Coreos集群中安装Kubernetes的步骤(4)

在Master节点中,执行下面命令下载kubectl工具.

curl -O https://storage.googleapis.com/kubernetes-release/release/v1.6.1/bin/linux/amd64/kubectl

chmod +x kubectl

mv kubectl /usr/local/bin/kubectl  

配置环境变量:

  • MASTER_HOST master节点IP
  • CA_CERT ca.pem证书位置
  • ADMIN_KEY admin-key.pem证书位置
  • ADMIN_CERT admin.pem证书位置

执行下面四条命令:

kubectl config set-cluster default-cluster --server=https://${MASTER_HOST} --certificate-authority=${CA_CERT}

kubectl config set-credentials default-admin --certificate-authority=${CA_CERT} --client-key=${ADMIN_KEY} --client-certificate=${ADMIN_CERT}

kubectl config set-context default-system --cluster=default-cluster --user=default-admin

kubectl config use-context default-system  

验证配置是否正确:

kubectl get nodes  
输出类似于下面:
NAME          LABELS                               STATUS  
X.X.X.X       kubernetes.io/hostname=X.X.X.X       Ready