Deploying Kubernetes with the Scaleway CLI

Following my Using kubeadm to deploy Kubernetes to Scaleway post, I wanted to be able to create a script to aid the Kubernetes cluster creation.

Scaleway provide a CLI tool to interact with their service called scw, and the latest stable version is installable with a quick brew install scw to which is nice and handy.

Once scw was installed I authenticated with Scaleway by running scw login and supplying my control panel credentials.

I’ve posted the script I ended up with below, but I’ll give you a quick run through of it.

To create the servers I ran the scw create --bootscript="8fd15f37" --name="<name>" --commercial-type="VC1S" Ubuntu_Xenial command. You’ll notice the --bootscript option which allowed me to specify which bootscript to use when provisioning the instance, I obtained the correct bootscript identifier by running scw images -f type=bootscript and finding the x86_64 4.10.8 script - if you had read the previously mentioned post you would’ve have seen why this was important.

It would’ve been nice if I could use the tag functionality provided by the control panel UI to address/filter instances, but this doesn’t appear to be supported in an intuitive way with the CLI so I used the --name option as a surrogate.

Once the servers were created they needed to be started, to do this I ran scw start --wait <identifier> against each of the servers.

To prepare the servers I used the scw exec <identifier> <command> command to update and install the required packages. Once those were prepared I configured the Kubernetes master using kubeadm , and obtained a join token to use on the nodes - the token create --print-join-command functionality was introduced in 1.9 and it’s very handy.

Strangely, when I tried to use the output of scw exec -w "$master" 'kubeadm token create --print-join-command' directly I get an error from kubeadm on the node stating couldn't validate the identity of the API Server: encoding/hex: odd length hex string . After piping the content into xxd , I noticed that the string ended in an \r

pair so I removed this with tr .

I need to investigate whether this was expected functionality or introduced by accident in either scw or kubeadm .

Finally, to destroy the cluster, I issued the scw stop -t <identifier> command which terminated the server and destroys attached resources.