I have been able to create a Kubernetes cluster on CoreOS using Calico following this guide.
As documented in the guide, Calico creates a default subnet 192.168.0.0/16. Once the services start, I can redefine the subnet by running the following commands:
$ export ETCD_AUTHORITY=127.0.0.1:6666
$ calicoctl pool remove 192.168.0.0/16
$ calicoctl pool add 10.244.0.0/16 --nat-outgoing
All work nicely. However, I would like to automate the above using cloud-config. I've tried using a OneShot service to execute the commands but it only worked partially. The new subnet 10.244.0.0/16 was added but 192.168.0.0/16 was not removed. The error was:
calicoctl[1330]: 192.168.0.0/16 is not a configured pool.
I guess that was because the default subnet was not yet created when the pool remove
command executed.
So my questions are:
pool remove
on the default subnet?A bit late to the party here, but...
With recent releases of Calico this is easier to automate. The calico/node
container will attempt to create the 192.168.0.0/16
pool by default. If you'd like to use a different pool you can do the following:
Before running the calico/node
container, create the pool you'd like to use.
Start the calico/node
container with NO_DEFAULT_POOLS=true environment variable. This stops the container from creating the default pool. (https://github.com/projectcalico/calico-containers/blob/master/calico_node/filesystem/startup.py#L259)
Using cloud-init / systemd, I'd do something like this:
[Service]
Environment=ETCD_AUTHORITY=$private_ipv4:2379
Environment=NO_DEFAULT_POOLS=true
ExecStartPre=/opt/bin/calicoctl pool add <your ipv4 pool> --nat-outgoing
ExecStartPre=/opt/bin/calicoctl pool add <your ipv6 pool>
ExecStart=/opt/bin/calicoctl node --ip=$private_ipv4 --detach=false
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target