🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 安装Kubectl客户端 ``` wget https://dl.k8s.io/v1.12.1/kubernetes-client-linux-amd64.tar.gz tar -xzvf kubernetes-client-linux-amd64.tar.gz mv kubernetes/client/bin/kubectl /usr/local/bin/ ​ rm -rf kubernetes rm -rf kubernetes-client-linux-amd64.tar.gz ​ # 创建证书 cat << EOF | tee /etc/cfssl/k8s/kubelet-172.16.0.51.json { "CN": "system:node:172.16.0.51", "hosts": [ "172.16.0.51", "master01.k8s.blit.cloud" ], "key": { "algo": "rsa", "size": 2048 }, "names": [ { "C": "CN", "L": "Guangxi", "ST": "Nanning", "O": "system:nodes", "OU": "Kubernetes-manual" } ] } EOF cfssl gencert \ -ca=/etc/pki/k8s/k8s-ca.pem -ca-key=/etc/pki/k8s/k8s-ca-key.pem \ -config=/etc/cfssl/ca-config.json \ -profile=kubernetes \ /etc/cfssl/k8s/kubelet-172.16.0.51.json | cfssljson -bare kubelet-172.16.0.51 ​ # 创建连接配置 kubectl config set-cluster kubernetes \ --certificate-authority=/etc/pki/k8s/k8s-ca.pem \ --embed-certs=true \ --server=https://172.16.0.51:6443 \ --kubeconfig=kubelet.172.16.0.51.kubeconfig kubectl config set-credentials system:node:172.16.0.51 \ --client-certificate=/etc/pki/k8s/kubelet-172.16.0.51.pem \ --client-key=/etc/pki/k8s/kubelet-172.16.0.51-key.pem \ --embed-certs=true \ --kubeconfig=kubelet.172.16.0.51.kubeconfig kubectl config set-context system:node:172.16.0.51@kubernetes \ --cluster=kubernetes \ --user=system:node:172.16.0.51 \ --kubeconfig=kubelet.172.16.0.51.kubeconfig kubectl config use-context system:node:172.16.0.51@kubernetes \ --kubeconfig=kubelet.172.16.0.51.kubeconfig `````