Skip to content

Commit 3fe51b2

Browse files
committed
examples readme: documentation explaining the two provided examples
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
1 parent 8f633b1 commit 3fe51b2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

examples/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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

0 commit comments

Comments
 (0)