Get the following output with Config view. Notice no "Current Context"
root@Bootstrap [ /etc ]# kubectl config view
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: DATA+OMITTED
server: https://192.168.10.50:6443
name: tanzu-m01
contexts:
- context:
cluster: tanzu-m01
user: tanzu-m01-admin
name: tanzu-m01-admin@tanzu-m01
current-context: ""
kind: Config
preferences: {}
users:
- name: tanzu-m01-admin
user:
client-certificate-data: REDACTED
client-key-data: REDACTED
- name: tkgm-mgmt01-admin
user:
client-certificate-data: REDACTED
client-key-data: REDACTED
Using kubectl set-context >> shows context modified
root@Bootstrap [ /etc ]# kubectl config set-context tanzu-m01-admin@tanzu-m01
Context "tanzu-m01-admin@tanzu-m01" modified.
However on "kubectl config current-context" shows current-context not set
root@Bootstrap [ /etc ]# kubectl config current-context
error: current-context is not set
What am i missing ?
The correct command is:
kubectl config use-context ${CONTEXT}
You can confirm this with:
kubectl config --help
set-context Set a context entry in kubeconfig
use-context Set the current-context in a kubeconfig file
kubectl config set-context set properties of the specified context:
kubectl config set-context ${CONTEXT} \
--cluster=${CLUSTER} \
--user=user_${USER} \
--namespace=${NAMESPACE}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With