Skip to content

Commit 73a976e

Browse files
authored
Merge pull request #204 from RedisLabs/randv1r-update-limiting-webhook-in-public-README-RED-66126
RED-66126 - Adding "Limiting Webhooks" section in Openshift README
2 parents b879006 + 5dbb8c8 commit 73a976e

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

README.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,47 @@ Other custom configurations are referenced in this repository.
284284
admissionReviewVersions: ["v1beta1"]
285285
EOF
286286
# patch webhook with caBundle
287-
kubectl patch ValidatingWebhookConfiguration redb-admission --patch "$(cat modified-webhook.yaml)"
287+
oc patch ValidatingWebhookConfiguration redb-admission --patch "$(cat modified-webhook.yaml)"
288288
```
289+
> **Note:** If you're not using multiple namespaces you may skip to ["Verify the installation"](#verify_admission_installation_openshift) step.
290+
291+
* Limiting the webhook to the relevant namespaces:
292+
Unless limited, webhooks will intercept requests from all namespaces.<br>
293+
In case you have several REC objects on your K8S cluster you need to limit the webhook to the relevant namespace.
294+
This is done by adding a `namespaceSelector` to the webhook spec that targets a label found on the namespace.<br>
295+
296+
* First, make sure you have such a relevant label on the namespace and that it is unique for this namespace. e.g.
297+
298+
```yaml
299+
apiVersion: v1
300+
kind: Namespace
301+
metadata:
302+
labels:
303+
namespace-name: staging
304+
name: staging
305+
```
306+
307+
* Then, patch the webhook with a namespaceSelector. See this example:
308+
```shell script
309+
cat > modified-webhook.yaml <<EOF
310+
webhooks:
311+
- name: redb.admission.redislabs
312+
namespaceSelector:
313+
matchLabels:
314+
namespace-name: staging
315+
EOF
316+
```
317+
318+
* apply the patch:
319+
```shell script
320+
oc patch ValidatingWebhookConfiguration redb-admission --patch "$(cat modified-webhook.yaml)"
321+
```
322+
<a name="verify_admission_installation_openshift"></a>
289323
* Verify the installation
290324
In order to verify that the all the components of the Admission Controller are installed correctly, we will try to apply an invalid resource that should force the admission controller to reject it. If it applies succesfully, it means the admission controller has not been hooked up correctly.
291325
292326
```shell script
293-
$ kubectl apply -f - << EOF
327+
$ oc apply -f - << EOF
294328
apiVersion: app.redislabs.com/v1alpha1
295329
kind: RedisEnterpriseDatabase
296330
metadata:
@@ -322,7 +356,7 @@ Other custom configurations are referenced in this repository.
322356
323357
memorySize: 100MB
324358
EOF
325-
kubectl apply -f /tmp/redis-enterprise-database.yml
359+
oc apply -f /tmp/redis-enterprise-database.yml
326360
```
327361
Replace the name of the cluster with the one used on the current namespace.
328362
All REDB configuration options are documented [here](redis_enterprise_database_api.md).

0 commit comments

Comments
 (0)