Bartosz Bierkowski - Low dose cloud

Minishift: recover .kube/config

I deleted my .kube/config file, which stores the configuration for OpenShift cluster in Minishift.

The cluster accepts any user, so it’s not a problem. Only when you want to have a look around and become an admin, you need system:admin credentials or cluster-admin privileges.

Creating initial project "myproject" ...                                                                                                                                      
Server Information ...                                                                                                                                                        
OpenShift server started.                                                                                                                                                     
                                                                                                                                                                              
The server is accessible via web console at:                                                                                                                                  
    https://192.168.42.188:8443/console                                                                                                                                       
                                                                                                                                                                              
You are logged in as:                                                                                                                                                         
    User:     developer                                                                                                                                                       
    Password: <any value>

To login as administrator:
    oc login -u system:admin

The oc login -u system:admin command does not work, as it asks for a password.

$ oc login -u system:admin --server https://192.168.42.188:8443 --insecure-skip-tls-verify
Authentication required for https://192.168.42.188:8443 (openshift)
Username: system:admin
Password: 
error: username system:admin is invalid for basic auth

I found solution to my problem in one of issues: https://github.com/minishift/minishift/issues/2107#issuecomment-441332761

There are multiple tickets open for similar problems. I liked the option to just get the config file from vm.

minishift ssh
sudo cat /home/docker/.kube/config

Copying the content of the file into ~/.kube/config file fixes the problem. The login as system:admin users works again.