Search This Blog

Monday, 6 April 2020

Thank you kubie exactly what I needed

On average I deal with at least 5 different Kubernetes clusters so today when I saw / heard of kubie I had to install it.

kubie is an alternative to kubectx, kubens and the k on prompt modification script. It offers context switching, namespace switching and prompt modification in a way that makes each shell independent from others

Installing kubie right now involved download the release from the link below. Homebrew support is pending

Once added to your path it's as simple as this

1. Check kubie is in your path

$ which kubie

2. Run "kubie ctx" as follows and select the "apples" k8s context

papicella@papicella:~/pivotal/PCF/APJ/PEZ-HaaS/haas-236$ kubie ctx

[apples|default] papicella@papicella:~/pivotal/PCF/APJ/PEZ-HaaS/haas-236$

3. Switch to a new namespace as shown below and watch how the PS1 prompt changes to indicate the k8s conext and new namespace we have set as result of the command below

$ kubectl config set-context --current --namespace=vmware-system-tmc
Context "apples" modified.

[apples|vmware-system-tmc] papicella@papicella:~/pivotal/PCF/APJ/PEZ-HaaS/haas-236$

4. Finally kubie exec is a subcommand that allows you to run commands inside of a context, a bit like kubectl exec allows you to run a command inside a pod. Here is some examples below
[apples|vmware-system-tmc] papicella@papicella:~/pivotal/PCF/APJ/PEZ-HaaS/haas-236$ kubie exec apples vmware-system-tmc kubectl get pods
NAME                                        READY   STATUS    RESTARTS   AGE
agent-updater-75f88b44f6-9f9jj              1/1     Running   0          2d23h
agentupdater-workload-1586145240-kmwln      1/1     Running   0          3s
cluster-health-extension-76d9b549b5-dlhms   1/1     Running   0          2d23h
data-protection-59c88488bd-9wxk2            1/1     Running   0          2d23h
extension-manager-8d69d95fd-sgksw           1/1     Running   0          2d23h
extension-updater-77fdc4574d-fkcwb          1/1     Running   0          2d23h
inspection-extension-64857d4d95-nl76f       1/1     Running   0          2d23h
intent-agent-6794bb7995-jmcxg               1/1     Running   0          2d23h
policy-sync-extension-7c968c9dcd-x4jvl      1/1     Running   0          2d23h
policy-webhook-779c6f6c6-ppbn6              1/1     Running   0          2d23h
policy-webhook-779c6f6c6-r82h4              1/1     Running   1          2d23h
sync-agent-d67f95889-qbxtb                  1/1     Running   6          2d23h
[apples|vmware-system-tmc] papicella@papicella:~/pivotal/PCF/APJ/PEZ-HaaS/haas-236$ kubie exec apples default kubectl get pods
NAME                                     READY   STATUS      RESTARTS   AGE
pbs-demo-image-build-1-mnh6v-build-pod   0/1     Completed   0          2d23h
[apples|vmware-system-tmc] papicella@papicella:~/pivotal/PCF/APJ/PEZ-HaaS/haas-236$

More Information

Blog Page:

GitHub Page:

No comments: