Skip to content
Flexible, reusable and concise configuration for Kubernetes
Go Jsonnet Makefile Dockerfile
Branch: master
Clone or download
sh0rez fix(kubernetes): do not fail on nil receiver (#56)
Although Tanka can run totally fine without a spec.json, it panicked because of
the namespace override.

Now leaves the namespace untouched if it is not known.

Furthermore also fails on apply and diff without a spec.json with a clean error
message.
Latest commit e220c83 Aug 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.drone chore: relocate to grafana (#26) Aug 8, 2019
.github chore: bots (#25) Aug 13, 2019
cmd/tk feat(cli): abort `tk show` when stdout is being piped (#47) Aug 14, 2019
docs doc: README + documentation (#51) Aug 16, 2019
pkg
.gitignore chore(packaging): automatic releasing Jul 31, 2019
CHANGELOG.md chore(release): v0.3.0 (#43) Aug 13, 2019
Dockerfile chore(packaging): automatic releasing Jul 31, 2019
LICENSE
Makefile chore(build): add install and uninstall Makefile targets (#37) Aug 12, 2019
README.md doc: README + documentation (#51) Aug 16, 2019
go.mod chore: relocate to grafana (#26) Aug 8, 2019
go.sum feat(tooling): import analysis (#10) Aug 7, 2019
mkdocs.yml doc: name Grafana Labs as the sponsor (#54) Aug 16, 2019
requirements.txt doc: README + documentation (#51) Aug 16, 2019

README.md

Overview

Tanka Banner

Build Status Golang GitHub contributors GitHub release License

Tanka is a composable configuration utility for Kubernetes. It leverages the Jsonnet language to realize flexible, reusable and concise configuration.

  • 🔁 ksonnet drop-in replacement: Tanka aims to provide the same workflow as ksonnet: show, diff and apply are just where you expect them.
  • 🔩 integrates with the ecosystem: Tanka doesn't re-invent the wheel. It rather makes heavy use of what is already there: jsonnet-bundler for package management and kubectl for communicating with Kubernetes clusters.
  • 🔨 powerful: Being a jsonnet-compatibility layer for Kubernetes, it removes the limitations of static (or template-based) configuration languages.
  • 🚀 used in production: We use Tanka internally at Grafana Labs for all of our Kubernetes configuration needs.
  • ❤️ fully open-source: This is an open-source project. It is free as in beer and as in speech and this will never change.

Getting started

Head over to the Releases section and download the most latest release of Tanka for your OS and arch.

Then check everything is working correctly with

$ tk --version
tk version v0.3.0

It is also recommended to install Jsonnet bundler:

$ go get -u github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb

Creating a new project

To start from scratch with the recommended directory structure, do the following:

# create a directory and enter it
$ mkdir poetry && cd poetry

# initialize the Tanka application
$ tk init

Deploying an application

As an example, Promtail is being deployed using Tanka now.

After you initialized the directory structure, install the required libraries using jb:

# Ksonnet kubernetes libraries
$ jb install github.com/ksonnet/ksonnet-lib/ksonnet.beta.3/k.libsonnet
$ jb install github.com/ksonnet/ksonnet-lib/ksonnet.beta.3/k8s.libsonnet

# Promtail library
$ jb install github.com/grafana/loki/production/ksonnet/promtail

Then, replace the contents of environments/default/main.jsonnet with the following:

local promtail = import 'promtail/promtail.libsonnet';

promtail + {
  _config+:: {
    namespace: 'loki',

    promtail_config+: {
      clients: [
        {
          scheme:: 'https',
          hostname:: 'logs-us-west1.grafana.net',
          username:: 'user-id',
          password:: 'password',
          external_labels: {},
        }
      ],
      container_root_path: '/var/lib/docker',
    },
  },
}

As a last step, fill add the correct spec.apiServer and spec.namespace to environments/default/spec.json:

{
  "apiVersion": "tanka.dev/v1alpha1",
  "kind": "Environment",
  "spec": {
    "apiServer": "https://localhost:6443",
    "namespace": "default"
  }
}

Now use tk show environments/default to see the yaml, and tk apply environments/default to apply it to the cluster.

Congratulations! You have successfully set up your first application using Tanka 🎉

Additional resources

License

Licensed Apache 2.0, see LICENSE.

You can’t perform that action at this time.