|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# |
| 4 | +# Welcome to the webhook support with CertManager demo |
| 5 | +# |
| 6 | +trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT |
| 7 | + |
| 8 | +# enable 'WebhookProviderCertManager' feature |
| 9 | +kubectl kustomize config/overlays/featuregate/webhook-provider-certmanager | kubectl apply -f - |
| 10 | + |
| 11 | +# wait for operator-controller to become available |
| 12 | +kubectl rollout status -n olmv1-system deployment/operator-controller-controller-manager |
| 13 | + |
| 14 | +# create webhook-operator catalog |
| 15 | +cat ${DEMO_RESOURCE_DIR}/webhook-provider-certmanager/webhook-operator-catalog.yaml |
| 16 | +kubectl apply -f ${DEMO_RESOURCE_DIR}/webhook-provider-certmanager/webhook-operator-catalog.yaml |
| 17 | + |
| 18 | +# wait for catalog to be serving |
| 19 | +kubectl wait --for=condition=Serving clustercatalog/webhook-operator-catalog --timeout="60s" |
| 20 | + |
| 21 | +# create install namespace |
| 22 | +kubectl create ns webhook-operator |
| 23 | + |
| 24 | +# create installer service account |
| 25 | +kubectl create serviceaccount -n webhook-operator webhook-operator-installer |
| 26 | + |
| 27 | +# give installer service account admin privileges |
| 28 | +kubectl create clusterrolebinding webhook-operator-installer-crb --clusterrole=cluster-admin --serviceaccount=webhook-operator:webhook-operator-installer |
| 29 | + |
| 30 | +# install webhook operator clusterextension |
| 31 | +cat ${DEMO_RESOURCE_DIR}/webhook-provider-certmanager/webhook-operator-extension.yaml |
| 32 | + |
| 33 | +# apply cluster extension |
| 34 | +kubectl apply -f ${DEMO_RESOURCE_DIR}/webhook-provider-certmanager/webhook-operator-extension.yaml |
| 35 | + |
| 36 | +# wait for cluster extension installation to succeed |
| 37 | +kubectl wait --for=condition=Installed clusterextension/webhook-operator --timeout="60s" |
| 38 | + |
| 39 | +# wait for webhook-operator deployment to become available and back the webhook service |
| 40 | +kubectl wait --for=condition=Available -n webhook-operator deployments/webhook-operator-webhook |
| 41 | + |
| 42 | +# demonstrate working validating webhook |
| 43 | +cat ${DEMO_RESOURCE_DIR}/webhook-provider-certmanager/validating-webhook-test.yaml |
| 44 | + |
| 45 | +# resource creation should be rejected by the validating webhook due to bad attribute value |
| 46 | +kubectl apply -f ${DEMO_RESOURCE_DIR}/webhook-provider-certmanager/validating-webhook-test.yaml |
| 47 | + |
| 48 | +# demonstrate working mutating webhook |
| 49 | +cat ${DEMO_RESOURCE_DIR}/webhook-provider-certmanager/mutating-webhook-test.yaml |
| 50 | + |
| 51 | +# apply resource |
| 52 | +kubectl apply -f ${DEMO_RESOURCE_DIR}/webhook-provider-certmanager/mutating-webhook-test.yaml |
| 53 | + |
| 54 | +# get webhooktest resource in v1 schema - resource should have new .spec.mutate attribute |
| 55 | +kubectl get webhooktest.v1.webhook.operators.coreos.io -n webhook-operator mutating-webhook-test -o yaml |
| 56 | + |
| 57 | +# demonstrate working conversion webhook by getting webhook test resource in v2 schema - the .spec attributes should now be under the .spec.conversion stanza |
| 58 | +kubectl get webhooktest.v2.webhook.operators.coreos.io -n webhook-operator mutating-webhook-test -o yaml |
| 59 | + |
| 60 | +# this concludes the webhook support demo - Thank you! |
0 commit comments