apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "nsx-ncp-operator.fullname" . }}
  labels:
    {{- include "nsx-ncp-operator.labels" . | nindent 4 }}
spec:
  replicas: 1
  selector:
    matchLabels:
      {{- include "nsx-ncp-operator.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        {{- include "nsx-ncp-operator.selectorLabels" . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      hostNetwork: true
      serviceAccountName: {{ include "nsx-ncp-operator.serviceAccountName" . }}
      volumes:
      - hostPath: {path: /etc/os-release}
        name: host-os-release
      containers:
        - name: nsx-ncp-operator
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          command: ["/bin/bash", "-c", "nsx-ncp-operator --zap-time-encoding=iso8601"]
          volumeMounts:
          - {mountPath: /host/etc/os-release, name: host-os-release}
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: OPERATOR_NAME
              value: "nsx-ncp-operator"
            - name: NCP_IMAGE
              value: "{{ .Values.ncp.image }}"
            - name: WATCH_NAMESPACE
              value: "{{ .Release.Namespace }}"
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}