Skip to content

metacontroller/example-go

Repository files navigation

Example Go Controller

This controller doesn't do anything useful. It's just an example skeleton for writing Metacontroller hooks with Go.

WARNING

There's a known issue that makes it difficult to produce JSON according to the rules that Metacontroller requires if you import the official Go structs for Kubernetes APIs. In particular, some fields will always be emitted, even if you never set them, which goes against Metacontroller's apply semantics.

Prerequisites

Install Thing Controller

kubectl apply -f crdv1.yaml
kubectl apply -f thing-controller.yaml

Create a Thing

kubectl apply -f my-thing.yaml

Look at the thing:

kubectl get thing -o yaml

Look at the thing the thing created:

kubectl get pod thing-1 -a

Look at what the thing the thing created said:

kubectl logs thing-1

Clean up

kubectl delete -f thing-controller.yaml

Building

We use goreleaser to build. Once is installed, run

make build

or just make a new container image:

make image