Main Menu

Search

Thursday, April 11, 2024

KUBERNETES: How To Setup Kubectl Environment Variables On Control Node To Run Kubectl Commands?

Login to Kubernetes control node as user using which you want to run kubectl commands. Execute below commands to setup kubectl command

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
echo 'export KUBECONFIG=$HOME/.kube/config' >> $HOME/.bashrc

Validate that the kubectl commands are working. For this you can run below simple command to list the pods.

kubectl get pods -owide 

No comments:

Post a Comment