k9s
k9s copied to clipboard
Add support for delete context (Ctrl+D) from k9s
Like other k8s resources, please add support for deleting a context with Ctrl+D in the contexts view. This would make it easier for me to clean up cluttered context settings with k9s.
What we'd normally do with kubectl
is:
$ kubectl config get-contexts
and then:
$ kubectl config delete-context <chosen-context>
Please just support the same operation from k9s UI.
I don't like the idea of using an standard linxu key-combo for such an critical task.
@rockaut Is this so critical? It's just deleting an authentication cache to a k8s cluster from client side. It shouldn't do anything to the remote cluster.
Sorry I got this somewhat wrong ... but ctrl+d is not only deleting in contexts but in any view. So you can also delete a pod with ctrl+d thought there is a confirmation box.
But you're right my comment was irrelevant for your issue sorry.
👍 for this feature request.
This plugin works when added to your ~/.k9s/plugin.yml
; however, k9s doesn't allow reload/refresh of the contexts (you need to quit/restart):
plugin:
deleteContext:
shortCut: Ctrl-D
confirm: true
description: Delete kubectl context
scopes:
- contexts
command: kubectl
background: true
args:
- config
- delete-context
- $NAME
Adding the ability to refresh contexts would be a great MVP feature for this. I've been wanting to add a plugin for pulling kubeconfigs from ClusterAPI & gcloud
also, which would benefit from reload-able contexts as well.
Great plugin, thank you. It works on usual k8s but it fails on AWS, they are naming its clusters with arn and it need
full name to be deleted: arn:aws:eks:eu-west-2:1234567890:cluster/delteme
kubectl config delte-context delteme #failed
kubectl config delte-context arn:aws:eks:eu-west-2:1234567890:cluster/delteme #cluster deleted
I have tried things like
- "$NAME"
- \"$NAME\"
... but without any results. Do you have any hint? Thanks
@robinpecha I'm using - $COL-NAME
and it works fine.
From docs: $COL-<RESOURCE_COLUMN_NAME> use a given column name for a viewed resource. Must be prefixed by COL-!
this worked for me:
arothste@console:~$ cat ~/.config/k9s/plugins.yaml
---
plugins:
deleteContext:
shortCut: Ctrl-D
confirm: true
description: Delete kubectl context
scopes:
- contexts
command: kubectl
background: true
args:
- config
- delete-context
- $COL-NAME