This topic describes how to connect to a Kubernetes cluster through kubectl.

Background information

If you need to connect to Kubernetes clusters from a local computer, use the Kubernetes command line tool, kubectl.

Procedure

  1. Download the latest kubectl version from the Kubernetes release page.
  2. Install and set up kubectl.
    For more information, see Install and set up kubectl.
  3. Configure cluster credentials.
    • To connect to the cluster from public networks, select the KubeConfig (Public Access) tab, click Copy, and paste the copied content to the $HOME/.kube/config directory on your local machine. This is the directory where kubectl credentials are stored.
    • To connect to the cluster from internal networks, select the KubeConfig (Internal Access) tab, click Copy, and paste the copied content to the $HOME/.kube/config directory on your local machine. This is the directory where kubectl credentials are stored.

    After the configuration is complete, you can use kubectl to access Kubernetes clusters from your local computer.

    1. Log on to the Container Service console.
    2. In the left-side navigation pane, click Clusters to go to the Clusters page.
    3. Select the target cluster and click Manage in the Actions column.

      You can view the cluster address in the Cluster Information section.

      Cluster address
      Note The method introduced here only applies to dedicated Kubernetes clusters.