kubeadm安装集群系列-4.证书更新
证书更新
- 默认证书一年有效期
- 一旦证书过期,使用kubectl时会出现如下提示:`Unable to connect to the server: x509: certificate has expired or is not yet valid`
查看证书过期情况
[root@k8s-test-master- ~]# kubeadm alpha certs check-expiration
CERTIFICATE EXPIRES RESIDUAL TIME EXTERNALLY MANAGED
admin.conf Jul , : UTC 364d no
apiserver Jul , : UTC 364d no
apiserver-etcd-client Jul , : UTC 364d no
apiserver-kubelet-client Jul , : UTC 364d no
controller-manager.conf Jul , : UTC 364d no
etcd-healthcheck-client Jul , : UTC 364d no
etcd-peer Jul , : UTC 364d no
etcd-server Jul , : UTC 364d no
front-proxy-client Jul , : UTC 364d no
scheduler.conf Jul , : UTC 364d no # 查看根CA证书的有效期(十年)
[root@k8s-test-master- pki]# cd /etc/kubernetes/pki
[root@k8s-test-master- pki]# ls | grep ca.crt | xargs -I {} openssl x509 -text -in {} | grep "Not After"
Not After : Jul :: GMT
Not After : Jul :: GMT
证书目录结构
[root@k8s-test-master- pki]# pwd
/etc/kubernetes/pki
[root@k8s-test-master- pki]# tree .
.
├── apiserver.crt
├── apiserver-etcd-client.crt
├── apiserver-etcd-client.key
├── apiserver.key
├── apiserver-kubelet-client.crt
├── apiserver-kubelet-client.key
├── ca.crt
├── ca.key
├── etcd
│ ├── ca.crt
│ ├── ca.key
│ ├── healthcheck-client.crt
│ ├── healthcheck-client.key
│ ├── peer.crt
│ ├── peer.key
│ ├── server.crt
│ └── server.key
├── front-proxy-ca.crt
├── front-proxy-ca.key
├── front-proxy-client.crt
├── front-proxy-client.key
├── sa.key
└── sa.pub directory, files
Kubernetes 集群根证书
/etc/kubernetes/pki/ca.crt
/etc/kubernetes/pki/ca.key
- 1,kube-apiserver 组件持有的服务端证书
- 2,kubelet 组件持有的客户端证书
汇聚层(aggregator)证书
- 1,代理端使用的客户端证书, 用作代用户与 kube-apiserver 认证
etcd 集群根证书
- 1,etcd server 持有的服务端证书
- 2,peer 集群中节点互相通信使用的客户端证书
- 3,pod 中定义 Liveness 探针使用的客户端证书
- 4,配置在 kube-apiserver 中用来与 etcd server 做双向认证的客户端证书
Serveice Account秘钥
更新证书
生成集群配置的yaml文件
kubeadm config view > /root/kubeadm.yaml
- kubeadm.yaml
apiServer:
extraArgs:
authorization-mode: Node,RBAC
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta2
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes-test
controlPlaneEndpoint: 10.8.28.200:6443
controllerManager: {}
dns:
type: CoreDNS
etcd:
local:
dataDir: /data/etcd
imageRepository: k8s.gcr.io
kind: ClusterConfiguration
kubernetesVersion: v1.15.1
networking:
dnsDomain: cluster.local
podSubnet: 192.168.0.0/16
serviceSubnet: 10.96.0.0/12
scheduler: {}
证书更新使用帮助
[root@k8s-test-master- ~]# kubeadm alpha certs renew --help
This command is not meant to be run on its own. See list of available subcommands. Usage:
kubeadm alpha certs renew [flags]
kubeadm alpha certs renew [command] Available Commands:
admin.conf Renew the certificate embedded in the kubeconfig file for the admin to use and for kubeadm itself
all Renew all available certificates
apiserver Renew the certificate for serving the Kubernetes API
apiserver-etcd-client Renew the certificate the apiserver uses to access etcd
apiserver-kubelet-client Renew the certificate for the API server to connect to kubelet
controller-manager.conf Renew the certificate embedded in the kubeconfig file for the controller manager to use
etcd-healthcheck-client Renew the certificate for liveness probes to healtcheck etcd
etcd-peer Renew the certificate for etcd nodes to communicate with each other
etcd-server Renew the certificate for serving etcd
front-proxy-client Renew the certificate for the front proxy client
scheduler.conf Renew the certificate embedded in the kubeconfig file for the scheduler manager to use
更新证书操作
kubeadm alpha certs renew all --config=/root/kubeadm.yaml
# (也可以逐个更新)
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 healtcheck 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
# 再次查询证书期限
[root@k8s-test-master- ~]# kubeadm alpha certs check-expiration
CERTIFICATE EXPIRES RESIDUAL TIME EXTERNALLY MANAGED
admin.conf Jul , : UTC 364d no
apiserver Jul , : UTC 364d no
apiserver-etcd-client Jul , : UTC 364d no
apiserver-kubelet-client Jul , : UTC 364d no
controller-manager.conf Jul , : UTC 364d no
etcd-healthcheck-client Jul , : UTC 364d no
etcd-peer Jul , : UTC 364d no
etcd-server Jul , : UTC 364d no
front-proxy-client Jul , : UTC 364d no
scheduler.conf Jul , : UTC 364d no # 在三台Master上执行重启kube-apiserver,kube-controller,kube-scheduler,etcd这4个容器,使证书生效
docker ps |grep -E 'k8s_kube-apiserver|k8s_kube-controller-manager|k8s_kube-scheduler|k8s_etcd_etcd' | awk -F ' ' '{print $1}' |xargs docker restart
kubeadm安装集群系列-4.证书更新的更多相关文章
- kubeadm安装集群系列(kubeadm 1.15.1)
kubeadm已经进入GA阶段,所以尝试使用kubeadm从零开始安装高可用的Kubernetes集群,并记录下过程和所有坑 本文基于kubeadm 1.15.1 目录 kubeadm安装集群系列-1 ...
- kubeadm安装集群系列-2.Master高可用
Master高可用安装 VIP负载均衡可以使用haproxy+keepalive实现,云上用户可以使用对应的ULB实现 准备kubeadm-init.yaml文件 apiVersion: kubead ...
- kubeadm安装集群系列-3.添加工作节点
添加工作节点 worker通过kubeadm join加入集群,加入所需的集群的token默认24小时过期 查看Token kubeadm token list # 如果失效创建一个新的 kubead ...
- kubeadm安装集群系列-1.基础服务安装
基础服务 本文基于centos7.5部署 规划 10.8.28.200 master-VIP 10.8.31.84 k8s-test-master-1 10.8.152.149 k8s-test-ma ...
- kubeadm安装集群系列-5.其他操作
常用的一些操作记录 imagePullSecrets kubectl -n [namespace] create secret docker-registry regsecret --docker-s ...
- Kubeadm安装的K8S集群1年证书过期问题的解决思路
这个问题,很多使用使用kubeadm的用户都会遇到. 网上也有类似的帖子,从源代码编译这种思路, 在生产环境,有些不现实. 还是使用kubeadm的命令操作,比较自然一点. 当然,自行生成一套证书,也 ...
- mycat数据库集群系列之数据库多实例安装
mycat数据库集群系列之数据库多实例安装 最近在梳理数据库集群的相关操作,现在花点时间整理一下关于mysql数据库集群的操作总结,恰好你又在看这一块,供一份参考.本次系列终结大概包括以下内容:多数据 ...
- Kubernetes学习之路(八)之Kubeadm部署集群
一.环境说明 节点名称 ip地址 部署说明 Pod 网段 Service网段 系统说明 k8s-master 192.168.56.11 docker.kubeadm.kubectl.kubelet ...
- Kubernetes 使用kubeadm创建集群
镜像下载.域名解析.时间同步请点击 阿里巴巴开源镜像站 实践环境 CentOS-7-x86_64-DVD-1810 Docker 19.03.9 Kubernetes version: v1.20.5 ...
随机推荐
- 记一次 解决 vue 兼容ie11 的问题
vue2.0 最近项目需要做到兼容ie11,找问题找半天,于是各种百度, 发现引入 babel-polyfill 还是有问题 空白页面 参考它的配置 ( 最后一句代码为引入的资源路径 ) 我跟他差 ...
- css居然有根据容器宽度自动截取长度加省略号功能,强大!!
作者:☆威廉古堡♂ 项目中最初的做法(js截取): //字符长度截取包括中英文混合 function subStr(str, len) { str = str.toString(); var newL ...
- laravel 服务容器的用法
建立一个服务 <?php namespace App\Services; class FooService { public function __construct(){ } public f ...
- IDEA Java
目录 1 配置 2 常用快捷键 3 安装插件 4 使用Maven创建web项目 5 使用Maven导入依赖 6 Maven创建项目后缺少文件夹 7 Tomcat LocalHost Log消失 8 E ...
- 树莓派安装QT(全部库包括)
在网上现有的资料中大部分只有前两个命令,少量有三个命令,因此写下该博客 在树莓派上安装QT5的全部库,包括QtQuick.QtMultimedia库. sudo apt-get install qt5 ...
- 理清gcc、libc、libstdc++的关系
当你在linux下写C/C++代码的时候,是不是会遇到许多编译链接的问题? 时不时报个glibc,gcc,g++等相关的错误? 很多时候都无从下手,而且比较混乱. 这也是编译链接过程中经常出现的问题. ...
- MySQL之pymysql
pymysql的安装 pip install PyMySQL 连接数据库 import pymysql db = pymysql.connect("数据库ip","用 ...
- Kettle环境的安装
Kettle是绿色免安装的,下载完解压之后找到Spoon.bat,直接执行就好 欢迎界面 Kettle主要分为转换和作业2类 新建一个转换demo 创建了一个转换demo后,由于是数据抽取,因此我们抽 ...
- C/C++程序基础-C++与C有什么不同
1:C和C++的联系和区别? 答:C是一个结构化语言,它的重点在于算法和数据结构.对于语言本身而言,C是C++的子集.C程序的设计首先要考虑的是如何通过一个过程,对输入进行运算处理,得到输出.对于C+ ...
- JS基础_垃圾回收(GC)
垃圾回收(GC) 程序运行过程中也会产生垃圾,这些垃圾积攒过多以后,会导致程序运行的速度过慢,所以我门需要一个垃圾回收的机制,来处理程序运行过程中产生的垃圾 当一个对象没有任何的变量或属性对它进行引用 ...