Script for initializing a cluster automatically

Hello guys.

I’m trying to make a script for creating a custom cluster automatically.

This is the project’s Github page: (is based on the script by superseb, just tried to improve it a little bit, and add some automatic stuff for using with Ansible).

It works at arround a 99%, the only issue I’m having is when trying to get the “nodeCommand” from the API to get the command to add nodes.

This is the code I’m getting:

sudo docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.1.6 --server --token XXXXXXXXX

As you can see, there’s nothing for the “–server” parameter.

But, when I go to Rancher’s GUI, settings and advanced settings, the server URL is set right, and the value is perfect.

Also, when accesing to the endpoint “” the value is correct.

This is how the script try to get the nodeCommand:

curl -s '' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" --data-binary '{"type":"clusterRegistrationToken","clusterId":"'$CLUSTERID'"}' --insecure

Is a minor issue, as I can just add it by hand, but it would be awesome for having it at 100%.

Obviously, anyone who wants to use/improve it, is welcome.

Best regards.

1 Like

i wonder if anyone was able to figureout this part.

This has been used for a long time without issue, see for an example. Let me know if you still run into issues when using this.