4.5 Using the kubectl Command

When you have deployed a Kubernetes cluster to the nodes, you can use the kubectl command to create and manage pods. It is recommended that you use the kubectl command on a master node in the Kubernetes cluster.


You must set up the kubectl command before you can use it.

To set up the kubectl command on a master node, copy and paste these commands to a terminal in your home directory on a master node:

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

For more information on setting up and using the kubectl command to manage pods, see Container Orchestration.