4.7.2.3. Admission Webhook 示例
以下是一个准入 Webhook 示例,它将不允许在命名空间被保留时创建命名空间 :
apiVersion: admissionregistration.k8s.io/v1beta1 kind: ValidatingWebhookConfiguration metadata: name: namespacereservations.admission.online.openshift.io webhooks: - name: namespacereservations.admission.online.openshift.io clientConfig: service: namespace: default name: webhooks path: /apis/admission.online.openshift.io/v1beta1/namespacereservations caBundle: KUBE_CA_HERE rules: - operations: - CREATE apiGroups: - "" apiVersions: - "b1" resources: - namespaces failurePolicy: Ignore
以下是一个由名为 webhook 的准入 webhook 评估的 pod 示例:
apiVersion: v1 kind: Pod metadata: labels: role: webhook name: webhook spec: containers: - name: webhook image: myrepo/myimage:latest imagePullPolicy: IfNotPresent ports: - containerPort: 8000
以下是 webhook 的前端服务:
apiVersion: v1 kind: Service metadata: labels: role: webhook name: webhook spec: ports: - port: 443 targetPort: 8000 selector: role: webhook