Jsonnet and Tanka Kubernetes Config Prompt
Generate and structure Kubernetes manifests with Jsonnet and Grafana Tanka — libraries, abstractions, environments, and diff-gated apply — for teams that have outgrown YAML templating but want stronger composition than Helm or Kustomize.
- Target user
- Platform engineers managing large, highly-templated manifest sets
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior platform engineer who has run Grafana Tanka and Jsonnet to manage thousands of Kubernetes objects with real abstractions instead of copy-pasted YAML. I will provide: - The scale and shape of my manifests (services, environments, clusters) - What I use today (raw YAML, Helm, Kustomize) and why it hurts - Team's appetite for learning Jsonnet - How applies happen (CI vs manual) and the GitOps setup, if any Your job: 1. **When Jsonnet/Tanka is justified** — be honest: Jsonnet has a learning curve and a smaller community. Compare against Helm and Kustomize for my scale and say when it is and isn't worth it. 2. **Jsonnet fundamentals for config** — objects, functions, `+:` merging, `std` library, and hidden fields — the minimum the team needs. Show a small example that builds a Deployment from parameters. 3. **Libraries and abstraction** — design reusable libraries (e.g. a `service.libsonnet` that takes name/image/replicas and returns Deployment+Service+HPA), use `k.libsonnet` (the Kubernetes Jsonnet library) for typed object builders, and vendor deps with `jsonnet-bundler`. 4. **Tanka structure** — `environments/<cluster>/<namespace>/` with `main.jsonnet`, `spec.json` (target cluster/namespace), and shared `lib/`. Show the tree and one environment's `main.jsonnet`. 5. **Environment parameters** — model per-env differences as data passed into the libraries, not forked files. 6. **Diff-gated workflow** — `tk diff` against the live cluster in CI, posted to the PR, then `tk apply` on merge with `--dry-run` validation first. Show the snippet. 7. **GitOps fit** — how to render Tanka to plain YAML for Argo CD/Flux if you don't want Tanka doing the apply, vs letting `tk apply` own it. 8. **Guardrails** — linting (`jsonnet-lint`, `tk lint`), formatting (`jsonnetfmt`), and tests that assert rendered objects, so abstractions don't silently change output. Output as: (a) directory tree, (b) a reusable `service.libsonnet` + one environment `main.jsonnet`, (c) the diff-gated CI snippet, (d) a render-to-YAML option for GitOps, (e) an incremental adoption plan from my current setup. Favor small, tested libraries over deep inheritance; keep rendered output reviewable.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Crossplane Managed Resource Import & Observe-Only Prompt
Bring existing brownfield cloud resources under Crossplane management using the crossplane.io/external-name annotation and observe-only policies, without recreating or mutating live infrastructure.
-
Crossplane v2 Namespaced XR Migration Prompt
Plan the migration from Crossplane v1 cluster-scoped composite resources and claims to v2 namespaced XRs, updating XRDs, compositions, and RBAC without orphaning managed resources.
-
cdk8s Construct Library Design Prompt
Design a reusable cdk8s construct library that turns raw Kubernetes manifests into typed, composable building blocks with sane defaults and validation.
-
Crossplane Composition Testing with uptest Prompt
Build a render-and-test workflow for Crossplane Compositions so XR changes are validated against expected managed resources before they reach a cluster.
More Infrastructure as Code prompts & error guides
Browse every Infrastructure as Code prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.