2017-02-08 11:50:26 +01:00
|
|
|
KonTemplate - A simple Kubernetes templater
|
|
|
|
===========================================
|
|
|
|
|
2017-02-08 13:03:06 +01:00
|
|
|
[![Build Status](https://travis-ci.org/tazjin/kontemplate.svg?branch=master)](https://travis-ci.org/tazjin/kontemplate)
|
|
|
|
|
2017-02-08 11:50:26 +01:00
|
|
|
I made this tool out of frustration with the available ways to template Kubernetes resource files. All I want out of
|
|
|
|
such a tool is a way to specify lots of resources with placeholders that get filled in with specific values, based on
|
|
|
|
which context (i.e. k8s cluster) is specified.
|
|
|
|
|
|
|
|
## Overview
|
|
|
|
|
|
|
|
KonTemplate lets you describe resources as you normally would in a simple folder structure:
|
|
|
|
|
|
|
|
```
|
|
|
|
.
|
2017-02-08 13:15:36 +01:00
|
|
|
├── prod-cluster.yaml
|
2017-02-08 11:50:26 +01:00
|
|
|
└── some-api
|
|
|
|
├── deployment.yaml
|
|
|
|
└── service.yaml
|
|
|
|
```
|
|
|
|
|
|
|
|
This example has all resources belonging to `some-api` (no file naming conventions enforced at all!) in the `some-api`
|
|
|
|
folder and the configuration for the cluster `prod-cluster` in the corresponding file.
|
|
|
|
|
2017-02-08 13:15:36 +01:00
|
|
|
Lets take a short look at `prod-cluster.yaml`:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
---
|
|
|
|
context: k8s.prod.mydomain.com
|
|
|
|
global:
|
|
|
|
globalVar: lizards
|
|
|
|
include:
|
|
|
|
- name: some-api
|
|
|
|
values:
|
|
|
|
version: 1.0-0e6884d
|
|
|
|
importantFeature: true
|
|
|
|
apiPort: 4567
|
2017-02-08 11:50:26 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
Those values are then templated into the resource files of `some-api`.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
You must have `kubectl` installed to use KonTemplate.
|