sigs.k8s.io/controller-runtime@v0.18.2/examples/README.md (about) 1 # Examples 2 3 These two examples represent the usage of `controller-runtime` libraries for built-in Kubernetes resources as well as custom resources. 4 5 ### builtins/ 6 7 This example implements a custom controller and webhooks for the *existing* ReplicaSet resource. 8 9 * `controller.go`: implements a reconciler for ReplicaSets 10 * `mutatingwebhook.go`: implements a mutating webhook that adds an annotation to every incoming Pod ("example-mutating-admission-webhook" = "foo") 11 * `validatingwebhook.go`: implements a validating webhook that checks to see if a Pod has the aforementioned annotation 12 * `main.go` 13 1. Creates a new manager 14 2. Creates a new controller that watches both ReplicaSets and Pods and reconciles the objects with the implemented reconciler 15 3. Registers the mutating and validating webhooks with the manager 16 4. Starts the manager 17 18 ### crd/ 19 20 This example implements a *new* Kubernetes resource, ChaosPod, and creates a custom controller that watches it and webhooks that mutate and validate. 21 22 * `pkg/` 23 * `resource.go`: defines the schema for the ChaosPod API and implements validate and mutate webhooks 24 * `groupversion_info.go`: specifies the Group and Version for the ChaosPod API 25 * `zz_generated.deepcopy.go`: deep copy functions generated by kubebuilder 26 * `main.go` 27 1. Creates a new manager 28 2. Adds ChaosPod resource to the manager's schema 29 3. Implements a reconciler to execute the desired behavior of the ChaosPod API 30 4. Creates a new controller that watches ChaosPods and reconciles the objects with the implemented reconciler 31 5. Adds ChaosPod webhooks to manager 32 6. Starts the manager 33 34 ## Deploying and Running 35 36 To install and run the provided examples, see the Kubebuilder [Quick Start](https://book.kubebuilder.io/quick-start.html).