Kubernetes 简明教程
Kubernetes - Kubectl
Kubectl 是与 Kubernetes API 交互的命令行实用程序。它是一个用于在 Kubernetes 集群中通信和管理容器的界面。
Kubectl is the command line utility to interact with Kubernetes API. It is an interface which is used to communicate and manage pods in Kubernetes cluster.
需要在本地设置 kubectl 以与 Kubernetes 集群交互。
One needs to set up kubectl to local in order to interact with Kubernetes cluster.
Setting Kubectl
使用 curl 命令将可执行文件下载到本地工作站。
Download the executable to the local workstation using the curl command.
Configuring Kubectl
以下是执行配置操作的步骤。
Following are the steps to perform the configuration operation.
$ kubectl config set-cluster default-cluster --server = https://${MASTER_HOST} --
certificate-authority = ${CA_CERT}
$ kubectl config set-credentials default-admin --certificateauthority = ${
CA_CERT} --client-key = ${ADMIN_KEY} --clientcertificate = ${
ADMIN_CERT}
$ kubectl config set-context default-system --cluster = default-cluster --
user = default-admin
$ kubectl config use-context default-system
-
Replace ${MASTER_HOST} with the master node address or name used in the previous steps.
-
Replace ${CA_CERT} with the absolute path to the ca.pem created in the previous steps.
-
Replace ${ADMIN_KEY} with the absolute path to the admin-key.pem created in the previous steps.
-
Replace ${ADMIN_CERT} with the absolute path to the admin.pem created in the previous steps.