You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+99-5Lines changed: 99 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,30 +116,120 @@ The lookup function, if used by the template, is executed with a client which im
116
116
117
117
The creation time webhook is not installed by the operator. This is because there is no way to know which specific object type should be intercepted and intercepting all of the types would be too inefficient. It's up to the administrator then to install the webhook. Here is some guidance.
118
118
119
-
If you installed the operator via OLM, use the following webhook template:
119
+
The configurations that needs to be applied in order to support creation time webhooks depends on how the operator was installed (OLM or Helm chart).
120
+
121
+
#### Enabling creation time time webhook (OLM)
122
+
123
+
If you installed the operator via OLM, the certificate that the OLM generates to expose the webhook need to be applied dynamically to the `MutatingWebhookConfiguration` resource. To support this action, we can use the Patch operator to perform the needed configurations.
124
+
125
+
First, create the following resources which will create a ServiceAccount and RBAC policies so that the operator can apply the needed configurations:
126
+
127
+
```yaml
128
+
---
129
+
apiVersion: v1
130
+
kind: ServiceAccount
131
+
metadata:
132
+
creationTimestamp: null
133
+
name: mutatingwebhook-patcher
134
+
namespace: patch-operator
135
+
---
136
+
apiVersion: rbac.authorization.k8s.io/v1
137
+
kind: ClusterRole
138
+
metadata:
139
+
labels:
140
+
name: mutatingwebhookconfiguration-patcher
141
+
rules:
142
+
- apiGroups:
143
+
- ""
144
+
resources:
145
+
- secrets
146
+
verbs:
147
+
- get
148
+
- list
149
+
- watch
150
+
- apiGroups:
151
+
- "admissionregistration.k8s.io"
152
+
resources:
153
+
- mutatingwebhookconfigurations
154
+
verbs:
155
+
- get
156
+
- list
157
+
- watch
158
+
- patch
159
+
- update
160
+
---
161
+
apiVersion: rbac.authorization.k8s.io/v1
162
+
kind: ClusterRoleBinding
163
+
metadata:
164
+
name: mutatingwebhookconfiguration-patcher
165
+
roleRef:
166
+
apiGroup: rbac.authorization.k8s.io
167
+
kind: ClusterRole
168
+
name: mutatingwebhookconfiguration-patcher
169
+
subjects:
170
+
- kind: ServiceAccount
171
+
name: mutatingwebhook-patcher
172
+
namespace: patch-operator
173
+
```
174
+
175
+
Next, apply the following _Patch_ resource which will look up the `Secret` the OLM created containing the CA used by the webhook
Note that the `targetObjectRef` uses a _Label Selector_ to query for _MutatingWebhookConfigurations_ with the label `redhat-cop.redhat.io/patch-operator: "true"`.
204
+
205
+
The following is an example of a _MutatingWebhookConfiguration_ with the required label that can be used to support the creation time webhook.
120
206
121
207
```yaml
208
+
---
122
209
apiVersion: admissionregistration.k8s.io/v1
123
210
kind: MutatingWebhookConfiguration
124
211
metadata:
125
212
name: patch-operator-inject
126
-
annotations:
127
-
service.beta.openshift.io/inject-cabundle: "true"
213
+
labels:
214
+
redhat-cop.redhat.io/patch-operator: "true"
128
215
webhooks:
129
216
- admissionReviewVersions:
130
217
- v1
131
218
clientConfig:
132
219
service:
133
-
name: patch-operator-webhook-service
220
+
name: patch-operator-controller-manager-service
134
221
namespace: patch-operator
135
222
path: /inject
223
+
caBundle: Cg==
136
224
failurePolicy: Fail
137
225
name: patch-operator-inject.redhatcop.redhat.io
138
226
rules:
139
227
- << add your intercepted objects here >>
140
228
sideEffects: None
141
229
```
142
230
231
+
#### Enabling creation time time webhook (Helm)
232
+
143
233
If you installed the operator via the Helm chart and are using cert-manager, use the following webhook template:
144
234
145
235
```yaml
@@ -164,7 +254,11 @@ webhooks:
164
254
sideEffects: None
165
255
```
166
256
167
-
You should need to enable the webhook only for `CREATE` operations. So for example to enable the webhook on configmaps:
257
+
No additional steps are needed since as cert-manager manages setting the `caBundle` field on the MutatingWebhookConfiguration
258
+
259
+
#### Webhook rules
260
+
261
+
For the rules that apply to webhooks, you should need to enable the webhook only for `CREATE` operations. So for example to enable the webhook on configmaps:
0 commit comments