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.
Note: 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 herehttps://github.com/elik1001/coreos-kubernetes-generator/tree/master/examples 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 code I am referencing is hosted on GitHub and can be accessed here. The repository includes the Python Kubernetes generator script, as well as pre configured samples.
- 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.
Dependencies / PrerequisitesThe following libraries are required: Note: The script will (try to) download and install the required libraries (if needed).
sys, os, pip, re, ast, pwd, uuid, crypt, shutil, pprint, getpass, requests, subprocess, inquirer, from contextlib import contextmanager Crypto.PublicKey.RSANote: You can also manually install the required libraries by running pip install [library]
Usage examplesTo 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|
./generate_template.py [..] snip [?] What kubernetes system type are you building ?: Master > Master Worker [..] snip 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
DetailsThe 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 DetailsYou 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.ignReplace 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.
Like what you’re reading? please provide feedback, any feedback is appreciated.