Skip to main content

Kubernetes templating engine based on Jinja2

Project description

k8t

Pronounced katie [ˈkeɪti]

Build Status PyPi version PyPi downloads CLARK Open Source

Simple cluster and environment specific aware templating for kubernetes manifests.

Table of Contents generated with DocToc

installation

run this

$ pip install --user --upgrade k8t

usage

scaffolding

Create a new project folder with a cluster directory and an empty defaults file

$ k8t new project foobar

Create a new cluster

$ k8t new cluster A

Create a new environment

$ k8t new environment staging -c A
$ k8t new environment production

Generate a new deployment template for cluster A (currently only deployment and service are supported)

$ k8t new template deployment -c A

Specify prefixes for secrets

$ k8t edit config --cluster A --environment staging
secrets:
  prefix: "staging/application"```

Values can be easily added/modified in the same way

$ k8t edit values --cluster Ano creds to it anyway or dont know where to get

A typical setup should look something like this

.deploy/
├── clusters
│   ├── A
│   │   ├── config.yaml
│   │   ├── environments
│   │   │   ├── production
│   │   │   │   ├── config.yaml
│   │   │   │   ├── files
│   │   │   │   ├── templates
│   │   │   │   └── values.yaml
│   │   │   └── staging
│   │   │       ├── config.yaml
│   │   │       ├── files
│   │   │       ├── templates
│   │   │       └── values.yaml
│   │   ├── files
│   │   ├── templates
│   │   └── values.yaml
│   └── local
│       ├── environments
│       ├── files
│       ├── secret.yaml.j2
│       ├── templates
│       │   ├── database.yaml.j2
│       │   └── secret.yaml.j2
│       └── values.yaml
├── config.yaml
├── files
├── templates
│   ├── deployment.yaml.j2
│   └── secret.yaml.j2
└── values.yaml

validate files

While validation is done before generating, templates can be validated for environment files easily.

$ k8t validate

To validate for clusters/environments the usual options can be used

$ k8t validate -c A -e production

generate files

The --cluster flag will load variables from a directory. By default the file default.yaml in that directory will be loaded, however an environment can be specified with --environment.

$ k8t gen -c A -e staging

Additionally k8t will attempt to load a file defaults.yaml in the root directory. This way a set of default variables can be specified and selectively overriden via cluster and environment.

Additional values can be given via flag --value-file in the form of a file or --value KEY VALUE, both can be supplied multiple times.

Variables will be merged via deep merging. Default merge strategy is left-to-right. For the merge order see the output of

$ k8t --help

Overriding templates

Templates can be overriden on a cluster/environment level.

If a file application.yaml exists in the root templates folder, simply add a file with the same name to the cluster/environment template folder.

Managing secrets

SSM

Setup secrets on SSM

$ k8t edit config
secrets:
  provider: ssm
  prefix: "foobar"

TODO

  • testing needs to be expanded
  • add more templates for manifest scaffolding
  • the ability to add additional template directories via the CLI
  • validation functions for template values (e.g. memory/cpu values)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

k8t-0.1.10.post4.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

k8t-0.1.10.post4-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file k8t-0.1.10.post4.tar.gz.

File metadata

  • Download URL: k8t-0.1.10.post4.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for k8t-0.1.10.post4.tar.gz
Algorithm Hash digest
SHA256 7c802507884d03114809058179f4d99c22351b1f0562e823a7a15c92c36d93d4
MD5 b875ff442584bff626c93dc4ceedffe8
BLAKE2b-256 a7cc7a55e66c11bea3ccf8d25943fbc0c7523a51c11ddfda120d90810ab3e10a

See more details on using hashes here.

File details

Details for the file k8t-0.1.10.post4-py3-none-any.whl.

File metadata

  • Download URL: k8t-0.1.10.post4-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1

File hashes

Hashes for k8t-0.1.10.post4-py3-none-any.whl
Algorithm Hash digest
SHA256 c8217922b43e3fd754239ad86d4aeee8dc1bebe10b0d5ec7dd9bf80b3c37ccbe
MD5 348a68fad15444c55a52956738bf1a5f
BLAKE2b-256 ed1327a10dddebbed71dcbaed0da47e4139223e914b20df7345f8707bf3dc15d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page