No description
Find a file
Vincent Ambo 511ae92224 chore(build): Update dependencies to newest version
Updates the following dependencies to latest:

* Masterminds/semver
* Masterminds/sprig
* ghodss/yaml
* satori/go.uuid -> google/uuid
* huandu/xstrings
* imdario/mergo
* crypto
* alecthomas/kingpin.v2
* yaml.v2

As usual Go libraries are YOLO-versioned, so who knows what changed
here. I'll be going through `sprig` at least to add that to the
changelog.

This relates to #152.
2018-08-15 19:46:33 +02:00
context test(context): Introduce an explicit value merging test 2018-06-26 21:06:38 +02:00
docs feat(templater) Add a template function to insert surrounding repo's Git hash 2018-03-29 20:05:30 +02:00
example feat(templater): Support single-template resource sets 2018-06-09 21:23:48 +02:00
image chore(image): Bump version to 1.6.0 2018-06-09 22:13:42 +02:00
templater test(templater): Add a test for the default template function 2018-07-14 23:21:36 +02:00
util refactor(util): Use YAML parser for both JSON & YAML files 2018-06-09 20:21:29 +02:00
.gitignore feat release: Add simple release script 2017-05-08 11:15:20 +02:00
.travis.yml feat(build): Build both derivations on Travis 2018-03-09 13:35:35 +01:00
build-release.sh chore: Bump version to 1.7.0 2018-06-26 21:06:38 +02:00
CODE_OF_CONDUCT.md docs: Add official code of conduct 2017-06-22 15:12:51 +02:00
CONTRIBUTING.md docs: Add contribution guidelines 2018-05-15 11:25:25 +02:00
default.nix refactor(build): Add Nix derivation & configure Travis to build it 2018-03-09 13:35:35 +01:00
deps.nix chore(build): Update dependencies to newest version 2018-08-15 19:46:33 +02:00
kontemplate.rb chore(brew): Update Homebrew formula for 1.6.0 2018-06-09 22:13:42 +02:00
LICENSE feat(license): Relicense under GPLv3 2017-11-21 11:46:27 +01:00
main.go chore: Bump version to 1.7.0 2018-06-26 21:06:38 +02:00
PKGBUILD feat(license): Relicense under GPLv3 2017-11-21 11:46:27 +01:00
README.md chore: Remove legacy build system 2018-03-09 13:35:35 +01:00
release.nix feat(build): Pin nixpkgs used for release build 2018-03-09 14:51:05 +01:00

Kontemplate - A simple Kubernetes templater

Build Status

Kontemplate is a simple CLI tool that can take sets of Kubernetes resource files with placeholders and insert values per environment.

This tool was made because in many cases all I want in terms of Kubernetes configuration is simple value interpolation per environment (i.e. Kubernetes cluster), but with the same deployment files.

In my experience this is often enough and more complex solutions such as Helm are not required.

Check out a Kontemplate setup example and the feature list below!

Table of Contents

Features

Example

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. That's it!

You can also set up more complicated folder structures for organisation, for example:

.
├── api
│   ├── image-api
│   │   └── deployment.yaml
│   └── music-api
│       └── deployment.yaml
│   │   └── default.json
├── frontend
│   ├── main-app
│   │   ├── deployment.yaml
│   │   └── service.yaml
│   └── user-page
│       ├── deployment.yaml
│       └── service.yaml
├── prod-cluster.yaml
└── test-cluster.yaml

And selectively template or apply resources with a command such as kontemplate apply test-cluster.yaml --include api --include frontend/user-page to only update the api resource sets and the frontend/user-page resource set.

Installation

It is recommended to install Kontemplate from the signed binary releases available on the releases page. Release binaries are available for Linux, OS X, FreeBSD and Windows.

Homebrew

OS X users with Homebrew installed can "tap" Kontemplate like such:

brew tap tazjin/kontemplate https://github.com/tazjin/kontemplate
brew install kontemplate

Arch Linux

An AUR package is available for Arch Linux and other pacman-based distributions.

Building from source

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.

usage: kontemplate [<flags>] <command> [<args> ...]

simple Kubernetes resource templating

Flags:
  -h, --help                 Show context-sensitive help (also try --help-long and --help-man).
  -i, --include=INCLUDE ...  Resource sets to include explicitly
  -e, --exclude=EXCLUDE ...  Resource sets to exclude explicitly

Commands:
  help [<command>...]
    Show help.

  template <file>
    Template resource sets and print them

  apply [<flags>] <file>
    Template resources and pass to 'kubectl apply'

  replace <file>
    Template resources and pass to 'kubectl replace'

  delete <file>
    Template resources and pass to 'kubectl delete'

  create <file>
    Template resources and pass to 'kubectl create'

Examples:

# Look at output for a specific resource set and check to see if it's correct ...
kontemplate template example/prod-cluster.yaml -i some-api

# ... maybe do a dry-run to see what kubectl would do:
kontemplate apply example/prod-cluster.yaml --dry-run

# And actually apply it if you like what you see:
kontemplate apply example/prod-cluster.yaml

Check out the feature list and the individual feature documentation above. Then you should be good to go!

Contributing

Feel free to contribute pull requests, file bugs and open issues with feature suggestions!

Kontemplate is licensed under the GPLv3, a copy of the license and its terms can be found in the LICENSE file.

Please follow the code of conduct.