apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "spring-cloud-config-server.fullname" . }}
  labels:
    {{- include "spring-cloud-config-server.labels" . | nindent 4 }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "spring-cloud-config-server.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        {{- include "spring-cloud-config-server.labels" . | nindent 8 }}
        {{- with .Values.podLabels }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
    spec:
      {{- with .Values.image.pullSecrets }}
      imagePullSecrets:
        {{- range . }}
        - name: {{ . }}
        {{- end }}
      {{- end }}
      containers:
        - name: {{ include "spring-cloud-config-server.name" . }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: {{ .Values.service.targetPort }}
              protocol: TCP
          env:
            - name: SERVER_PORT
              value: {{ .Values.service.targetPort | quote }}
            - name: CONFIG_GIT_URI
              value: {{ .Values.app.configGitUri | quote }}
            - name: CONFIG_GIT_USERNAME
              value: {{ .Values.app.configGitUsername | quote }}
            - name: CONFIG_GIT_DEFAULT_LABEL
              value: {{ .Values.app.configGitDefaultLabel | quote }}
            - name: CONFIG_GIT_SEARCH_PATHS
              value: {{ .Values.app.configGitSearchPaths | quote }}
            - name: CONFIG_GIT_SKIP_SSL_VALIDATION
              value: {{ .Values.app.configGitSkipSslValidation | quote }}
            - name: CONFIG_GIT_TOKEN
              valueFrom:
                secretKeyRef:
                  name: {{ .Values.gitTokenSecret.name | quote }}
                  key: {{ .Values.gitTokenSecret.key | quote }}
            {{- with .Values.extraEnv }}
            {{- toYaml . | nindent 12 }}
            {{- end }}
          readinessProbe:
            httpGet:
              path: /actuator/health
              port: http
            initialDelaySeconds: 20
            periodSeconds: 15
            timeoutSeconds: 5
          livenessProbe:
            httpGet:
              path: /actuator/health
              port: http
            initialDelaySeconds: 40
            periodSeconds: 20
            timeoutSeconds: 5
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
