Skip to content
A basic stateless Ruby app for experimenting with Kubernetes
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Docker Pulls

A basic stateless Ruby app for experimenting with Kubernetes

Belafonte Example

This repo contains the sample code of a basic Sinatra app called Belafonte that can be deployed to Kubernetes for learning and exploration.

It was written to be an example application for my blog post on Cloud Native Buildpacks and kapp in Kubernetes.

The app prints out some basic information about the pod it is running on and demonstrates inter-pod communication by fetching a UUID from another microservice that spits out UUIDs (httpbin).

Building the Image

I use the Cloud Native Buildpacks pack CLI and heroku Ruby buildpack to build and publish the container image for this app.

pack build downey/sinatra-k8s-sample --builder heroku/buildpacks --buildpack heroku/ruby --publish

If you want to publish to your own image repository, replace the downey/sinatra-k8s-sample portion above.

Deploying to Kubernetes

I have been deploying to a Digital Ocean hosted Kubernetes cluster that has the following installed:

To deploy the app itself I have been using the kapp CLI.

kapp deploy -a belafonte -f deploy

This will deploy everything in the deploy directory and kapp will ensure resources are applied in a reasonable order (e.g. namespaces and CRDs first) and it will wait until the status checks succeed for resources before continuing.

After that finished you can run kapp inspect -a belafonte and you should see all of the resources that were deployed. Example:

Resources in app 'belafonte'

Namespace  Name                             Kind                Owner    Conds.  Rs  Ri  Age
(cluster)  belafonte                        Namespace           kapp     -       ok  -   33m
belafonte  belafonte                        Certificate         cluster  1/1 t   ok  -   33m
^          belafonte                        Deployment          kapp     2/2 t   ok  -   33m
^          belafonte                        Endpoints           cluster  -       ok  -   33m
^          belafonte                        Ingress             kapp     -       ok  -   33m
^          belafonte                        Service             kapp     -       ok  -   33m
^          belafonte-1918113368             CertificateRequest  cluster  1/1 t   ok  -   33m
^          belafonte-1918113368-3886681398  Order               cluster  -       ok  -   33m
^          belafonte-694ffdfdd4             ReplicaSet          cluster  -       ok  -   33m
^          belafonte-7c874788d7             ReplicaSet          cluster  -       ok  -   11s
^          belafonte-7c874788d7-lm6hj       Pod                 cluster  4/4 t   ok  -   11s
^          httpbin                          Deployment          kapp     2/2 t   ok  -   33m
^          httpbin                          Endpoints           cluster  -       ok  -   33m
^          httpbin                          Service             kapp     -       ok  -   33m
^          httpbin-85b9b4c565               ReplicaSet          cluster  -       ok  -   33m
^          httpbin-85b9b4c565-x2nmb         Pod                 cluster  4/4 t   ok  -   33m
You can’t perform that action at this time.