(1 votes, average: 1.00 out of 5)
Loading...
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 here
https://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.
Getting Started
Installation
Dependencies / Prerequisites
The 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 examples
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 belowCoreOS Cluster IP Address | |
---|---|
Name | IP Addrss |
coreos1 | 10.0.2.11/20 |
coreos2 | 10.0.2.12/20 |
coreos3 | 10.0.2.13/20 |
./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
Details
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.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.
To Do’s
- 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.
0
0
votes
Article Rating
Hi Eli,
I can not get this ignition file to work with the latest version of coreos 1729.0.0 Rhyolite.
Network is ok, but flannel is not working.
Using the traspiler yaml to json i got this error:
warning at line 1136, column 19
flannel minor version too new. Only options available in the previous minor version will be supported
this line contained:
version: 0.9.0
really sorry for the late response, I had a serious issue and many comments ware marked as SPAM. Thank you for pointing this out, I am sorry this is not working for you, please try one of the below solutions. I hope to updated the Github code to a more recent versions soon. Option 1 Update the code with the latest ct URL, by replacing line 22 in generate_template.py or if using generate_template-python_2_only.py replace line 20, with the below. # From ct_url = 'https://github.com/coreos/container-linux-config-transpiler/releases/download/v0.5.0/ct-v0.5.0-x86_64-unknown-linux-gnu' # To ct_url = 'https://github.com/coreos/container-linux-config-transpiler/releases/download/v0.9.0/ct-v0.9.0-x86_64-unknown-linux-gnu' Option 2 Download the latest ct utility by following the below… Read more »