Giter Site home page Giter Site logo

k8spsdrive's Introduction

Kubernetes PowerShell Drive (aka K8sPSDrive)

This repository plays around the idea of exposing Kubernetes cluster as a PowerShell PSDrive.

This is binary PowerShell module, which means it is written in C#. This is purely experimental and a pet project of mine to learn C# and Kubernetes together.

Tested on PowerShell Core and built on .NET Core 3.1

Pre-requisites

Clone

Clone this repository

git clone https://github.com/DexterPOSH/K8sPSDrive.git

Building

Run the build script in the root of the project to install dependent modules and start the build.ps1 specifying bootstrap mode. This will restore the dotnet cake tool along with installing required PowerShell modules.

./build.ps1 -BootStrapOnly

To just run the build, execute

./build.ps1 

If you encounter (Permission denied) issues with above use dotnet cake tool in your shell (bash/zsh)

# or run dotnet cake from the repository root
dotnet cake ./build.cake --target="Build"

Once the module is built the artifacts are placed under ci/artifacts folder. In the PowerShell console open the repository root and run below commands.

Note - Mapping a K8sPSDrive uses the default KubeConfig at ~/.kube/config , so if that is not set it will throw an error

Import-Module -Name  ./ci/artifacts/K8sPSDrive.psd1 -Verbose
New-PSDrive -Name K8sPSDrive -PSProvider SHiPS -Root K8sPSDrive#K8sPSDrive.Root

If the drive is mapped, you can set the location using the name K8sPSDrive specified earlier.

Set-Location -Path K8sPSDrive:/

Once inside the PSDrive you can list the childrens.

 Get-ChildItem
PS K8sPSDrive:\> Get-ChildItem


    Directory: K8sPSDrive:


Mode  Name
----  ----
+     namespaces
+     nodes

Now, one can change directory and move down the path under namespaces

cd .\namespaces\

Under namespaces folder list all the namespaces

Gte-ChildItem
PS K8sPSDrive:\namespaces> ls


    Directory: K8sPSDrive:\namespaces


Mode NAME            STATUS AgeInDays
---- ----            ------ ---------
+    default         Active 16
+    kube-node-lease Active 16
+    kube-public     Active 16
+    kube-system     Active 16

Go inside a namespace and you'll see namspaced objects e.g. Deployments and Pods currently and list them.

cd ./kubec-system/pods; ls
PS K8sPSDrive:\namespaces> cd .\kube-system\pods\

PS K8sPSDrive:\namespaces\kube-system\pods> ls


    Directory: K8sPSDrive:\namespaces\kube-system\pods


Mode NAME                                   Ready Status  Restarts AgeInDays
---- ----                                   ----- ------  -------- ---------
.    coredns-f9fd979d6-qkrgm                1/1   Running 0        16
.    coredns-f9fd979d6-wl27c                1/1   Running 0        16
.    etcd-docker-desktop                    1/1   Running 0        0
.    kube-apiserver-docker-desktop          1/1   Running 0        0
.    kube-controller-manager-docker-desktop 1/1   Running 0        0
.    kube-proxy-2lwq6                       1/1   Running 0        16
.    kube-scheduler-docker-desktop          1/1   Running 0        0
.    storage-provisioner                    1/1   Running 0        16
.    vpnkit-controller                      1/1   Running 0        16

Visualization

Visualization of the codebase

k8spsdrive's People

Contributors

dexterposh avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.