rancher自定义集群master组件被删除
第一步.备份etcd目录
备份/var/lib/etcd/目录 cp /var/lib/etcd /var/lib/etcd.bak
第二部.点击编辑集群,在master原节点执行生成的命令,添加主机页面添加3个master主机,和node主机
等待master组件启动
第二步.创建注册命令
获取到以下执行命令
` curl --insecure -sfL https://172.30.1.159:8443/v3/import/5qk4w2lvgpvl2rtd7tcwm54wj56tj9gmlv4wrnrqsgrrff9f55rbg6.yaml | kubectl apply -f - `
进入k8s master 01 节点执行以上命令,如没有下载kubectl配置文件则以下第二步创建kubectl config文件
第三步.创建kubectl config(有则跳过)
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 - `