1、检查
检查ingress里的配置证书的过期时间
for i in $(kubectl get ingress -o yaml|grep secretName:|awk '{print $2}'|sort|uniq);do echo -n "$i - "; kubectl get secret $i -o "jsonpath={.data['tls\.crt']}" | base64 -d | openssl x509 -enddate -noout;done
检查所有创建的tls证书的过期时间
for i in $(kubectl get secret|awk '/tls/{print $1}');do echo -n "$i - "; kubectl get secret $i -o "jsonpath={.data['tls\.crt']}" | base64 -d | openssl x509 -enddate -noout;done
2、备份
找到临过期证书,先备份
kubectl get secret herlly-cn-https -o yaml >secret-herlly-cn-https.yaml
3、更换
kubectl create secret tls herlly-cn-https --save-config --dry-run=client --cert=/srv/salt/nginx/files/ssl/herlly/herlly.cn.crt --key=/srv/salt/nginx/files/ssl/herlly/herlly.cn.key -o yaml|kubectl apply -f -
4、验证
curl -v https://www.herlly.cn
5、回滚
验证有问题,先恢复旧证书,问题解决后,再重新执行替换操作,重新验证。
恢复旧证书
kubectl apply -f secret-herlly-cn-https.yaml