Hello guys.
I’m trying to make a script for creating a custom cluster automatically.
This is the project’s Github page: https://github.com/ggMartinez/rancher_cluster_init (is based on the script rancher2customnodecmd.sh 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 “https://127.0.0.1/v3/settings/server-url” the value is correct.
This is how the script try to get the nodeCommand:
curl -s 'https://127.0.0.1/v3/clusterregistrationtoken' -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.