jonmosco / kube-ps1

Kubernetes prompt info for bash and zsh
Apache License 2.0
3.47k stars 349 forks source link

Prompt continues to show deleted context #150

Closed unmarshall closed 2 years ago

unmarshall commented 2 years ago

Hi,

Initially my kube-context had 2 contexts:

I deleted local-garden via kubectl config delete-context local-garden command. The context was removed from kubeconfig which is kept at its default location of ~/.kube/config. Shell used: zsh OS: macos, App: Terminal.app

There is no env KUBECONFIG set. Even after deleting the context the prompt continues to show:

(⎈ |local-garden:default)~ ➤ k config get-contexts                                                                                                                
CURRENT   NAME       CLUSTER    AUTHINFO   NAMESPACE
          minikube   minikube   minikube   default
(⎈ |local-garden:default)~ ➤

It seems that kube-ps1 is not reflecting the context properly. Even if you open a brand new terminal when zshrc is replayed the context still does not change.

It seems that the cache only updates the namespace and not the context. When it should actually be updating both.

unmarshall commented 2 years ago

Ok it seems that the issue is with the kubectl commands. When you do kubectl config delete-context then it does not change the correct context. The current-context continues to point to a context which has no entry under contexts in the kube config file which is a bit strange. If i now explicitly go into the kube config and then remove the value of current-context then it get properly reflected in PS1 so there is no issue with PS1. Apologies for creating an issue.

Closing this issue.