apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: istio-ingress
  labels:
    app: {{ template "istio.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
    istio: ingress
spec:
  replicas: {{ .Values.replicaCount }}
  template:
    metadata:
      labels:
        istio: ingress
      annotations:
        sidecar.istio.io/inject: "false"
    spec:
      serviceAccountName: istio-ingress-service-account
      containers:
        - name: {{ template "istio.name" . }}
          image: "{{ .Values.global.hub }}/{{ .Values.global.proxy.image }}:{{ .Values.global.tag }}"
          imagePullPolicy: {{ .Values.global.imagePullPolicy }}
          ports:
            - containerPort: 80
              containerPort: 443
          args:
          - proxy
          - ingress
          - -v
          - "2"
          - --discoveryRefreshDelay
          - '1s' #discoveryRefreshDelay
          - --drainDuration
          - '45s' #drainDuration
          - --parentShutdownDuration
          - '1m0s' #parentShutdownDuration
          - --connectTimeout
          - '10s' #connectTimeout
          - --serviceCluster
          - istio-ingress
          - --zipkinAddress
          - istio-zipkin:9411
          - --statsdUdpAddress
          - istio-mixer:9125
          - --proxyAdminPort
          - "15000"
        {{- if .Values.global.controlPlaneSecurityEnabled }}
          - --controlPlaneAuthPolicy
          - MUTUAL_TLS
          - --discoveryAddress
          - istio-pilot:15005
        {{- else }}
          - --controlPlaneAuthPolicy
          - NONE
          - --discoveryAddress
          - istio-pilot:8080
        {{- end }}
          resources:
{{ toYaml .Values.resources | indent 12 }}
          env:
          - name: POD_NAME
            valueFrom:
              fieldRef:
                apiVersion: v1
                fieldPath: metadata.name
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                apiVersion: v1
                fieldPath: metadata.namespace
          volumeMounts:
          - name: istio-certs
            mountPath: /etc/certs
            readOnly: true
          - name: ingress-certs
            mountPath: /etc/istio/ingress-certs
            readOnly: true
      volumes:
      - name: istio-certs
        secret:
          secretName: "istio.default"
          optional: true
      - name: ingress-certs
        secret:
          secretName: istio-ingress-certs
          optional: true
    {{- if .Values.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
    {{- end }}
