apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "clearml.name" . }}-apps-pt
data:
  template.yaml: |
    apps_queue:
      apiVersion: v1
      metadata:
        namespace: {{ $.Release.Namespace }}
      spec:
        {{- if $.Values.imageCredentials.enabled }}
        imagePullSecrets:
        {{- if $.Values.imageCredentials.existingSecret }}
          - name: {{ $.Values.imageCredentials.existingSecret }}
        {{- else }}
          - name: clearml-registry-key
        {{- end }}
        {{- end }}
        serviceAccountName: "clearml-apps-sa"
        securityContext:
          {{ toYaml .Values.enterpriseFeatures.clearmlApplications.podSecurityContext | nindent 10 }}
        volumes:
          {{- if .Values.enterpriseFeatures.clearmlApplications.fileMounts }}
          - name: filemounts
            secret:
              secretName: {{ include "clearml.name" . }}-apps-fm
          {{- end }}
        containers:
        - resources:
          ports:
            - containerPort: 10022
          volumeMounts:
            {{- range .Values.enterpriseFeatures.clearmlApplications.fileMounts }}
            - name: filemounts
              mountPath: "{{ .folderPath }}/{{ .name }}"
              subPath: "{{ .name }}"
              readOnly: true
            {{- end }}
          env:
          - name: CLEARML_API_HOST
            value: "http://{{ include "apiserver.referenceName" . }}:{{ .Values.apiserver.service.port }}"
          - name: CLEARML_FILES_HOST
            value: "http://{{ include "fileserver.referenceName" . }}:{{ .Values.fileserver.service.port }}"
          - name: CLEARML_WEB_HOST
            value: "http://{{ include "webserver.referenceName" . }}:{{ .Values.webserver.service.port }}"
          {{- if .Values.enterpriseFeatures.clearmlApplications.extraEnvs }}
          {{ toYaml .Values.enterpriseFeatures.clearmlApplications.extraEnvs | nindent 10 }}
          {{- end }}
          securityContext:
            {{ toYaml .Values.enterpriseFeatures.clearmlApplications.containerSecurityContext | nindent 12 }}