Skip to content

Latest commit

 

History

History
executable file
·
152 lines (97 loc) · 2.59 KB

File metadata and controls

executable file
·
152 lines (97 loc) · 2.59 KB

Lab - KubeConfig

  • Take me to the Lab

Solutions for Lab - KubeConfig:

  • Look for the kube config file under the /root/.kube directory.

    $ ls -l /root/.kube
    
  • Run the kubectl config view command and count the number of clusters.

    $ kubectl config view
    
  • Run the command kubectl config view and count the number of users.

    $ kubectl config view
    
  • How many contexts are defined in the default kubeconfig file?

    $ kubectl config view
    
  • Run the command kubectl config view and look for the user name.

    $ kubectl config view
    
  • What is the name of the cluster configured in the default kubeconfig file?

    $ kubectl config view
    
  • Run the command kubectl config view --kubeconfig my-kube-config.

    $ kubectl config view --kubeconfig my-kube-config
    
  • How many contexts are configured in the 'my-kube-config' file?

    $ kubectl config view --kubeconfig my-kube-config
    
  • What user is configured in the 'research' context?

    $ kubectl config view --kubeconfig my-kube-config
    
  • What is the name of the client-certificate file configured for the 'aws-user'?

    $ kubectl config view --kubeconfig my-kube-config
    
  • What is the current context set in the 'my-kube-config' file?

    $ kubectl config view --kubeconfig my-kube-config
    
  • Run the command kubectl config --kubeconfig=/root/my-kube-config use-context research

    $ kubectl config --kubeconfig=/root/my-kube-config use-context research
    
  • Replace the contents in the default kubeconfig file with the content from my-kube-config file.

    $ mv ~/.kube/config ~/.kube/config.bak
    
    $ cp /root/my-kube-config ~/.kube/config
    
  • The path to certificate is incorrect in the kubeconfig file. Fix it. All users certificates are stored at /etc/kubernetes/pki/users.

    $ kubectl get pods
    
    $ ls
    
    dev-user.crt  dev-user.csr  dev-user.key
    
    $ vi /root/.kube/config
    
    $ grep dev-user.crt /root/.kube/config
    
    client-certificate: /etc/kubernetes/pki/users/dev-user/dev-user.crt
    
    $ pwd
    
    /etc/kubernetes/pki/users/dev-user
    
    $ kubectl get pods
    
    No resources found in default namespace.