kubespray

How to change current-context


I use kubespray installed Kubernetes Cluster. I defined the cluster name as cluster.devops in the file, group_vars/k8s-cluster/k8s-cluster.yml. After the Kubernetes Cluster installed. the current-context in kube confi file is kubernetes-admin@cluster.devops. I would like the current-context is cluster.devops,

i.e. current-context is same as cluster name. How to do it?


Solution

  • you can rename context using

    kubectl config rename-context old-name new-name
    

    for example in your case

    kubectl config rename-context kubernetes-admin@cluster.devops cluster.devops