Get Started

What is ksonnet?

ksonnet is a configuration management tool for Kubernetes manifests. The goal of ksonnet is to improve developer experience by providing options beyond writing YAML or text templating.

The typical use case for ksonnet is managing a Kubernetes manifest that differs slightly across environments (e.g. development, staging, production). ksonnet concisely creates a framework for building modular, composable, and reusable configuration management.

Why use ksonnet?

ksonnet aims to simplify configuration management across clusters and environments. It provides a structured way of grouping Jsonnet files in a way that is specific for Kubernetes configuration management.

Extending beyond data templating with Jsonnet, ksonnet uses a registry system for development across teams and features to support local development. Pre-written Jsonnet files can be parameterized and re-used from the command line.

The addition of ksonnet-lib as a built-in Jsonnet library allows writing Kubernetes specific configuration in an object oriented way.

See Core Concepts for a more detailed description of how ksonnet works.

Quick Start

The ksonnet CLI, ks, can be installed in three different ways. Choose the method that best matches your setup:

Run through an example

See some basic ks commands in action:

# View all available commands
ks --help

# Create an app directory (and reference your cluster with $KUBECONFIG)
KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}"

ks init ks-example    # Add '--api-spec=version:v1.8.0' to this command if you're running Kubernetes 1.8!
cd ks-example

# Autogenerate a basic manifest
ks generate deployed-service guestbook-ui \
  --image gcr.io/heptio-images/ks-guestbook-demo:0.1 \
  --type ClusterIP

# Deploy the manifest to your cluster, and view results
ks apply default
kubectl get svc guestbook-ui

# Teardown (Don't worry, this only removes resources defined in your ksonnet app,
# and should not affect any other resources in your 'default' namespace)
ks delete default

Wondering what else you can do with ksonnet? See the tutorials to build a complete app.

Last updated on: September 25, 2018