apiVersion: apps/v1
kind: Deployment
metadata:
  name: sidecar-injector
  labels:
    app: sidecar-injector
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sidecar-injector
  template:
    metadata:
      labels:
        app: sidecar-injector
    spec:
      serviceAccountName: sidecar-injector
      containers:
        - name: sidecar-injector
          image: sidecar-injector
          imagePullPolicy: Always
          args:
          - -service-name=sidecar-injector
          - -sidecar-config-file=/etc/webhook/config/sidecarconfig.yaml
          env:
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "/prestop.sh"]
          volumeMounts:
          - name: webhook-config
            mountPath: /etc/webhook/config
      volumes:
      - name: webhook-config
        configMap:
          name: sidecar-injector
