Skip to main content

Utility to template Kubernetes Resource Definitions using the jinja2 templating language

Project description

# ktpl

Utility to template Kubernetes Resource Definitions using the jinja2 templating engine, then apply or delete the templated resources

[![Build Status](https://travis-ci.org/whereismyjetpack/ktpl.svg?branch=master)](https://travis-ci.org/whereismyjetpack/ktpl)

## Getting Started
`pip install git+https://github.com/whereismyjetpack/ktpl.git@master`

### Prerequisites
`kubectl`

### Usage
```
Usage:
ktpl [options] [<folder>...]
ktpl [options] [--input-file=<file>]...
ktpl [options] [--template-file=<file>]...

Options:
--delete -d Delete, instead of apply templated manifests
--template -t Template manifests, and print to screen
--environment -e Consider environment when processing variables
--input-file=<file> -i Path to input file(s) to process instead of the defaults
--template-file=<file> -t Path to template file(s) to process instead of the defaults
```


### Directory Structure:

```.
├── folder-1
│   ├── template.yml.tpl
│   └── values.yml <- "defaulty" variables for resources in this folder
├── folder-2
│   ├── template.yml.tpl
│   └── values.yml <- "defaulty" variables for resources in this folder
├── values.yml <--- global variables used in all resources
├── folder-2.yml <--- values that get added only for resources in folder-2
├── folder-2-customer-b.yml <--- a second set of values, that will get appied to resources in folder-2
├── folder-1.yml <---values that get added only for resources in folder-1
└── values.yml.secret <--- global variables, that will be merged with values.yml. good for using `git-crypt` to encrypt only secret portions of your variables
```

### Variable precidence:
{{folder_name}}.yml
values.yml
{{folder_name}}/values.yml

### Examples:
```
1.) ktpl
- processes folder-1/template.yml.tpl, and folder-2/template.yml.tpl. processes folder-2/template.yml.tpl twice. once with values from folder-2.yml, and once with values from folder-2-customer-b.yml.
2.) ktpl folder-1
- processes folder-1/template.yml.tpl with values from values.yml, values.yml.secret, and folder-1.yml. variables from folder-1.yml will override defaulty variables set in values.yml
3.) ktpl --template
- processes the same as example 1, but prints the template to screen instead of sending to kubectl
```

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

ktpl-0.0.16.tar.gz (22.4 kB view details)

Uploaded Source

File details

Details for the file ktpl-0.0.16.tar.gz.

File metadata

  • Download URL: ktpl-0.0.16.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ktpl-0.0.16.tar.gz
Algorithm Hash digest
SHA256 6319b62faaec9c64c1662590b1a2c7fda470e88a27e454ac5fb4599bbd731db2
MD5 a2fca6474c688321e17af8e108a5153f
BLAKE2b-256 dd2d5634bbf839b91c2ecc8bbe80bb650bd911fa36d8e1330689b011ba2b9591

See more details on using hashes here.

Supported by

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