https://rancher.com/ logo
#k3s
Title
h

hundreds-state-15112

06/30/2022, 10:15 PM
Hey y’all hopefully quick question. I’m trying to automate the installation of a k3s Rancher Server cluster with Ansible and have questions about the embedded etcd init functionality (thread)
I’m currently trying to understand how the
--cluster-init
flag functions and how idempotent it is to rerun on the same set of nodes. Is it a noop if a cluster has already been initialized?
Best case it’s idempotent and doesn’t do anything if a cluster has already been initialized, but it would also need to be idempotent successive runs and changes in cluster membership on different hosts, otherwise I have to manage things with a kind of “cluster_init_node” variable
I’d also assume that if the init has been done on server 1 and server 2 has successfully joined, then server 3 could join by pointing at server 1 or 2?
I’m in the process of testing all these to make sure I understand potential failure scenarios but if someone could short circuit this or let me know there’s an easier way let me know
“oops someone ran cluster init accidentally on our production k3s rancher server cluster”
c

creamy-pencil-82913

06/30/2022, 10:41 PM
the datastore arguments are ignored if an etcd datastore is found on disk. this include --cluster-init, --datastore-endpoint, and so on
so yeah, once a etcd database has been initialized on a node, the --cluster-init argument is not needed. Technically neither is the --server argument on the other servers.
and yes, you can join a new node by pointing at any existing server
h

hundreds-state-15112

06/30/2022, 10:43 PM
Awesome! Thank you for saving us from ourselves haha. Also appreciate all the work you do on the k3s project! I feel like I’m talking to a celebrity
Might have some followups after later testing, appreciate it
I threw together a PR for the docs here based on your comments
c

creamy-pencil-82913

07/01/2022, 1:05 AM
Thanks for the PR!
👍 1
2 Views