This topic describes how to use the Kubernetes command-line client kubectl to connect to a Kubernetes cluster from a local computer.
- Download the latest kubectl client from the Kubernetes version description page.
- Install and configure the kubectl client.
For more information, see Install and configure kubectl.
- Configure the cluster credentials.
You can view the cluster credentials on the cluster information page.
- Log on to the Container Service console.
- In the left-side navigation pane under Container Service - Kubernetes, choose . The Clusters page appears.
- In the Actions column of the target cluster, click Manage.
- View the endpoint of the cluster in the Cluster Information section.
- Copy the cluster credentials to a local file. You can create the $HOME/.kube/config file and copy the cluster credentials to this file. This is the default file from
which kubectl obtains cluster credentials. You can also create a file, such as /tmp/kubeconfig, and copy the cluster credentials to the file. Then, run the
- After completing the preceding configuration, run the following command to check whether
the kubectl client is connected to the cluster:
#kubectl get pod No resources found.
What to do next
After completing the configuration, you can use kubectl to access the Kubernetes cluster from a local computer.