Skip to content

Commit 7a2dbe8

Browse files
authored
Sample resource
1 parent a63fa5d commit 7a2dbe8

File tree

1 file changed

+67
-5
lines changed

1 file changed

+67
-5
lines changed

README.md

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,75 @@ Let's take a look at another example, that will show also additional features (b
119119
resources are applied, however, there are certain cases when this is needed also for Kubernetes, but especially useful when external resources are managed by Kubernetes controllers.
120120
The following example shows how to deploy a [dynamic admission controller](https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/) that mutates
121121
all the `Pods`, adding annotation on them. Note that this is a tricky situation since the endpoint for the `MutatingWebhookConfiguration` is also a `Pod`, thus it should be
122-
first up and running before the configuration is applied, otherwise, the mutation webhook will block the changes on the pods, which would render the cluster unable to manage `Pods':
122+
first up and running before the configuration is applied, otherwise, the mutation webhook will block the changes on the pods, which would render the cluster unable to manage `Pods'
123+
(irrelevant details are omitted, see the full version [here][https://github.com/csviri/resource-workflow-operator/blob/main/src/test/resources/sample/mutation/mutation.glue.yaml]):
123124

124125
```yaml
125-
126-
127-
128-
126+
apiVersion: io.csviri.operator.resourceglue/v1beta1
127+
kind: Glue
128+
metadata:
129+
name: mutation-webhook-deployment
130+
spec:
131+
resources:
132+
- name: service
133+
resource:
134+
apiVersion: v1
135+
kind: Service
136+
metadata:
137+
name: pod-mutating-hook
138+
spec:
139+
# spec omitted
140+
- name: deployment # webhook endpoint
141+
readyPostCondition:
142+
type: ReadyCondition # ready post conditions determine when a Deployment is considered "ready", thus up and running.
143+
resource:
144+
apiVersion: apps/v1
145+
kind: Deployment
146+
metadata:
147+
name: pod-mutating-hook
148+
spec:
149+
replicas: 2
150+
template:
151+
spec:
152+
containers:
153+
image: ghcr.io/csviri/sample-pod-mutating-webhook:0.1.0
154+
name: pod-mutating-hook
155+
ports:
156+
- containerPort: 443
157+
name: https
158+
protocol: TCP
159+
160+
- name: mutation_hook_config
161+
# dependsOn relation means, that the resource will be reconciled only if all the listed resources are already reconciled and ready (if ready post-condition is present).
162+
# This resource will be applied, after the service and deployment are applied, and the deployment is ready, thus all the pods are started up and ready.
163+
dependsOn:
164+
- deployment
165+
- service
166+
resource:
167+
apiVersion: admissionregistration.k8s.io/v1
168+
kind: MutatingWebhookConfiguration
169+
metadata:
170+
name: pod-mutating-webhook
171+
webhooks:
172+
- admissionReviewVersions:
173+
- v1
174+
clientConfig:
175+
service:
176+
name: pod-mutating-hook
177+
namespace: default
178+
path: /mutate
179+
failurePolicy: Fail
180+
name: sample.mutating.webhook
181+
rules:
182+
- apiGroups:
183+
- ""
184+
apiVersions:
185+
- v1
186+
operations:
187+
- UPDATE
188+
- CREATE
189+
resources:
190+
- pods
129191
```
130192

131193

0 commit comments

Comments
 (0)