Skip to main content
Version: Pasley (2.0.0-rc.15)

Sample Kubernetes Project

All the tutorials use the Sample Kubernetes Project on GitHub. For the remainder of these tutorials, you will need:

  1. A Kubernetes cluster
  2. The Codezero CLI installed
  3. The sample project cloned locally

Tutorials are a work in progress and do not represent everything you can do with Codezero. If you are new to Codezero, it is best that you go through the tutorials in the order they are presented.


In this tutorial, you will learn:

  • How to perform local development against an application running in a Kubernetes cluster

By the end of the tutorial you should have successfully run the application locally, and also in your cluster.


The following diagram depicts all the components of the sample project:

Simple Architecture


If you haven't already, clone the Sample Kubernetes Project repo on GitHub, and set up a Kubernetes cluster. For development, we recommend using either Civo or DigitalOcean, but any k8s or k3s Kubernetes cluster will do.

Getting to know Kubernetes and setting up a cluster is beyond the scope of this README, however you can check out the beginner articles on our Blog.

Local Setup

This project requires NodeJS 16+ and yarn, has been tested on macOS (BigSur), Linux, and Windows Subsystem for Linux (WSL).

npm install -g yarn

All microservices can run locally with minimal requirements. After you clone the project, you can build and run all the services locally. From the repo's root, run the following (yarn is required):

yarn install
yarn start

Open http://localhost:3030 in a browser to view the running services.


If you aren't running MongoDB locally you won't see the database service running, but we'll get this working in a cluster in the next section.

Hit Ctrl-C now to stop the services and exit.

Kubernetes Setup

This project uses Persistent Volumes, and for ingress it can use either LoadBalancer services (e.g. for clusters on DigitalOcean) or Traefik V2.

Once your cluster is set up, install the sample project in-cluster. From the root of the repo, run:

kubectl create ns sample-project
kubectl -n sample-project apply -f ./k8s

Set Up Ingress (optional)

The above commands will install all the services and deployment, but will not set up ingress. You won't need ingress for performing a Teleport, but you will need it for performing other commands like Intercept.

If you're using TraefikV2, run the following:

kubectl -n sample-project apply -f ./k8s/traefik

Or if you use an Ingress Controller, run the following:

kubectl -n sample-project apply -f ./k8s/ingress

To use a generic LoadBalance service (for example if your cluster is on DigitalOcean), run the following:

kubectl -n sample-project apply -f ./k8s/loadbalance

The above assumes port 80 is available. If you'd like an alternative port, edit the port in k8s/loadbalance/frontend.yaml

You will then need to obtain the appropriate ingress service IP address or the LoadBalancer IP address, and go to http://IP-ADDRESS in a browser, where you should see all the microservices running.

If using LoadBalance as the Service type, you can get the Frontend IP using:

kubectl get svc -n sample-project sample-project-frontend --output jsonpath='{.status.loadBalancer.ingress[0].ip}'

It may take a bit of time for the load balancer to obtain an address. You can use the following command to determine if the load balancer has an external address: kubectl get svc -n sample-project sample-project-frontend

On macOS, you can access the service using:

open http://$(kubectl get svc -n sample-project sample-project-frontend --output jsonpath='{.status.loadBalancer.ingress[0].ip}')

For zsh users, when pasting the script command into your terminal, the open parenthesis before "kubectl" may be escaped automatically by zsh. The escape character will need to be removed for the comand to run.

Congratulations, you are now ready to move on to the Developing Edge Services tutorial.