Skip to content

C123R/k8s-click-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

k8s-click-counter

K8s-click-counter is a demo application, can be used for the Kubernetes workshops.

This demo app runs across two containers:

  • backend - a Go REST API which serves the click's count.
  • fronend - a simple Go web application calls the backend REST API /api/counter

Running

Docker

  • click-counter-backend
cd backend

docker build -t click-counter-backend .

docker run -it -p 9001:9001 click-counter-backend
  • click-counter-frontend
cd frontend

docker build -t click-counter-frontend .

docker run -it -p 9000:9000 --env BACKEND_SERVICE=http://localhost:9001/api/counter click-counter-frontend

You can access the frontend on: http://localhost:9000

Kubernetes

Deploy it on Kubernetes cluster:

kubectl apply -f https://raw.githubusercontent.com/C123R/k8s-click-counter/master/k8s-click-counter.yaml -n $(whoami)

# it will create a namespace with your userid(whoami)

Since we are creating service as cluster type, we cant access it from outside our cluster. Still you can do it using kubectl port-forward.

kubectl port-forward service/click-counter-frontend-svc :80 -n $(whoami)