Building a sample Guestbook application using ksonnet on Kubernetes

Required

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

 

Details:

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 metadata.name

--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 192.168.99.100:8443: 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 127.0.0.1:8001: 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

Install:

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

 

View YAML

ks show default

and deploy:

ks apply default

(can use --dry-runto see summary)

 

 

https://ksonnet.io/docs/tutorial/guestbook/

 

Leave a Reply

Your email address will not be published. Required fields are marked *