kubernetesdocker-for-windowsdocker

Get back docker-for-windows Kuberentes kubeconfig file after deleting it


My Docker for Windows ~/.kube/config file was replaced when setting up access to cloud based K8s cluster.

Is there a way to re-create it without having to restart Docker for Windows Kubernetes?

Update My current ~/.kube/config file is now set to a GKE cluster. I don't want to reset Docker for Kubernetes and clobber it. Instead I want to create a separate kubeconfig file for Docker for Windows i.e. place it in some other location rather than ~/.kube/config.


Solution

  • You probably want to back up your ~/.kube/config for GKE and then disable/reenable Kubernetes on Docker for Windows. Pull up a Windows command prompt:

    copy \<where-your-.kube-is\config \<where-your-.kube-is\config.bak
    

    Then follow this. In essence, uncheck the box, wait for a few minutes and check it again.

    docker for windows

    You can re-recreate without disabling/reenabling Kubernetes on Docker but you will have to know exactly where your API server and credentials (certificates, etc):

     kubectl config set-context ...
     kubectl config use-context ...
    

    What's odd is that you are specifying ~/.kube/config where the ~ (tilde) thingy is unix/linux thing, but maybe what you mean is $HOME