Skip to content

An example Kubernetes controller in go which prints the number of replicas when a deployment is scaled

Notifications You must be signed in to change notification settings

janwillies/example-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes Example Controller

An example controller in go which prints the number of replicas when a deployment is scaled. Local dev environment with kind and ko.

setup dev environment

Make sure Docker is up and running. Then start a local Kubernetes cluster with kind:

./kind-with-registry.sh

This will start a docker registry and a Kubernetes cluster and wires them up. Easy peasy right?

build and deploy the controller

Our source is written in go and thus we can use ko to build and deploy:

export KO_DOCKER_REPO=localhost:5000/controller-example
ko apply -f deployment.yaml

use

scale a deployment

kubectl logs -f controller-example-7f7fffd5c5-pdnml
kubectl scale deployment --replicas 2 controller-example
kubectl scale deployment --replicas 4 controller-example

watch the controller logs

2020/02/15 14:16:12 Deployment: controller-example, Replicas: 2
2020/02/15 14:16:19 Deployment: controller-example, Replicas: 4

About

An example Kubernetes controller in go which prints the number of replicas when a deployment is scaled

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published