tencent cloud

Connecting to a Registered Cluster
最終更新日:2024-05-09 15:47:11
Connecting to a Registered Cluster
最終更新日: 2024-05-09 15:47:11

Operation Scenarios

This document describes how to connect a local client to a registered cluster using kubectl, the Kubernetes command-line tool.

Prerequisites

The cURL software has been installed.
Select an appropriate way to obtain kubectl based on the type of the operating system:
Note:
Replace the version v1.8.13 in the command line with the kubectl version required for your business, according to the version you are actually using.
macOS
Linux
Windows
Execute the following command to obtain kubectl:
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.8.13/bin/darwin/amd64/kubectl

Execute the following command to obtain kubectl:
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.8.13/bin/linux/amd64/kubectl

Execute the following command to obtain kubectl:
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.8.13/bin/windows/amd64/kubectl.exe


Directions

Installing kubectl

1. Refer to Install and Set Up kubectl to install kubectl.
Note:
If you have already installed kubectl, skip this step.
This step uses the Linux operating system as an example.
2. Execute the following commands in sequence to grant execution permissions.
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
3. Execute the following command to check the installation result.
kubectl version
If the output is similar to the following version information, the installation was successful.
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.2", GitCommit:"08e099554f3c31f6e6f07b448ab3ed78d0520507", GitTreeState:"clean", BuildDate:"2017-01-12T04:57:25Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"linux/amd64"}

Configuring kubeconfig

1. Log in to the TKE console, and choose Cluster from the left navigation bar.
2. On the cluster list page, click the ID of the registered cluster you want to connect to, to enter the management page of the cluster.
3. Choose Basic Information from the left navigation bar to enter the basic information page of the cluster.
4. In the Cluster APIServer Information, obtain the kubeconfig for either public network access or private network access, which you can copy or download.
5. Configure the cluster credential as needed. For details, see Connecting to the Kubernetes Cluster Through kubectl in the console.

Accessing the Kubernetes Cluster

1. After completing the kubeconfig configuration, execute the following commands in sequence to view contexts and switch the contexts to access the cluster.
kubectl config get-contexts
kubectl config use-context cls-3jju4zdc-context-default
2. Execute the following command to check whether the cluster can be accessed.
kubectl get pod
If you cannot connect to the cluster, check whether public network access or private network access is enabled, and ensure that the access client is in the specified network environment.

Relevant Descriptions

Introduction to the kubectl CLI

kubectl is a command-line tool for operating Kubernetes clusters. This document covers syntax and common command operations of kubectl, and provides common examples. For detailed information about each command (including all main commands and subcommands), refer to the kubectl Reference Documentation or use the kubectl help command for more detailed assistance. For kubectl installation instructions, refer to the earlier section Installing kubectl.

この記事はお役に立ちましたか?
営業担当者に お問い合わせ いただくか チケットを提出 してサポートを求めることができます。
はい
いいえ

フィードバック