Kubernetes CoreOS Ignition Configuration Generator Written in Python.
In the previous post I went through how to Configuring Kubernetes Træfik Ingress Controller, DNS, Dashboard. below are examples to use a small Python script I have written to automate most of the Kubernetes deployment process.
Get going in minutes with a full Kubernetes cluster by using the free Kubernetes generator on my GitHub repository.
Version 0.7 just became available of the Kubernetes generator, supporting kubernetes version v.1.13.x+, RBAC, Auto Bootstraping, and more.
You can generate your own configuration in minutes by using the generator, available on my GitHub repository by going here, you can also just use the ready examples files available here
I divided the configuration into parts outlined below.
- Part 1: Initial setup – getting CoreOS, prepare SSL certificates, etc.
- Part 2: Configure Etcd key value store, Configure Flannel.
- Part 3: Configure Kubernetes manifests for controller, api, scheduler and proxy.
- Part 4: Finalize the kubelet configuration to use RKT and Flannel+CNI.
- Part 5: Optional – configure Ingress, kube-dns and kube-dashboard.
- Part 6: Automate the Kubernetes deployment, etcd, kubelet, rkt, flannel, cni and ssl.
This is part 6 – Automate the Kubernetes deployment.
This document provides instructions on how to install and use the Python Kubernetes Generator Script. the script helps automate a Kubernetes deployment on CoreOS. See the deployment notes for additional details.
- The script helps automate a Kubernetes Multi-Master deployment on CoreOS.
- The script generates a CoreOS Ignition file that can be used, either as part of a 3 node Master cluster or just as a worker node.
- The generated Ignition file includes all required properties for, Etcd, Flannel(with CNI), Kubelet using (Rkt), etc.. all protocols are configured to use SSL.
The script uses a wizard-like approach with a minimum set of questions, just to be able to generate a configuration.
Dependencies / Prerequisites
The following libraries are required:
Note: The script will (try to) download and install the required libraries (if needed).
from contextlib import contextmanager
Note: You can also manually install the required libraries by running pip install [library]
To use the application just run the ./generate_template.py.
You can leave most of the default values by just hitting enter – (replace the IP Address, Hostnames, etc.. if you like..).
The default pre-set Hostname and IP Adress are below
|CoreOS Cluster IP Address|
Tip: Re-run the script for every Master, worker, etc.. each run will generate a new configuration file that you can use.
[?] What kubernetes system type are you building ?: Master
Ignition Template created successfully.
SSH private key is : keys/id_rsa
SSH public key is : keys/id_rsa.pub
SSL certificates are in : ./ssl/
Build Template file is : configs/coreos1_template.yaml
Ignition Template file is : configs/coreos1_template.ign
Ignition Template ISO file is : configs/coreos1_template.iso
The script generates the below list of files and Directories.
- ssl: Contains all SSL certificates used in the configuration including the CA certificate
- manifests: Contains all the manifests used to generate the Ignition
- keys: Contains the SSH Private and Public keys in the configuration
- configs: Contains the final configuration files, like. Ignition (mastr[n].ign), ISO with Ignition data on it(master[n].iso) and the YAML config(master[n].yaml).
- tmp: Contains all temporary configuration files.
- src: Contains the default Kubernetes properties, these files get updated at run time, based on your selections set as the default properties(for the next run).
- template: Contains all templates or ready sample templates used in the configuration.
Additional Usage Details
You can use the ign (or ISO with ign file) in a verity of ways.
If you are using bear-metal or virtual box, an example is explained below.
Boot from a CoreOS ISO/CD/USB which already contains the coreos-install script, or use any bootable CD, then download the CoreOS coreos-install script from here.
Next, use the generated Ignition file, you can use the IGN file, or use the ISO which contains the IGN file, the process is the same (like the below).
Now, run the coreos-install with the below parameters.
Note: the coreos-install script comes pre-installed on CoreOS.
coreos-install -d /dev/[sda] -C [stable|alpha] -i master1_template.ign
Replace sda with your disk.
Use alpha or stable channel.
Once completed just reboot the server (or virtual) and you should be good to go.
- Convert SSL subprocess to pure Python code.
- Convert configuration files (in src directory) to a DB layer.
- Add include matchbox, PXE, DHCP, as an option for full automation.
- Add a Web-UI interface to manipulate properties.
You can download all necessary files from the GitHub project page available here..
You might also like – Other articles related to Docker Kubernetes / micro-service.
Like what you’re reading? please provide feedback, any feedback is appreciated.