Saturday 11 July 2020

Kubernetes: get the configuration used by kubectl

Just execute the command ‘kubectl config view’ to see the configuration used by kubectl.

$kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority: /Users/krishna/.minikube/ca.crt
    server: https://192.168.99.100:8443
  name: minikube
contexts:
- context:
    cluster: minikube
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
  user:
    client-certificate: /Users/krishna/.minikube/profiles/minikube/client.crt
    client-key: /Users/krishna/.minikube/profiles/minikube/client.key

As you observe above output,

a.   user with the name ‘minikube’ is configured with some client certificate and client key. This set up is done by minikube. This is the reason why kubectl does not ask you to login while communicating with Kubernetes.

b.   Specifies which cluster to communicate with (https://192.168.99.100:8443).

 

When you directly hit the server url in browser, you will receive a Forbidden message. It is because you are not provided any authentication details.

 

{

  "kind": "Status",

  "apiVersion": "v1",

  "metadata": {

   

  },

  "status": "Failure",

  "message": "forbidden: User \"system:anonymous\" cannot get path \"/\"",

  "reason": "Forbidden",

  "details": {

   

  },

  "code": 403

}

 

Kubectl Configuration is located in the file '~/.kube/config' (~ represents your home directory).



Previous                                                    Next                                                    Home

No comments:

Post a Comment