apiVersion: apps/v1
kind: Deployment
metadata:	
  namespace: {{ .Release.Namespace }}
  labels:
    app: {{ include "openslice.fullname" . }}
    org.etsi.osl.service: cridge
    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    {{- include "openslice.labels" . | nindent 4 }}
  name: {{ include "openslice.fullname" . }}-cridge
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ include "openslice.fullname" . }}
      org.etsi.osl.service: cridge
      {{- include "openslice.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        app: {{ include "openslice.fullname" . }}
        org.etsi.osl.service: cridge
        {{- include "openslice.selectorLabels" . | nindent 8 }}
    spec:
      containers:
        - image: "{{ .Values.image.cridge.repository }}:{{ .Values.image.cridge.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.cridge.pullPolicy | default "Always" }}
          name: {{ include "openslice.fullname" . }}-cridge
          env:
            - name: SPRING_APPLICATION_JSON
              value: >-
                {
                  "spring.activemq.brokerUrl": "{{ .Values.oscreds.activemq.brokerUrl }}",  
                  "spring.activemq.user": "{{ .Values.oscreds.activemq.user }}", 
                  "spring.activemq.password": "{{ .Values.oscreds.activemq.password }}",
                  "logging.level.org.springframework" : "{{ .Values.spring.logLevel | default "INFO" }}",
                  "logging.level.org.etsi.osl.cridge" : "{{ .Values.logLevel | default "INFO" }}" 
                }
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
          securityContext:
            {{- if .Values.securityContext.enabled }}
            allowPrivilegeEscalation: {{ .Values.securityContext.allowPrivilegeEscalation }}
            capabilities:
              drop: {{ .Values.securityContext.capabilities.drop }}
            seccompProfile:
              type: {{ .Values.securityContext.seccompProfile.type }}
            {{- end }}
          volumeMounts:
            - name: kubeconfig
              readOnly: true
              mountPath: /root/.kube
      restartPolicy: Always
      volumes:
        - name: kubeconfig
          secret:
            secretName: {{ include "openslice.fullname" . }}-kubeconfig
