k8s主节点更换证书后,从节点使用kubectl get pods命令报Config not found: /etc/kubernetes/admin.conf:
解决:
1.替换config文件
更换主节点的证书后,将主节点”.kube/config“文件复制到从节点相应位置
2.复制admin.conf文件
由于报错是找不到admin.conf文件,所以从主节点复制该文件到从节点
3.新增环境变量
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
source ~/.bash_profile
如下:
[root@node1 kubernetes]# echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
[root@node1 kubernetes]# source ~/.bash_profile
[root@node1 kubernetes]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-7ff77c879f-gkgwr 1/1 Running 0 35h
coredns-7ff77c879f-vhlmt 1/1 Running 0 35h
etcd-master 1/1 Running 0 35h
kube-apiserver-master 1/1 Running 0 35h
kube-controller-manager-master 1/1 Running 0 35h
kube-flannel-ds-amd64-6htwx 1/1 Running 0 27h
kube-flannel-ds-amd64-glljs 1/1 Running 4 27h
kube-flannel-ds-amd64-wbcdn 1/1 Running 4 27h
kube-proxy-678v8 1/1 Running 0 35h
kube-proxy-p75c4 1/1 Running 4 27h
kube-proxy-qmlct 1/1 Running 3 27h
kube-scheduler-master 1/1 Running 0 35h
可看到问题解决了
参考自(https://www.cnblogs.com/wind-zhou/p/12829079.html)