乐趣区

关于kubernetes:Unable-to-connect-to-the-server-x509-certificate-has-xxxx

systemctl restart haproxy
systemctl restart keepalived

[root@master49 ~]# systemctl restart keepalived
[root@master49 ~]# kubectl get node
Unable to connect to the server: x509: certificate has expired or is not yet valid
[root@master49 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:50:56:90:60:e2 brd ff:ff:ff:ff:ff:ff
    inet 172.16.197.49/24 brd 172.16.197.255 scope global noprefixroute ens160
       valid_lft forever preferred_lft forever
    inet 172.16.197.200/32 scope global ens160
       valid_lft forever preferred_lft forever
3: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1
    link/ipip 0.0.0.0 brd 0.0.0.0
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:79:10:bc:7b brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever


  • 看着配置的 https://k8s-lb:16443 也有了端口

万万没想到竟然是工夫问题影响的

[root@master49 ~]# kubectl get node
Unable to connect to the server: x509: certificate has expired or is not yet valid



May 28 08:07:11 master49 kubelet: E0528 08:07:11.931549   19064 reflector.go:178] k8s.io/kubernetes/pkg/kubelet/config/apiserver.go:46: Failed to list *v1.Pod: Get https://k8s-lb:16443/api/v1/pods?fieldSelector=spec.nodeName%3Dmaster49&limit=500&resourceVersion=0: x509: certificate has expired or is not yet valid
May 28 08:07:11 master49 kubelet: E0528 08:07:11.936527   19064 reflector.go:178] k8s.io/kubernetes/pkg/kubelet/kubelet.go:526: Failed to list *v1.Node: Get https://k8s-lb:16443/api/v1/nodes?fieldSelector=metadata.name%3Dmaster49&limit=500&resourceVersion=0: x509: certificate has expired or is not yet valid
May 28 08:07:11 master49 kubelet: E0528 08:07:11.938526   19064 reflector.go:178] k8s.io/kubernetes/pkg/kubelet/kubelet.go:517: Failed to list *v1.Service: Get https://k8s-lb:16443/api/v1/services?limit=500&resourceVersion=0: x509: certificate has expired or is not yet valid
May 28 08:07:11 master49 kubelet: E0528 08:07:11.941466   19064 reflector.go:178] k8s.io/kubernetes/pkg/kubelet/config/apiserver.go:46: Failed to list *v1.Pod: Get https://k8s-lb:16443/api/v1/pods?fieldSelector=spec.nodeName%3Dmaster49&limit=500&resourceVersion=0: x509: certificate has expired or is not yet valid
May 28 08:07:11 master49 kubelet: E0528 08:07:11.946360   19064 reflector.go:178] k8s.io/kubernetes/pkg/kubelet/kubelet.go:526: Failed to list *v1.Node: Get https://k8s-lb:16443/api/v1/nodes?fieldSelector=metadata.name%3Dmaster49&limit=500&resourceVersion=0: x509: certificate has expired or is not yet valid
^C
[root@master49 ~]# date
Thu May 28 08:07:15 CST 1998
[root@master49 ~]# crontab -l
52 23 * * * /usr/sbin/ntpdate us.pool.ntp.org
[root@master49 ~]# /usr/sbin/ntpdate us.pool.ntp.org
29 Mar 18:59:00 ntpdate[23754]: step time server 44.190.40.123 offset 720701478.575950 sec
[root@master49 ~]# date
Mon Mar 29 18:59:02 CST 2021
[root@master49 ~]# kubectl get node


退出移动版