标签:微软 ssl mod net api err bec mkdir 参数
1 [root@k8smaster01 ~]# cd /opt/k8s/work 2 [root@k8smaster01 work]# wget https://dl.k8s.io/v1.14.2/kubernetes-client-linux-amd64.tar.gz 3 [root@k8smaster01 work]# tar -zxvf kubernetes-client-linux-amd64.tar.gz
1 [root@k8smaster01 ~]# cd /opt/k8s/work 2 [root@k8smaster01 work]# source /opt/k8s/bin/environment.sh 3 [root@k8smaster01 work]# for master_ip in ${MASTER_IPS[@]} 4 do 5 echo ">>> ${master_ip}" 6 scp kubernetes/client/bin/kubectl root@${master_ip}:/opt/k8s/bin/ 7 ssh root@${master_ip} "chmod +x /opt/k8s/bin/*" 8 done
1 [root@k8smaster01 ~]# cd /opt/k8s/work 2 [root@k8smaster01 work]# cat > admin-csr.json <<EOF 3 { 4 "CN": "admin", 5 "hosts": [], 6 "key": { 7 "algo": "rsa", 8 "size": 2048 9 }, 10 "names": [ 11 { 12 "C": "CN", 13 "ST": "Shanghai", 14 "L": "Shanghai", 15 "O": "system:masters", 16 "OU": "System" 17 } 18 ] 19 } 20 EOF 21 #创建admin的CA证书请求文件
1 [root@k8smaster01 ~]# cd /opt/k8s/work 2 [root@k8smaster01 work]# cfssl gencert -ca=/opt/k8s/work/ca.pem \ 3 -ca-key=/opt/k8s/work/ca-key.pem -config=/opt/k8s/work/ca-config.json 4 -profile=kubernetes admin-csr.json | cfssljson -bare admin #生成CA密钥(ca-key.pem)和证书(ca.pem)
1 [root@k8smaster01 ~]# cd /opt/k8s/work 2 [root@k8smaster01 work]# source /opt/k8s/bin/environment.sh 3 [root@k8smaster01 work]# kubectl config set-cluster kubernetes 4 --certificate-authority=/opt/k8s/work/ca.pem 5 --embed-certs=true 6 --server=${KUBE_APISERVER} 7 --kubeconfig=kubectl.kubeconfig # 设置集群参数 8 [root@k8smaster01 work]# kubectl config set-credentials admin 9 --client-certificate=/opt/k8s/work/admin.pem 10 --client-key=/opt/k8s/work/admin-key.pem 11 --embed-certs=true 12 --kubeconfig=kubectl.kubeconfig # 设置客户端认证参数 13 [root@k8smaster01 work]# kubectl config set-context kubernetes 14 --cluster=kubernetes 15 --user=admin 16 --kubeconfig=kubectl.kubeconfig # 设置上下文参数 17 [root@k8smaster01 work]# kubectl config use-context kubernetes --kubeconfig=kubectl.kubeconfig # 设置默认上下文
1 [root@k8smaster01 ~]# cd /opt/k8s/work 2 [root@k8smaster01 work]# source /opt/k8s/bin/environment.sh 3 [root@k8smaster01 work]# for master_ip in ${MASTER_IPS[@]} 4 do 5 echo ">>> ${master_ip}" 6 ssh root@${master_ip} "mkdir -p ~/.kube" 7 scp kubectl.kubeconfig root@${master_ip}:~/.kube/config 8 done
标签:微软 ssl mod net api err bec mkdir 参数
原文地址:https://www.cnblogs.com/itzgr/p/11865195.html