备份/var/lib/etcd/目录
cp /var/lib/etcd /var/lib/etcd.bak
curl --insecure -sfL https://172.30.1.159:8443/v3/import/5qk4w2lvgpvl2rtd7tcwm54wj56tj9gmlv4wrnrqsgrrff9f55rbg6.yaml | kubectl apply -f -
cp /etc/kubernetes/ssl/kubecfg-kube-node.yaml /root/.kube/config
若执行kubect无法操作k8s则创建以下自定义admin证书
创建admin.key
umask 077;openssl genrsa -out admin.key 2048 openssl req -new -key admin.key -out admin.csr -subj "/CN=kube-admin/O=system:masters" openssl x509 -req -days 999 -CA /etc/kubernetes/ssl/kube-ca.pem -CAkey /etc/kubernetes/ssl/kube-ca-key.pem -CAcreateserial -in ./admin.csr -out admin.pem
创建以下内容/root/.kube/config 将
apiVersion: v1 kind: Config clusters: - cluster: api-version: v1 certificate-authority: /etc/kubernetes/ssl/kube-ca.pem server: "https://127.0.0.1:6443" name: "local" contexts: - context: cluster: "local" user: "kube-node-local" name: "local" current-context: "local" users: - name: "kube-node-local" user: client-certificate: /etc/kubernetes/ssl/admin.pem client-key: /etc/kubernetes/ssl/admin.key
curl --insecure -sfL https://172.30.1.159:8443/v3/import/5qk4w2lvgpvl2rtd7tcwm54wj56tj9gmlv4wrnrqsgrrff9f55rbg6.yaml | kubectl apply -f -