apiVersion: apps/v1
kind: Deployment
metadata:
  name: server
spec:
  selector: {}
  replicas: 1
  template:
    metadata:
      name: server
    spec:
      containers:
        - name: server
          image: $DOCKER_IMAGE
          env:
            - name: SPRING_PROFILES_ACTIVE
              value: production
            - name: MONGODB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: server
                  key: mongo.secret
          ports:
            - containerPort: 8080
              name: web
            - containerPort: 8081
              name: health
          livenessProbe:
            httpGet:
              port: health
              path: /health
            initialDelaySeconds: 30
            periodSeconds: 5
            timeoutSeconds: 2
          readinessProbe:
            httpGet:
              port: health
              path: /health
            initialDelaySeconds: 10
            periodSeconds: 5
            timeoutSeconds: 2
          resources:
            requests:
              cpu: 50m
#      initContainers:
#        - name: mongo-init
#          image: mongo
#          command: [bash, -c, 'mongo mongodb://mongo-0.mongo < /bin/init-mongo.js']
#          volumeMounts:
#            - mountPath: /bin/init-mongo.js
#              name: init-mongo
#              subPath: init-mongo.js
#          env:
#            - name: MONGO_INITDB_ROOT_USERNAME
#              value: pandemieduell
#            - name: MONGO_INITDB_ROOT_PASSWORD
#              valueFrom:
#                secretKeyRef:
#                  name: server
#                  key: mongo.secret
      volumes:
        - name: init-mongo
          configMap:
            name: init-mongo


  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
