Share with together

独乐乐不如众乐乐

博客园 首页 新随笔 联系 订阅 管理
  35 随笔 :: 10 文章 :: 33 评论 :: 23万 阅读

错误描述:

1
2
[root@k8s-master ~]# kubectl get nodes
Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")

一般是:k8s master 初始化操作不完整导致,完整过程如下:

1
[root@k8s-master ~]# kubeadm reset

 

1
[root@k8s-master ~]# kubeadm init --apiserver-advertise-address=192.168.58.138 --kubernetes-version v1.23.5 --pod-network-cidr=192.168.0.0/16

  

看到如下提示信息后要继续执行:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Your Kubernetes control-plane has initialized successfully!
 
To start using your cluster, you need to run the following as a regular user:
 
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
 
Alternatively, if you are the root user, you can run:
 
export KUBECONFIG=/etc/kubernetes/admin.conf
 
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/
 
Then you can join any number of worker nodes by running the following on each as root:
 
kubeadm join 192.168.58.138:6443 --token ngpadd.js4es78t13mi9cjd \
--discovery-token-ca-cert-hash sha256:a72b70060492ad11c2034db603c6d58b069d18a7aa44cd8903ccb383ffdb342a

  

如果当前是 root 用户,执行如下:

1
[root@k8s-master ~]# export KUBECONFIG=/etc/kubernetes/admin.conf

  

如果当时是非root用户,执行如下:

1
2
3
[root@k8s-master ~]#mkdir -p $HOME/.kube
[root@k8s-master ~]#sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
[root@k8s-master ~]#sudo chown $(id -u):$(id -g) $HOME/.kube/config

  

再次执行:

1
2
3
4
[root@k8s-master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready control-plane,master 106m v1.23.5
k8s-node1 Ready <none> 97m v1.23.5

  

 问题解决,希望能帮到您!

posted on   寒枫  阅读(3734)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
点击右上角即可分享
微信分享提示