Created
May 20, 2023 09:54
-
-
Save xhoong/e6255e687f3ea54b240da296b019cb31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Reference: https://raynix.info/archives/4296 | |
# in the master node, run as root | |
kubeadm certs renew all | |
[renew] Reading configuration from the cluster... | |
[renew] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml' | |
[renew] Error reading configuration from the Cluster. Falling back to default configuration | |
certificate embedded in the kubeconfig file for the admin to use and for kubeadm itself renewed | |
... | |
Done renewing certificates. You must restart the kube-apiserver, kube-controller-manager, kube-scheduler and etcd, so that they can use the new certificates. | |
# it's easier to restart the kubelet service which runs those static pods | |
systemctl restart kubelet.service | |
... | |
# copy the updated kubeconfig from the master node | |
ssh ubuntu@kmaster -- sudo cat /etc/kubernetes/admin.conf > /tmp/admin.conf | |
# delete current cluster, user, context from local kubeconfig | |
# by default, the kubeadm cluster is named kubernetes | |
k config delete-context kubernetes | |
k config delete-cluster kubernetes | |
k config delete-user kubernetes-admin | |
# merge the new admin.conf with current kubeconfig | |
KUBECONFIG=~/.kube/config:/tmp/admin.conf k config view --flatten > /tmp/config | |
# test the new kubeconfig | |
k --kubeconfig=/tmp/config get nodes | |
NAME STATUS ROLES AGE VERSION | |
kmaster1 Ready control-plane,master 376d v1.21.0 | |
... | |
# replace the current kubeconfig | |
mv /tmp/config ~/.kube/config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment