add webhook
This commit is contained in:
33
config/webhook/kustomizeconfig.yaml
Normal file
33
config/webhook/kustomizeconfig.yaml
Normal file
@@ -0,0 +1,33 @@
|
||||
# the following config is for teaching kustomize where to look at when substituting vars.
|
||||
# It requires kustomize v2.1.0 or newer to work properly.
|
||||
nameReference:
|
||||
- kind: Service
|
||||
version: v1
|
||||
fieldSpecs:
|
||||
- kind: CustomResourceDefinition
|
||||
version: v1
|
||||
group: apiextensions.k8s.io
|
||||
path: spec/conversion/webhook/clientConfig/service/name
|
||||
- kind: MutatingWebhookConfiguration
|
||||
group: admissionregistration.k8s.io
|
||||
path: webhooks/clientConfig/service/name
|
||||
- kind: ValidatingWebhookConfiguration
|
||||
group: admissionregistration.k8s.io
|
||||
path: webhooks/clientConfig/service/name
|
||||
|
||||
namespace:
|
||||
- kind: CustomResourceDefinition
|
||||
version: v1
|
||||
group: apiextensions.k8s.io
|
||||
path: spec/conversion/webhook/clientConfig/service/namespace
|
||||
- kind: MutatingWebhookConfiguration
|
||||
group: admissionregistration.k8s.io
|
||||
path: webhooks/clientConfig/service/namespace
|
||||
create: true
|
||||
- kind: ValidatingWebhookConfiguration
|
||||
group: admissionregistration.k8s.io
|
||||
path: webhooks/clientConfig/service/namespace
|
||||
create: true
|
||||
|
||||
varReference:
|
||||
- path: metadata/annotations
|
||||
22
config/webhook/manager_patch.yaml
Normal file
22
config/webhook/manager_patch.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: controller
|
||||
namespace: system
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
monitor.demo.io/inject: "false"
|
||||
spec:
|
||||
containers:
|
||||
- name: manager
|
||||
ports:
|
||||
- name: webhook-server
|
||||
containerPort: 9443
|
||||
volumeMounts:
|
||||
- name: webhook
|
||||
mountPath: /tmp/webhook
|
||||
volumes:
|
||||
- name: webhook
|
||||
emptyDir: {}
|
||||
70
config/webhook/manifests.yaml
Normal file
70
config/webhook/manifests.yaml
Normal file
@@ -0,0 +1,70 @@
|
||||
apiVersion: admissionregistration.k8s.io/v1
|
||||
kind: MutatingWebhookConfiguration
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: mutating-webhook-configuration
|
||||
webhooks:
|
||||
- admissionReviewVersions:
|
||||
- v1beta1
|
||||
- v1
|
||||
clientConfig:
|
||||
service:
|
||||
name: webhook-service
|
||||
namespace: system
|
||||
path: /mutate--v1-pod
|
||||
failurePolicy: Fail
|
||||
name: namespace.injector.kb.io
|
||||
namespaceSelector:
|
||||
matchExpressions:
|
||||
- key: monitor-injection
|
||||
operator: In
|
||||
values:
|
||||
- enabled
|
||||
objectSelector:
|
||||
matchExpressions:
|
||||
- key: monitor.demo.io/inject
|
||||
operator: NotIn
|
||||
values:
|
||||
- "false"
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
apiVersions:
|
||||
- v1
|
||||
operations:
|
||||
- CREATE
|
||||
resources:
|
||||
- pods
|
||||
scope: '*'
|
||||
sideEffects: None
|
||||
- admissionReviewVersions:
|
||||
- v1beta1
|
||||
- v1
|
||||
clientConfig:
|
||||
service:
|
||||
name: webhook-service
|
||||
namespace: system
|
||||
path: /mutate--v1-pod
|
||||
failurePolicy: Fail
|
||||
name: object.injector.kb.io
|
||||
namespaceSelector:
|
||||
matchExpressions:
|
||||
- key: monitor-injection
|
||||
operator: DoesNotExist
|
||||
objectSelector:
|
||||
matchExpressions:
|
||||
- key: monitor.demo.io/inject
|
||||
operator: In
|
||||
values:
|
||||
- "true"
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
apiVersions:
|
||||
- v1
|
||||
operations:
|
||||
- CREATE
|
||||
resources:
|
||||
- pods
|
||||
scope: '*'
|
||||
sideEffects: None
|
||||
12
config/webhook/service.yaml
Normal file
12
config/webhook/service.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: webhook-service
|
||||
namespace: system
|
||||
spec:
|
||||
selector:
|
||||
component: controller
|
||||
ports:
|
||||
- port: 443
|
||||
targetPort: 9443
|
||||
Reference in New Issue
Block a user