apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
  name: dynatrace-webhook
  labels:
    dynatrace.com/operator: dynakube
    internal.dynatrace.com/component: webhook
webhooks:
  - name: webhook.pod.dynatrace.com
    reinvocationPolicy: IfNeeded
    failurePolicy: Ignore
    timeoutSeconds: 2
    rules:
      - apiGroups: [ "" ]
        apiVersions: [ "v1" ]
        operations: [ "CREATE" ]
        resources: [ "pods" ]
        scope: Namespaced
    namespaceSelector:
      matchExpressions:
        - key: dynakube.internal.dynatrace.com/instance
          operator: Exists
    clientConfig:
      service:
        name: dynatrace-webhook
        namespace: dynatrace
        path: /inject
    admissionReviewVersions: [ "v1beta1", "v1" ]
    sideEffects: None
  - name: webhook.ns.dynatrace.com
    reinvocationPolicy: IfNeeded
    failurePolicy: Ignore
    timeoutSeconds: 2
    rules:
      - apiGroups: [ "" ]
        apiVersions: [ "v1" ]
        operations: [ "CREATE", "UPDATE"]
        resources: [ "namespaces" ]
        scope: Cluster
    clientConfig:
      service:
        name: dynatrace-webhook
        namespace: dynatrace
        path: /label-ns
    admissionReviewVersions: [ "v1beta1", "v1" ]
    sideEffects: None
