Created
August 8, 2021 20:17
-
-
Save ericbisme/8bb09be3537d669d6ef34e784c90ad22 to your computer and use it in GitHub Desktop.
k3s/k3os Remove Master Node from embedded ETCD
This file contains hidden or 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
| https://github.com/k3s-io/k3s/issues/2732#issuecomment-749181797 | |
| Run pod with etcdctl: | |
| kubectl run --rm --tty --stdin --image docker.io/bitnami/etcd:latest etcdctl --overrides='{"apiVersion":"v1","kind":"Pod","spec":{"hostNetwork":true,"restartPolicy":"Never","securityContext":{"runAsUser":0,"runAsGroup":0},"containers":[{"command":["/bin/bash"],"image":"docker.io/bitnami/etcd:latest","name":"etcdctl","stdin":true,"stdinOnce":true,"tty":true,"volumeMounts":[{"mountPath":"/var/lib/rancher","name":"var-lib-rancher"}]}],"volumes":[{"name":"var-lib-rancher","hostPath":{"path":"/var/lib/rancher","type":"Directory"}}]}}' | |
| Remove member (must use hex ID): | |
| ./bin/etcdctl --key /var/lib/rancher/k3s/server/tls/etcd/client.key --cert /var/lib/rancher/k3s/server/tls/etcd/client.crt --cacert /var/lib/rancher/k3s/server/tls/etcd/server-ca.crt member remove 327051268c526155 | |
| List Members: | |
| ./bin/etcdctl --key /var/lib/rancher/k3s/server/tls/etcd/client.key --cert /var/lib/rancher/k3s/server/tls/etcd/client.crt --cacert /var/lib/rancher/k3s/server/tls/etcd/server-ca.crt member list |
This is still very helpful!
Since bitnami deprecated its images the command for spawning the pod needs a little adjustment. Additionally if your control plane has taints, you might need to add a toleration for that:
kubectl run --rm --tty --stdin --image docker.io/bitnamilegacy/etcd:latest etcdctl --overrides='{"apiVersion":"v1","kind":"Pod","spec":{"hostNetwork":true,"restartPolicy":"Never","securityContext":{"runAsUser":0,"runAsGroup":0},"containers":[{"command":["/bin/bash"],"image":"docker.io/bitnamilegacy/etcd:latest","name":"etcdctl","stdin":true,"stdinOnce":true,"tty":true,"volumeMounts":[{"mountPath":"/var/lib/rancher","name":"var-lib-rancher"}]}],"volumes":[{"name":"var-lib-rancher","hostPath":{"path":"/var/lib/rancher","type":"Directory"}}], "tolerations":[{"key":"node-role.kubernetes.io/control-plane"}] }}'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Appreciate it. This popped up on a Google search and helped me restore one of my clusters.