首页 > 其他分享 >k8s 1.18证书更新

k8s 1.18证书更新

时间:2022-09-19 18:25:28浏览次数:79  
标签:daemon kube 证书 1.18 etcd Error such k8s response

1.证书过期

k8s安装一年以后,证书会过期

ubuntu@ip-172-31-25-85:~$ kubectl get pods
Unable to connect to the server: x509: certificate has expired or is not yet valid

 

2.证书检测

可以看出已经过期了

ubuntu@ip-172-31-25-85:$ sudo kubeadm alpha certs check-expiration
[check-expiration] Reading configuration from the cluster...
[check-expiration] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
[check-expiration] Error reading configuration from the Cluster. Falling back to default configuration

W0919 09:47:20.248483   16939 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
CERTIFICATE                EXPIRES                  RESIDUAL TIME   CERTIFICATE AUTHORITY   EXTERNALLY MANAGED
admin.conf                 Sep 16, 2022 06:12 UTC   <invalid>                               no
apiserver                  Sep 16, 2022 06:12 UTC   <invalid>       ca                      no
apiserver-etcd-client      Sep 16, 2022 06:12 UTC   <invalid>       etcd-ca                 no
apiserver-kubelet-client   Sep 16, 2022 06:12 UTC   <invalid>       ca                      no
controller-manager.conf    Sep 16, 2022 06:12 UTC   <invalid>                               no
etcd-healthcheck-client    Sep 16, 2022 06:12 UTC   <invalid>       etcd-ca                 no
etcd-peer                  Sep 16, 2022 06:12 UTC   <invalid>       etcd-ca                 no
etcd-server                Sep 16, 2022 06:12 UTC   <invalid>       etcd-ca                 no
front-proxy-client         Sep 16, 2022 06:12 UTC   <invalid>       front-proxy-ca          no
scheduler.conf             Sep 16, 2022 06:12 UTC   <invalid>                               no

CERTIFICATE AUTHORITY   EXPIRES                  RESIDUAL TIME   EXTERNALLY MANAGED
ca                      Sep 14, 2031 06:12 UTC   8y              no
etcd-ca                 Sep 14, 2031 06:12 UTC   8y              no
front-proxy-ca          Sep 14, 2031 06:12 UTC   8y              no

 

 

3.证书更新

 

ubuntu@ip-172-31-25-85:$ sudo kubeadm alpha certs renew all
[renew] Reading configuration from the cluster...
[renew] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
[renew] Error reading configuration from the Cluster. Falling back to default configuration

W0919 09:47:28.567846   17005 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
certificate embedded in the kubeconfig file for the admin to use and for kubeadm itself renewed
certificate for serving the Kubernetes API renewed
certificate the apiserver uses to access etcd renewed
certificate for the API server to connect to kubelet renewed
certificate embedded in the kubeconfig file for the controller manager to use renewed
certificate for liveness probes to healthcheck etcd renewed
certificate for etcd nodes to communicate with each other renewed
certificate for serving etcd renewed
certificate for the front proxy client renewed
certificate embedded in the kubeconfig file for the scheduler manager to use renewed

 

 

4.证书验证

 

ubuntu@ip-172-31-25-85:$ sudo kubeadm alpha certs check-expiration
[check-expiration] Reading configuration from the cluster...
[check-expiration] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'

CERTIFICATE                EXPIRES                  RESIDUAL TIME   CERTIFICATE AUTHORITY   EXTERNALLY MANAGED
admin.conf                 Sep 19, 2023 09:47 UTC   364d                                    no
apiserver                  Sep 19, 2023 09:47 UTC   364d            ca                      no
apiserver-etcd-client      Sep 19, 2023 09:47 UTC   364d            etcd-ca                 no
apiserver-kubelet-client   Sep 19, 2023 09:47 UTC   364d            ca                      no
controller-manager.conf    Sep 19, 2023 09:47 UTC   364d                                    no
etcd-healthcheck-client    Sep 19, 2023 09:47 UTC   364d            etcd-ca                 no
etcd-peer                  Sep 19, 2023 09:47 UTC   364d            etcd-ca                 no
etcd-server                Sep 19, 2023 09:47 UTC   364d            etcd-ca                 no
front-proxy-client         Sep 19, 2023 09:47 UTC   364d            front-proxy-ca          no
scheduler.conf             Sep 19, 2023 09:47 UTC   364d                                    no

CERTIFICATE AUTHORITY   EXPIRES                  RESIDUAL TIME   EXTERNALLY MANAGED
ca                      Sep 14, 2031 06:12 UTC   8y              no
etcd-ca                 Sep 14, 2031 06:12 UTC   8y              no
front-proxy-ca          Sep 14, 2031 06:12 UTC   8y              no

 

5.重启内核服务

证书更新以后,需要重启kube-apiserver, kube-controller-manager, kube-scheduler和etcd服务

已经k8s 1.18采用docker安装的,所以直接用docker重启服务即可:

 

ubuntu@ip-172-31-25-85:$ sudo docker ps |grep -E 'k8s_kube-apiserver|k8s_kube-controller-manager|k8s_kube-scheduler|k8s_etcd_etcd'|sudo xargs docker restart
3a058c979dfb
k8s_kube-apiserver_kube-apiserver-iz2zeabl8ta0jq1nd850igz_kube-system_91781631bd4116dd829bd7f13c56b009_5
a8ee21edf101
k8s_kube-scheduler_kube-scheduler-iz2zeabl8ta0jq1nd850igz_kube-system_a1a9ab0012f568abd5ff6d13f407098a_4
ce4f2ec2547f
k8s_kube-controller-manager_kube-controller-manager-iz2zeabl8ta0jq1nd850igz_kube-system_d5e6fcb0367b27d18401e3e75f0e3634_4
3f353e38ccb6
k8s_etcd_etcd-iz2zeabl8ta0jq1nd850igz_kube-system_c7f9a92bff37fb94e3d0ab73329c1359_1
Error response from daemon: No such container: 8836b0d760bf
Error response from daemon: No such container: kube-apiserver --ad…
Error response from daemon: No such container: About
Error response from daemon: Multiple IDs found with provided prefix: a
Error response from daemon: No such container: minute
Error response from daemon: No such container: ago
Error response from daemon: No such container: Up
Error response from daemon: No such container: About
Error response from daemon: Multiple IDs found with provided prefix: a
Error response from daemon: No such container: minute
Error response from daemon: No such container: ef5be715de1b
Error response from daemon: No such container: kube-scheduler --au…
Error response from daemon: Multiple IDs found with provided prefix: 3
Error response from daemon: No such container: days
Error response from daemon: No such container: ago
Error response from daemon: No such container: Up
Error response from daemon: Multiple IDs found with provided prefix: 4
Error response from daemon: No such container: minutes
Error response from daemon: No such container: a0f70a7cf739
Error response from daemon: No such container: kube-controller-man…
Error response from daemon: Multiple IDs found with provided prefix: 3
Error response from daemon: No such container: days
Error response from daemon: No such container: ago
Error response from daemon: No such container: Up
Error response from daemon: Multiple IDs found with provided prefix: 4
Error response from daemon: No such container: minutes
Error response from daemon: No such container: 303ce5db0e90
Error response from daemon: No such container: etcd --advertise-cl…
Error response from daemon: Multiple IDs found with provided prefix: 9
Error response from daemon: No such container: months
Error response from daemon: No such container: ago
Error response from daemon: No such container: Up
Error response from daemon: Multiple IDs found with provided prefix: 4
Error response from daemon: No such container: minutes

 

6.拷贝证书给当前用户

 K8s会用到当前用户的权限,可以拷贝配置文件,或者设置链接

 拷贝:

   mkdir -p $HOME/.kube

   sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

  sudo chown $(id -u):$(id -g) $HOME/.kube/config         

软连接:

  mkdir -p $HOME/.kube

  sudo ln -sf /etc/kubernetes/admin.conf ~/.kube/config

如果之前是软连接,证书更新以后就不需要操作,自动更新了

7.看下命令是否可以使用

 

ubuntu@ip-172-31-25-85:~$ sudo kubectl get pods
NAME                       READY   STATUS    RESTARTS   AGE
account-67bbddfb47-prqwv   1/1     Running   0          179d
account-67bbddfb47-rsm8z   1/1     Running   0          179d
course-84ffd55765-4gzxv    1/1     Running   0          63d
course-84ffd55765-qxlns    1/1     Running   0          63d
device-84b5b655dd-nqtgv    1/1     Running   0          31d
device-84b5b655dd-p4565    1/1     Running   0          31d
dnsutils                   1/1     Running   3246       368d
file-685bf77b74-5rg9d      1/1     Running   0          179d
file-685bf77b74-66drt      1/1     Running   0          179d
gateway-5595fd66cc-5m5h6   1/1     Running   0          4d8h

 

至此证书更新完成。

标签:daemon,kube,证书,1.18,etcd,Error,such,k8s,response
From: https://www.cnblogs.com/zhanchenjin/p/16708540.html

相关文章

  • k8s系列学习
    一、k8s介绍  一个k8s集群有master和node节点组成,每个节点需要安装对应的组件master节点:ApiServer:资源操作的唯一入口,接收用户输入的命令,提供认证、授权、API注......
  • Dapr 证书过期了怎么办? 别慌,有救!
    一、背景Dapr默认证书有效时间是1年,证书过期后就不能执行相关控制面和数据面的交互了,如下图:二、查看证书有效时间通过daprmtlsexpiry看到期时间,具体参见命令https://v1......
  • 3.搭建K8S集群
    一,平台规划1.单master集群2.多master集群 ......
  • k8s给pod添加hosts
    ###1.背景线上待办功能一直不通,发现正式环境的待办系统域名无法访问,需要配置hosts。因为应用部署在云上,需使用k8s给pod添加域名IP映射。2.实战过程使用yaml方式创......
  • SSL证书过期怎么办?别慌!SSL应急解决方案及注意事项来了
    当浏览器飘红显示网站不安全才发现网站SSL证书已过期,而此时又联系不上之前的SSL供应商,一时不知道该如何是好?幸好有前辈给予指导让快速解决SSL证书过期问题。特此分享出来,供......
  • C# 为exe程序添加自签名证书
    1.使用管理员打开PowerShell2.输入命令New-SelfSignedCertificate-TypeCustom-Subject"CN=发行者,O=公司名称,C=CN,L=省,S=市"-KeyUsageDigitalSignature-Fr......
  • k8s service
    目录k8sserviceService作用为什么要引入ServiceService需要注意的点Service的作用和原理k8sserviceService作用Service的核心作用就是为Pod提供稳定的网络连接。除此......
  • k8s集群安装(kubeadm方式)
    一、准备三台虚拟机,系统CentOS7.9;192.168.1.221  k8s-master01192.168.1.189  k8s-node01192.168.1.60  k8s-node02二、.对三台虚拟机......
  • 二进制部署k8s --containerd 之基本环境
    一,首先配置hosts文件   k8s-master-01192.168.56.101#master节点k8s-master-02192.168.56.102#master节点k8s-master-03192.168.56.106#master节点k8......
  • [转载] 证书,证书链,CA的那些事
      RingCentralTech丨证书,证书链,CA的那些事 公开密钥算法HTTP是什么为什么HTTPS比较安全证明张三是张三神一样的CA证书证书验证过程,CA证书,证书链.........