No description
Find a file
Vincent Ambo bc9fc9730d feat main: Add apply command
This integrates support for actually calling out to `kubectl apply`.

A dry-run flag is implemented, too.

The `run` command has been renamed to `template`.
2017-02-08 15:42:13 +01:00
context feat context: Add YAML loading support 2017-02-08 13:13:21 +01:00
example docs: Add YAML to docs 2017-02-08 13:15:36 +01:00
templater feat template: Add additional template functions 2017-02-08 14:40:45 +01:00
.gitignore chore: Add .gitignore 2017-02-08 11:50:18 +01:00
.travis.yml feat build: Add Travis.CI support 2017-02-08 13:00:34 +01:00
LICENSE chore: Add LICENSE 2017-02-08 11:58:26 +01:00
main.go feat main: Add apply command 2017-02-08 15:42:13 +01:00
README.md docs: Add generated 'kontemplate run' help 2017-02-08 14:07:56 +01:00

KonTemplate - A simple Kubernetes templater

Build Status

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:

.
├── prod-cluster.yaml
└── 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.

Lets take a short look at prod-cluster.yaml:

---
context: k8s.prod.mydomain.com
global:
  globalVar: lizards
include:
  - name: some-api
    values:
      version: 1.0-0e6884d
      importantFeature: true
      apiPort: 4567

Those values are then templated into the resource files of some-api.

Installation

Assuming you have Go configured correctly, you can simply go get github.com/tazjin/kontemplate/....

Usage

You must have kubectl installed to use KonTemplate effectively.

NAME:
   kontemplate run - Interpolate and print templates

USAGE:
   kontemplate run [command options] [arguments...]

OPTIONS:
   --file value, -f value   Cluster configuration file to use
   --limit value, -l value  Limit templating to certain resource sets

At the moment KonTemplate will simply output the templated Kubernetes resource files, which can then be piped into kubectl:

# Look at output and check to see if it's correct ...
kontemplate run -f example/prod-cluster.yaml -l some-api

# ... if it is, go ahead and apply it
kontemplate run -f example/prod-cluster.yaml -l some-api | kubectl apply -f -

# That's it!