Simple example of the client-go
SharedInformer that can be used to do all kinds of fun stuff with K8S deployment events
- Clone this repo -
git clone https://github.com/venkyvb/k8s-sharedinformer.git
cd k8s-sharedinformer
- Update the path to the KUBECONFIG file (assumes that this app is running outside the cluster)
- Do a local K8S cluster set-up either using the Docker Desktop or the much more lightweight and awesome Kind
- To update the go-mod dependencies run
go get
- Run the app -
go run main.go
. - In another terminal session run do a simple K8S deployment (the file
nginx.yaml
) -kubectl apply -f nginx.yaml
- You would be able to see the message -
Pod started -> nginx-deployment-XXXXXXXXX-XXXXX
in the waiting console session created in step (6) - Now run
kubectl delete deployment nginx-deployment
in the 2nd terminal session -
- You would be able to see the message -
Pod deleted -> nginx-deployment-XXXXXXXXX-XXXXX
in the waiting console session created in step (6)
- You would be able to see the message -
Have fun !!