I have 3 contexts set up in k9s (context1
, context2
, context3
). I know I can change the context within k9s by typing :context
but how do I change the default context that loads when I open k9s from context3
to context1
?
Changing the default k9s/Kubernetes context
Asked Answered
You can set the default context via kubectl
:
kubectl config use-context context1
This will update the default context in your KUBECONFIG, what is the base for k9s.
From your commandline (not inside k9s
) you should be able to use kubectl
as k9s
needs it.
- get a list of the contexts:
kubectl config get-contexts
- set the default contexts:
kubectl config use-context <context>
Example shell
$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
dev dev dev
* test test test
my-context idk idk
$ kubectl config use-context my-context
Switched to context "my-context".
$ kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
dev dev dev
test test test
* my-context idk idk
$
Now you see the star on CURRENT
on a different value
I think you can change the k9s config.yml file, this link can help you understand better https://k9scli.io/topics/config, normally it is defined like this example:
k9s:
refreshRate: 2
maxConnRetry: 5
enableMouse: false
headless: false
logoless: false
crumbsless: false
readOnly: false
noExitOnCtrlC: false
noIcons: false
logger:
tail: 100
buffer: 5000
sinceSeconds: 60
fullScreenLogs: false
textWrap: false
showTime: false
**currentContext**: arn:aws:eks:us-east-1:ID:cluster/account-name
**currentCluster**: arn:aws:eks:us-east-1:ID:cluster/account-name
© 2022 - 2024 — McMap. All rights reserved.