kubernetes 初始化集群 证书100年操作 【kubeadm】

1、下载源码

[root@SPHQBKCEK8SMS01 ~]# git clone https://github.com/kubernetes/kubernetes
# 切换到自己的版本,修改源码,比如我的是v1.20.15版本
[root@SPHQBKCEK8SMS01 kubernetes]# cd kubernetes/
[root@SPHQBKCEK8SMS01 kubernetes]# git checkout v1.20.15
[root@SPHQBKCEK8SMS01 kubernetes]# git checkout -b v1.20.15

2、修改并编译并应用

[root@SPHQBKCEK8SMS01 kubernetes]# vim cmd/kubeadm/app/constants/constants.go 找到CertificateValidity,修改如下
# 大概在50行
// CertificateValidity defines the validity for all the signed certificates generated by kubeadm
CertificateValidity = time.Hour * 24 * 365 * 100

# 这里需要安装Go的1.17.X或更高的版本
# 编译kubeadm

[root@SPHQBKCEK8SMS01 kubernetes-1.20.15]# yum install go -y
[root@SPHQBKCEK8SMS01 kubernetes-1.20.15]# make WHAT=cmd/kubeadm/
[root@SPHQBKCEK8SMS01 kubernetes-1.20.15]# ll _output/bin/
total 75984
-rwxr-xr-x 1 root root  6217728 Oct 12 11:24 conversion-gen
-rwxr-xr-x 1 root root  5914624 Oct 12 11:24 deepcopy-gen
-rwxr-xr-x 1 root root  5939200 Oct 12 11:24 defaulter-gen
-rwxr-xr-x 1 root root  3580283 Oct 12 11:24 go2make
-rwxr-xr-x 1 root root  1818624 Oct 12 11:24 go-bindata
-rwxr-xr-x 1 root root 37864120 Oct 12 11:25 kubeadm
-rwxr-xr-x 1 root root 10575608 Oct 12 11:24 openapi-gen
-rwxr-xr-x 1 root root  5890048 Oct 12 11:24 prerelease-lifecycle-gen
[root@SPHQBKCEK8SMS01 kubernetes-1.20.15]# which kubeadm
/usr/bin/kubeadm
[root@SPHQBKCEK8SMS01 kubernetes-1.20.15]#  cp /usr/bin/kubeadm{,.bak}
[root@SPHQBKCEK8SMS01 kubernetes-1.20.15]# cp _output/bin/kubeadm /usr/bin/kubeadm
cp: overwrite ‘/usr/bin/kubeadm’? y

posted @ 2024-10-12 11:28  烟雨浮华  阅读(20)  评论(0编辑  收藏  举报