apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "openshift-console-plugin.fullname" . }}
  labels:
    {{- include "openshift-console-plugin.labels" . | nindent 4 }}
spec:
  replicas: 1
  selector:
    matchLabels:
      {{- include "openshift-console-plugin.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        {{- include "openshift-console-plugin.selectorLabels" . | nindent 8 }}
    spec:
      serviceAccountName: {{ include "openshift-console-plugin.fullname" . }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      containers:
        - name: {{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.plugin.image }}"
          imagePullPolicy: Always
          ports:
            - name: http
              containerPort: {{ .Values.plugin.port }}
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /health
              port: http
            initialDelaySeconds: 30
            periodSeconds: 10
            timeoutSeconds: 3
          resources:
            {{- toYaml .Values.plugin.resources | nindent 12 }}
          env:
            - name: PLUGIN_NAME
              value: {{ .Values.plugin.name }}
            - name: PLUGIN_PORT
              value: "{{ .Values.plugin.port }}"
            - name: BASE_PATH
              value: {{ .Values.plugin.basePath }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
