/
Kubernetes X509 certification issue while executing kubectl

Kubernetes X509 certification issue while executing kubectl

Problem

Getting the following error while executing kubectl commands. Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")

Cause

Default kubernetes configuration file  - /etc/kubernetes/admin.conf is not copied to home location reference (either $HOME/.kube/config or $HOME/admin.conf) after executing "kubeadm init"

Fix

Run the below commands as non-root user. To copy the kubernetes cluster configuration to $HOME/.kube/config

       To start using your cluster, run below commands:

          mkdir -p $HOME/.kube

          sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

          sudo chown $(id -u):$(id -g) $HOME/.kube/config

          export KUBECONFIG=$HOME/.kube/config

Add “export KUBECONFIG=$HOME/.kube/config” to ~/.bashrc file in order to export the conf file. If this is not added, the export will be applicable only to the current putty session. For a new session, the Kubernetes API will be unreachable.

(OR)

Run the below commands as root user. To copy the kubernetes cluster configuration to $HOME/admin.conf

    To start using your cluster, run below commands as root user or prefix with sudo:

          cp /etc/kubernetes/admin.conf $HOME/

          chown $(id -u):$(id -g) $HOME/admin.conf

          export KUBECONFIG=$HOME/admin.conf

Add “export KUBECONFIG=$HOME/admin.conf” to ~/.bashrc file in order to export the conf file. If this is not added, the export will be applicable only to the current putty session. For a new session, the Kubernetes API will be unreachable.

Related content

Kubernets Issues
Kubernets Issues
More like this
Unable to list Kube related resources
Unable to list Kube related resources
More like this
API access issue
API access issue
More like this
Kube Pods stay in the terminating state
Kube Pods stay in the terminating state
More like this
Knowledge Base
Knowledge Base
More like this
Steps to be followed when Kubernetes pod/containers not reachable to internet
Steps to be followed when Kubernetes pod/containers not reachable to internet
More like this