1、Unable to connect to the server: x509: certificate signed by unknown authority

背景:

云服务器上之前已经安装过 kubernetes master 以及一些pod。 现在kill k8重新安装。(将原配置改为 flannel 在node,pod之前安装)。

操作:

sudo kubeadm init –pod-network-cidr=10.244.0.0/16 –image-repository registry.aliyuncs.com/google_containers

然后:

kubectl get pods -A

报错:
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”)
该问题由配置未更新造成(之前的配置还在)。
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
再次执行: kubectl get pods -A

2、0/3 nodes are available: 1 node(s) had taint {node-role.kubernetes.io/controlplane: true}, that the pod didn’t tolerate, 2 node(s) didn’t match Pod’s node affinity/selector.

Internal error occurred: failed calling webhook “validate.nginx.ingress.kubernetes.io”: Post “https://ingress-nginx-controller-admission.ingress-nginx.svc:443/networking/v1beta1/ingresses?timeout=10s": dial tcp 10.43.132.113:443: connect: connection refused

原因分析:

我刚开始使用yaml的方式创建 nginx-ingress ,之后删除了它创建的命名空间以及 clusterrole and clusterrolebinding ,但是没有删除 ValidatingWebhookConfiguration ingress-nginx-admission,这个ingress-nginx-admission 是在yaml文件中安装的。当我再次使用helm安装nginx-ingress之后,创建自定义的 ingress 就会报这个错误。

解决方案:

最后参考下面的文章解决此问题

  • 使用下面的命令查看 webhook
kubectl get validatingwebhookconfigurations
ingress-nginx-admission
  • 删除 ingress-nginx-admission
kubectl delete -A ValidatingWebhookConfiguration ingress-nginx-admission
作者:Jeebiz  创建时间:2022-05-21 16:34
 更新时间:2024-08-02 14:28