2021-03-23 02:22:48 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
echo "## Expiration before renewal ##"
|
2021-03-31 15:00:58 +08:00
|
|
|
{{ bin_dir }}/kubeadm {{ 'alpha ' if kube_version is version('v1.20.0', '<') else '' }}certs check-expiration
|
2021-03-23 02:22:48 +08:00
|
|
|
|
|
|
|
echo "## Renewing certificates managed by kubeadm ##"
|
2021-03-31 15:00:58 +08:00
|
|
|
{{ bin_dir }}/kubeadm {{ 'alpha ' if kube_version is version('v1.20.0', '<') else '' }}certs renew all
|
2021-03-23 02:22:48 +08:00
|
|
|
|
|
|
|
echo "## Restarting control plane pods managed by kubeadm ##"
|
|
|
|
{% if container_manager == "docker" %}
|
2021-04-09 15:42:47 +08:00
|
|
|
{{ docker_bin_dir }}/docker ps -af 'name=k8s_POD_(kube-apiserver|kube-controller-manager|kube-scheduler|etcd)-*' -q | /usr/bin/xargs {{ docker_bin_dir }}/docker rm -f
|
2021-03-23 02:22:48 +08:00
|
|
|
{% else %}
|
|
|
|
{{ bin_dir }}/crictl pods --namespace kube-system --name 'kube-scheduler-*|kube-controller-manager-*|kube-apiserver-*|etcd-*' -q | /usr/bin/xargs {{ bin_dir }}/crictl rmp -f
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
echo "## Updating /root/.kube/config ##"
|
2021-09-21 15:36:22 +08:00
|
|
|
cp {{ kube_config_dir }}/admin.conf /root/.kube/config
|
2021-03-23 02:22:48 +08:00
|
|
|
|
|
|
|
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 ##"
|
2021-03-31 15:00:58 +08:00
|
|
|
{{ bin_dir }}/kubeadm {{ 'alpha ' if kube_version is version('v1.20.0', '<') else '' }}certs check-expiration
|