apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: key-generator
    version: "1.0"
  name: key-generator
spec:
  replicas: 1
  selector:
    matchLabels:
      app: key-generator
  strategy:
    rollingUpdate:
      maxSurge: 34%
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: key-generator
    spec:
      containers:
        - name: key-generator
          image: key-generator-service:1
          env:
          - name: MONGO_INITDB_DATABASE
            value: url
          - name: MONGO_INITDB_ROOT_USERNAME
            valueFrom:
              secretKeyRef:
                name: mongodb-root-rw-secret
                key: MONGO_ROOT_USERNAME
          - name: MONGO_INITDB_ROOT_PASSWORD
            valueFrom:
              secretKeyRef:
                name: mongodb-root-rw-secret
                key: MONGO_ROOT_PASSWORD
          imagePullPolicy: Never
          livenessProbe:
            httpGet:
              path: /actuator/info
              port: 8080
          readinessProbe:
            httpGet:
              path: /actuator/health
              port: 8080
          ports:
          - name: http
            containerPort: 8080
            protocol: TCP
          volumeMounts:
          - name: mongodb-root-rw-secret
            mountPath: /etc/secret
            readOnly: true
          resources:
            limits:
              cpu: "2"
              memory: 1Gi
            requests:
              cpu: 256m
              memory: 1Gi
      volumes:
      - name: mongodb-root-rw-secret
        secret:
          secretName: mongodb-root-rw-secret
          items:
            - key: MONGO_ROOT_USERNAME
              path: admin/MONGO_ROOT_USERNAME
              mode: 0444 # Octal read only
            - key: MONGO_ROOT_PASSWORD
              path: admin/MONGO_ROOT_PASSWORD
              mode: 0444 # Octal read only