---
# Source: consul/templates/connect-inject-deployment.yaml
# The deployment for running the Connect sidecar injector
apiVersion: apps/v1
kind: Deployment
metadata:
  name: consul-oc-consul-connect-injector-webhook-deployment
  namespace: default
  labels:
    app: consul
    chart: consul-helm
    heritage: Tiller
    release: consul-oc
spec:
  replicas: 1
  selector:
    matchLabels:
      app: consul
      chart: consul-helm
      release: consul-oc
      component: connect-injector
  template:
    metadata:
      labels:
        app: consul
        chart: consul-helm
        release: consul-oc
        component: connect-injector
      annotations:
        "consul.hashicorp.com/connect-inject": "false"
    spec:
      serviceAccountName: consul-oc-consul-connect-injector-webhook-svc-account
      containers:
        - name: sidecar-injector
          image: "hashicorp/consul-k8s:0.10.1"
          env:
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          command:
            - "/bin/sh"
            - "-ec"
            - |
              CONSUL_FULLNAME="consul-oc-consul"

              consul-k8s inject-connect \
                -default-inject=false \
                -consul-image="consul:1.6.2" \
                -consul-k8s-image="hashicorp/consul-k8s:0.10.1" \
                -listen=:8080 \
                -enable-central-config=true \
                -tls-auto=${CONSUL_FULLNAME}-connect-injector-cfg \
                -tls-auto-hosts=${CONSUL_FULLNAME}-connect-injector-svc,${CONSUL_FULLNAME}-connect-injector-svc.${NAMESPACE},${CONSUL_FULLNAME}-connect-injector-svc.${NAMESPACE}.svc
          livenessProbe:
            httpGet:
              path: /health/ready
              port: 8080
              scheme: HTTPS
            failureThreshold: 2
            initialDelaySeconds: 1
            periodSeconds: 2
            successThreshold: 1
            timeoutSeconds: 5
          readinessProbe:
            httpGet:
              path: /health/ready
              port: 8080
              scheme: HTTPS
            failureThreshold: 2
            initialDelaySeconds: 2
            periodSeconds: 2
            successThreshold: 1
            timeoutSeconds: 5
