---
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: istio-operator
  name: istio-operator
spec:
  replicas: 1
  selector:
    matchLabels:
      name: istio-operator
  template:
    metadata:
      labels:
        name: istio-operator
        app.kubernetes.io/name: istio-operator
        app.kubernetes.io/instance: istio-operator-{{ .Values.image.tag }} 
        app.kubernetes.io/version: "{{ .Values.image.tag }}"
        app.kubernetes.io/component: service-mesh
        app.kubernetes.io/managed-by: helm
    spec:
      serviceAccountName: istio-operator
      containers:
        - name: istio-operator
          image: "{{ .Values.image.registry }}/{{ .Values.image.name }}:{{ .Values.image.tag }}"
          command:
          - operator
          - server
          imagePullPolicy: IfNotPresent
          resources:
            limits:
              cpu: 200m
              memory: 256Mi
            requests:
              cpu: 50m
              memory: 128Mi
          env:
            - name: WATCH_NAMESPACE
              value: "istio-system"
            - name: LEADER_ELECTION_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: OPERATOR_NAME
              value: "istio-operator"
            - name: WAIT_FOR_RESOURCES_TIMEOUT
              value: 300s
