Skip to content

Commit 9dadfb2

Browse files
committed
Add OLM webhook support
1 parent 79d8dbe commit 9dadfb2

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

_topic_map.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,9 @@ Topics:
708708
- Name: Creating policy for Operator installations and upgrades
709709
File: olm-creating-policy
710710
Distros: openshift-origin,openshift-enterprise,openshift-webscale
711+
- Name: Managing admission webhooks in OLM
712+
File: olm-webhooks
713+
Distros: openshift-origin,openshift-enterprise,openshift-webscale
711714
- Name: Managing custom catalogs
712715
File: olm-managing-custom-catalogs
713716
Distros: openshift-origin,openshift-enterprise,openshift-webscale
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * operators/olm-webhooks.adoc
4+
5+
[id="olm-defining-csv-webhook_{context}"]
6+
= Defining webhooks in a CSV
7+
8+
The ClusterServiceVersion (CSV) resource includes a `webhookdefinitions` section
9+
to define validating and mutating admission webhooks that ship with an Operator.
10+
For example:
11+
12+
.CSV containing a validating admission webhook
13+
[source,yaml]
14+
----
15+
apiVersion: operators.coreos.com/v1alpha1
16+
kind: ClusterServiceVersion
17+
metadata:
18+
annotations:
19+
description: |-
20+
An example CSV that contains a webhook
21+
name: example-webhook.v1.0.0
22+
namespace: placeholder
23+
spec:
24+
webhookdefinitions:
25+
- generateName: example.webhook.com
26+
type: ValidatingAdmissionWebhook
27+
deploymentName: "example-webhook-deployment"
28+
containerPort: 443
29+
sideEffects: "None"
30+
failurePolicy: "Ignore"
31+
admissionReviewVersions:
32+
- "v1"
33+
- "v1beta1"
34+
rules:
35+
- operations:
36+
- "CREATE"
37+
apiGroups:
38+
- ""
39+
apiVersions:
40+
- "v1"
41+
resources:
42+
- "configmaps"
43+
objectSelector:
44+
foo: bar
45+
webhookPath: "/validate"
46+
...
47+
----
48+
49+
OLM requires that you define the following:
50+
51+
* The `type` field must be set to either `ValidatingAdmissionWebhook` or
52+
`MutatingAdmissionWebhook`, or the CSV will be placed in a failed phase. * The
53+
CSV must contain a Deployment whose name is equivalent to the value supplied in
54+
the `deploymentName` field of the `webhookdefinition`.
55+
56+
When the webhook is created, OLM ensures that the webhook only acts upon
57+
namespaces that match the OperatorGroup that the Operator is deployed in.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * operators/olm-webhooks.adoc
4+
5+
[id="olm-webhook-considerations_{context}"]
6+
= Webhook considerations
7+
8+
When developing an admission webhook to be managed by OLM, consider the
9+
following constraints:
10+
11+
[discrete]
12+
[id="olm-webhook-ca_{context}"]
13+
=== Certificate authority constraints
14+
15+
OLM is configured to provide each Deployment with a single certificate authority
16+
(CA). The logic that generates and mounts the CA into the Deployment was
17+
originally used by the APIService lifecycle logic. As a result:
18+
19+
* The TLS certificate file is mounted to the Deployment at
20+
`/apiserver.local.config/certificates/apiserver.crt`.
21+
* The TLS key file is mounted to the Deployment at
22+
`/apiserver.local.config/certificates/apiserver.key`.
23+
24+
[discrete]
25+
[id="olm-webhook-rules_{context}"]
26+
=== Admission webhook rules constraints
27+
28+
To prevent an Operator from configuring the cluster into an unrecoverable state,
29+
OLM places the CSV in the failed phase if the rules defined in an admission
30+
webhook intercept any of the following requests:
31+
32+
* Requests that target all groups
33+
* Requests that target the `operators.coreos.com` group
34+
* Requests that target the `ValidatingWebhookConfigurations` or
35+
`MutatingWebhookConfigurations` resources

operators/olm-webhooks.adoc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[id="olm-webhooks"]
2+
= Managing admission webhooks in Operator Lifecycle Manager
3+
include::modules/common-attributes.adoc[]
4+
:context: olm-webhooks
5+
6+
toc::[]
7+
8+
Validating and mutating admission webhooks allow Operator authors to intercept,
9+
modify, and accept or reject resources before they are handled by the Operator
10+
controller. Operator Lifecycle Manager (OLM) can manage the lifecycle of these
11+
webhooks when they are shipped alongside your Operator.
12+
13+
include::modules/olm-defining-csv-webhooks.adoc[leveloffset=+1]
14+
include::modules/olm-webhook-considerations.adoc[leveloffset=+1]
15+
16+
[id="olm-webhooks-additional-resources"]
17+
== Additional resources
18+
19+
* xref:../architecture/admission-plug-ins.adoc#admission-webhook-types_admission-plug-ins[Types of webhook admission plug-ins]

0 commit comments

Comments
 (0)