侧边栏壁纸
  • 累计撰写 61 篇文章
  • 累计创建 3 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

Kubernetes集群证书更新脚本

运维匠
2024-07-11 / 0 评论 / 0 点赞 / 36 阅读 / 1842 字
温馨提示:
本文最后更新于 2024-07-11,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

Kubernetes集群证书更新脚本

前提:

  • 集群是kubeadm部署
  • 证书到期前更新
#!/bin/bash

echo "## Expiration before renewal ##"
/usr/bin/kubeadm certs check-expiration

echo "## Renewing certificates managed by kubeadm ##"
/usr/bin/kubeadm certs renew all

echo "## Restarting control plane pods managed by kubeadm ##"
/usr/bin/crictl pods --namespace kube-system --name 'kube-scheduler-*|kube-controller-manager-*|kube-apiserver-*|etcd-*' -q | /usr/bin/xargs /usr/bin/crictl rmp -f

echo "## Updating /root/.kube/config ##"
cp /etc/kubernetes/admin.conf /root/.kube/config

echo "## Waiting for apiserver to be up again ##"
until printf "" 2>>/dev/null >>/dev/tcp/127.0.0.1/6443; do sleep 1; done

echo "## Expiration after renewal ##"
/usr/bin/kubeadm certs check-expiration
0

评论区