Introduction
Grafana Tanka is a Kubernetes configuration tool that uses Jsonnet as its templating language. Developed by Grafana Labs, it replaces static YAML manifests with programmable Jsonnet code and provides a CLI for diffing, applying, and managing environments.
What Tanka Does
- Generates Kubernetes manifests from Jsonnet source files
- Manages multiple environments (dev, staging, production) with shared base configurations
- Shows diffs between the desired state and the live cluster before applying
- Integrates with jsonnet-bundler (jb) for dependency management of Jsonnet libraries
- Exports rendered YAML for use with other deployment tools or GitOps pipelines
Architecture Overview
Tanka evaluates Jsonnet files into a JSON object of Kubernetes resources. Each environment has a main.jsonnet entrypoint and spec.json defining the target cluster. Jsonnet code imports libraries like k8s-libsonnet for typed K8s object constructors. Tanka's CLI evaluates Jsonnet, extracts individual objects, then diffs or applies them via the Kubernetes API.
Self-Hosting & Configuration
- Single binary (tk) with no daemon or server component
- Each environment is a directory with spec.json (cluster endpoint, namespace) and main.jsonnet
- Dependencies managed via jsonnet-bundler (jb) with a jsonnetfile.json manifest
- Supports inline environments for smaller projects without directory structure
- Connects to clusters using standard kubeconfig files and kubectl context
Key Features
- Jsonnet eliminates YAML repetition through variables, functions, and object merging
- Environment abstraction manages per-cluster differences from a shared code base
- Native diff command compares rendered output against live cluster state
- Export mode renders all manifests to static YAML files for GitOps workflows
- Helm chart support allows importing Helm charts as Jsonnet objects
Comparison with Similar Tools
- Helm — Template-based with Go templating; Tanka uses Jsonnet which is a full data language
- Kustomize — Overlay-based YAML patching; Tanka offers richer programmability via Jsonnet
- Pulumi — General-purpose IaC; Tanka is Kubernetes-focused with Jsonnet
- cdk8s — Generates K8s manifests from TypeScript/Python; Tanka uses Jsonnet with native diffing
FAQ
Q: Do I need to learn Jsonnet to use Tanka? A: Yes. Jsonnet is Tanka's core language. Its syntax is a superset of JSON, so the learning curve is manageable for developers familiar with JSON.
Q: Can Tanka work alongside Helm? A: Yes. Tanka can import Helm charts and render them as Jsonnet objects, allowing you to combine Helm charts with native Jsonnet configuration.
Q: How does Tanka handle multiple clusters? A: Each environment in Tanka points to a specific cluster via spec.json. You create separate environment directories sharing common Jsonnet libraries but targeting different API servers.
Q: Is Tanka used in production? A: Yes. Grafana Labs uses Tanka to manage their production Kubernetes clusters, and the project is actively maintained.