{{- /*
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
*/ -}}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "slingcms-standalone.fullname" . }}
  labels:
    {{- include "slingcms-standalone.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
{{- end }}
  selector:
    matchLabels:
      {{- include "slingcms-standalone.selectorLabels" . | nindent 6 }}
  template:
    metadata:
    {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
    {{- end }}
      labels:
        {{- include "slingcms-standalone.selectorLabels" . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "slingcms-standalone.serviceAccountName" . }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      containers:
        - name: {{ printf "%s-cms" .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.image.cms.repository }}:{{ .Values.image.cms.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.cms.pullPolicy }}
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
          livenessProbe:
            initialDelaySeconds: {{ .Values.livenessProbe.cms.initialDelaySeconds }}
            periodSeconds: {{ .Values.livenessProbe.cms.periodSeconds }}
            timeoutSeconds: {{ .Values.livenessProbe.cms.timeoutSeconds }}
            successThreshold: {{ .Values.livenessProbe.cms.successThreshold }}
            failureThreshold: {{ .Values.livenessProbe.cms.failureThreshold }}
            httpGet:
              path: /system/health
              port: http
          readinessProbe:
            initialDelaySeconds: {{ .Values.readinessProbe.cms.initialDelaySeconds }}
            periodSeconds: {{ .Values.readinessProbe.cms.periodSeconds }}
            timeoutSeconds: {{ .Values.readinessProbe.cms.timeoutSeconds }}
            successThreshold: {{ .Values.readinessProbe.cms.successThreshold }}
            failureThreshold: {{ .Values.readinessProbe.cms.failureThreshold }}
            httpGet:
              path: /system/health
              port: http
          resources:
            {{- toYaml .Values.resources.cms | nindent 12 }}
        - name: {{ printf "%s-web" .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.image.web.repository }}:{{ .Values.image.web.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.web.pullPolicy }}
          env:
            - name: AUTHOR_URL
              value: localhost
            - name: RENDERER_URL
              value: localhost
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
          livenessProbe:
            initialDelaySeconds: {{ .Values.livenessProbe.web.initialDelaySeconds }}
            periodSeconds: {{ .Values.livenessProbe.web.periodSeconds }}
            timeoutSeconds: {{ .Values.livenessProbe.web.timeoutSeconds }}
            successThreshold: {{ .Values.livenessProbe.web.successThreshold }}
            failureThreshold: {{ .Values.livenessProbe.web.failureThreshold }}
            httpGet:
              path: /
              port: http
          readinessProbe:
            initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
            periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
            timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
            successThreshold: {{ .Values.readinessProbe.successThreshold }}
            failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
            httpGet:
              path: /
              port: http
          resources:
            {{- toYaml .Values.resources.web | 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 }}