vs-starter

Creates a docker configuration using the rendered helm templates

Install

Can be installed by cloning and running

python setup.py install

Usage

The package transforms rendered helm templates to docker compose files so the helm templates should be rendered first with:

helm template <slug> chart --output-dir <output-dir> --values values.custom.yaml

Afterwards the vs_starter command is available:

Usage: vs_starter [OPTIONS] HELM_CONFIG_PATH OUTPUT_PATH

Options:
  -s/--slug             [required] name of collection to generate, eg "vhr15" 
  -e/--environment      [required] one of "ops", "staging", "dev"
  -o/--instance-override [multiple] `Absolute paths` to additional `YAML` files treated as jinja templates
                          to render and add to the OUTPUT_PATH (in case of files named docker*) 
                          or OUTPUT_PATH/config (in case of other files)
  --help                 Show this message and exit.

Example split of configuration compose files is as follows:

  • docker-compose.yml - is part of vs-starter/templates and gets rendered automatically - contains base service configurations that are likely not going to change

  • docker-compose.shared.yml - contains overrides for specific platform for all services (staging/dev/ops) but with configurations more or less same for each that gets created. This file needs to be supplied via -o flag.

  • docker-compose.instance.yml - contains specific overrides, additional services etc. This file needs to be supplied via -o flag.

Variables inside compose templates

Following variables are currently available for substitution in docker compose templates:

  • slug - CLI parameter

  • environment - CLI parameter

  • service_configs["host"] - from values, matches to values.global.ingress.tls [0].hosts[0]

  • service_configs[service]["replicas"] - from values, matches to values.service-name.replicaCount

  • service_configs[service]["image"] - from values

  • all key/value pairs of renderer environment variables coming from the values - can be inspected in /vs/charts/renderer/templates/deployment.yaml under key spec.template.spec.containers[0].env

Sample files

Basic docker-compose.yml contained in the templates folder does not contain any traefik configurations and special log handling. This puts direct control over the external routing, access and logging to the operator.

For deploying a fully accessible stack with defined ingress, docker external networks etc. refer to sample stack configuration stored in sample_templates/README.md. These can be used to base the -o overrides off from.

Tagging

This repository uses bump2version for managing tags. To bump a version use

bump2version <major|minor|patch>
git push && git push --tags

Development

To setup for development run the following commands for your virtual env.

python3 setup.py install --force
pip install -r requirements-dev.txt
pip install -r requirements-test.txt

Flake8, mypy and black can be ran as commands from terminal:

flake8 # at the root folder
mypy . # at the root folder
black file.py # to autoformat a file. also possible with a path