Projects, Software

CoreOS - Dynamic Cloud-init

I've been playing with CoreOS for a few weeks, using the VMWare hypervisor. Luckily there is documentation to simplify setup.

However this method got repetitive when it came to building config-drive. Especially when you have multiple nodes.

Config-drive

The concise instructions to building the config-drive.

When adding user_data script, remember to change the network adapter (enp0s33) if current release uses something different.

Generating cloud config

You will also need to update the url for where you will be storing the cloud-init config: http://192.168.0.2/config/web-backend/${MAC}
This could be as simple as a static file, or database driven dynamically generated for cluster management.

I've gone for a Symfony controller and a twig template.

Conclusion

This has been working well for me since I implemented it a few months ago and I'm surprised no one else seems to be mentioning it. You can dynamically build your cluster, as long as one node remains to keep the etcd token alive. This should be enough the all new nodes get the fleet config. Best of all, if I change the my cloud-config, you don't need rebuild config-drive every time you make a change. However you need to be aware if CoreOS change the interface name. At the moment the variables are hardcoded into my controller, because there is only 3 nodes. You can extend this by moving the config into a file, or a database. If you store the settings in a database then you could start to create nodes on the fly. This is why my url includes a node type (web-node). Once this the machine is booted, you would need to manually add the above services to fleet, but more on this in another post.

Tags: CoreOS, Cloud-init

comments powered by Disqus