Building a sample Guestbook application using ksonnet on Kubernetes


You’ll need:

  • ksonnet
  • running Kubernetes cluster

e.g. kubectl cluster-info


Steps are:

1. create sandbox namespace

2. init app

3. create Guestbook UI component – Deployment and Service

4. create Datastore component



1. create a sandbox namespace

kubectl create namespace ks-dev

(More on Kubernetes: Namespaces )

and set it up with:

which updates your $KUBECONFIG.

Why? To isolate from existing resources on your cluster. Now, we should see this context when you do:

kubectl config get-contexts

(which is just summarising what’s in your $KUBECONFIG. E.g. cat $KUBECONFIG)


2. init your app

which creates a directory, guestbook, with all your manifests, etc.


3. create Guestbook UI component

First declare 2 Kubernetes API resources: a Deployment and a Service. More info: Kubernetes: Deployments and Services

Generate manifest for Guestbook UI:

deployed-service: pattern for manifest (aka prototype)

guestbook-ui: filename and

--image: container image

--type ClusterIP: sets how Service is exposed (other options: NodePort or LoadBalancer)

Then, to view this app:

A few gotchas:

1. i/o timeout

kubectl proxy > /dev/null
log.go:172] http: proxy error: dial tcp i/o timeout

is ‘cos you need to start your cluster. e.g. minikube start

2. bind: address already in use

kubectl proxy > /dev/null &

F1109 16:28:11.685303 72363 proxy.go:158] listen tcp bind: address already in use

is ‘cos kubectl proxy is already running. You can kill it with: killall kubectl

or just reload your URL.


4. create Datastore component

Available prototypes:

ks prototype list

Packages available:

ks pkg list


ks pkg install incubator/redis@master

and should now see it installed, plus the prototypes available. i.e. when you do:

ks prototype list

ks pkg list


See what parameters are required:

ks prototype describe redis-stateless

and generate:

ks generate redis-stateless redis



ks show default

and deploy:

ks apply default

(can use --dry-runto see summary)


Use ksonnet to generate Kubernetes configurations from Helm Charts

What is ksonnet?

A CLI-supported framework for extensible Kubernetes configurations


ksonnet uses the jsonnetlanguage.

Nice that it can eliminate duplication with object-orientation.

More info – see Using jsonnet .
But what IS ksonnet?

Say you want to install an application on Kubernetes. Here’s how you could do it:

  1. kubectl – which quickly gets  complex when you have more than a basic app so you’d use something like helm
  2. helm – which simplifies stuff but you still get a ton of YAML files which is where ksonnet comes in

See this tutorial on building a sample application (Guestbook) using ksonnet on Kubernetes.