Generate dynamic number of manifest repetitions using minimum configuration
Project description
What is going on here ?
This is to solve a problem where it is required to dynamically vary/repeat the number of generated manifests for each of the otherwise quite similar dev, qa, staging, prod environments.
An environment is usually a set of workloads, e.g microservices, e.g antivirus, ocr and other components that are able to scale horizontally and service the complete environment. But what if we for a given environment want to also run a n-times repeated set of "customer installation" sets as well.
As an example, we might need to run N instances of a legacy application server (HelmRelease), so we want to define this helmrelease manifest just once, and then specify only the small configuration differences for each of needed instances.
This turns out to be an uneasy scenario to solve with Kustomize, because kustomizations is based on overlays that targets base manifests using specific (kind,namespace,name) coordinates, and for defining our N sets of "customer installations" we must vary the name part of the coordinates for each.
Managing a gitrepo for fluxd
The repo structure is for the initial empty state
└── releases
|—— .flux.yaml
└── environments
└── basetemplates
The releases folder is meant to be configured as the fluxcd --git-path=releases argument along with --manifest-generation=true
The environments directory is to be populated with subdirectories defining an instance of our workloads. Each subdirectory is to contain an editable copy of the root templates folder, and by editing these templates it will directly affect everything that is generator based on these templates.
The basetemplates folder is for base templates, editing these templates will only affect new instances, as nothing is directly generated from the base templates
Populating the basetemplates
The basetemplates are directories with sets of template files, e.g kubernetes yaml manifest files meant for jinja2 template processing
e.g.
└── basetemplates
└── SET1
|── template1.yaml
|── template2.yaml
└── SET2
|── template1.yaml
|── template2.yaml
Create a new workload configuration in the environments folder
An environment instance is expressed as subfolder in the environements folder, containing
- A snapshot copy of the basetemplates. E.g
cp -r basetemplates environments/NAME
- folder
generatorconfigs
with the.yaml
files withgeneratorconfig
manifests
└── environments
└── NAME
└── templates
└── SET1
|── template1.yaml
|── template2.yaml
└── SET2
|── template1.yaml
|── template2.yaml
└── generatorconfigs
|── SET1-a-generatorconfig.yaml
|── SET2-b-generatorconfig.yaml
|── SET2-c-generatorconfig.yaml
|── SET2-d-generatorconfig.yaml
The generatorconfig
format
The format is meant to be basically just properties, meaning pure configuration without much structure structure.
generatorconfigversion: 1
templateset: SET2
id: set2-a
import_substitution_parameters:
- set1
substitution_parameters:
NAME1: VALUE
NAME2: VALUE
overrides:
- manifest:
kind: MFKIND
namespace: MFNAMESPACE
name: MFNAME
values:
PATH: OVERRIDE
There are 2 mandatory parts:
- generatorconfigversion : must be 1
- templateset : pointer to template set directory for the environment, e.g SET2
The rest is optional:
- id: is optional, only useful if other generatorconfig needs to reference this config
- import_substitution_parameters: List of generatorconfig ids to import substitution parameters from. Each of the imported parameters can be overridden
- substitution_parameters: is the parameters for jinja2 templating of the templates
- overrides: Use it to override anything in the generated manifests. The section is a list with:
- manifest: Optional if there is just 1 manifest in the template SET, otherwise the manifest (kind,namespace,name) coordinates
- values: yaml to override anything in the jinja2 generated manifests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nmanifest-0.0.2.tar.gz
.
File metadata
- Download URL: nmanifest-0.0.2.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea668e27f89722e5e4400323f6dc328889520b2d48b307c8d181499b192fd561 |
|
MD5 | 3f1b36e17f69fb5d511fc892f52e98c9 |
|
BLAKE2b-256 | f0b9c2dc4ad32639942b2d5c792ad518da262e161396f879cb768d55a3c28090 |
File details
Details for the file nmanifest-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: nmanifest-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1c95f6ac59540956856aa6730ccfa70b164bd085ceb000508aaad923b6496cf |
|
MD5 | 8d3c21fc7a4e379d90a55909a54cc6bc |
|
BLAKE2b-256 | 62a8ced8f78fbd3e17ec6bdde5c482a31eb2474fdc3e05b6ba7ad74b50641f3c |