拉取kubernetes的源码:
git clone https://github.com/kubernetes/kubernetes.git
切换版本:
cd kubernetes && git checkout -b remotes/origin/release-1.13 v1.13.0
安装Go环境:
wget https://dl.google.com/go/go1.11.2.linux-amd64.tar.gz
tar zxvf go1.11.2.linux-amd64.tar.gz -C /usr/local #编辑/etc/profile文件添加如下:
#go setting
export GOROOT=/usr/local/go
export GOPATH=/usr/local/gopath
export PATH=$PATH:$GOROOT/bin source /etc/profile 生效 验证:
go version
go version go1.11.2 linux/amd64
修改源码:
cd /kubernetes/staging/src/k8s.io/client-go/util/cert/cert.go
#编辑 cert.go文件
maxAge := time.Hour * 24 * 365 #修改前
NotAfter: time.Now().Add(duration365d).UTC()
maxAge := time.Hour * 24 * 365 * 50 #修改后 给证书期限为50年
NotAfter: time.Now().Add(duration365d * 50).UTC()
编译Go:
cd /kubernetes/ && make WHAT=cmd/kubeadm
查看编译后的文件
ls -l /data/kubernetes/_output/bin/kubeadm
替换kubeadm
mv /usr/bin/kubeadm /usr/bin/kubeadm_backup
ln -s /data/kubernetes/_output/bin/kubeadm /usr/bin/kubeadm
重新初始化集群并查看证书
cd /etc/kubernetes/pki
openssl x509 -in front-proxy-client.crt -noout -text |grep Not