apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: url
    version: "1.0"
  name: url
spec:
  replicas: 1
  selector:
    matchLabels:
      app: url
  strategy:
    rollingUpdate:
      maxSurge: 34%
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: url
    spec:
      containers:
        - name: url
          image: url-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