apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: todo-app
  name: todo-app
  namespace: todo-app-ns
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: todo-app
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: todo-app
    spec:
      containers:
        - name: be-todos
          image: be-todos
          imagePullPolicy: Always
          readinessProbe:
            initialDelaySeconds: 90
            periodSeconds: 5
            httpGet:
               path: /todo
               port: 9999
          livenessProbe:
            initialDelaySeconds: 90
            periodSeconds: 5
            httpGet:
               path: /todo
               port: 9999
          resources:
            requests:
              memory: "250Mi"
              cpu: "250m"
            limits:
              memory: "500Mi"
              cpu: "350m"
          env:
            - name: spring.datasource.url
              valueFrom:
                secretKeyRef:
                  name: todoapp-postgress-secret
                  key: spring.datasource.url
            - name: spring.datasource.username
              #value: "wong username"
              valueFrom:
                secretKeyRef:
                  name: todoapp-postgress-secret
                  key: POSTGRES_USER
            - name: spring.datasource.password
              valueFrom:
                secretKeyRef:
                  name: todoapp-postgress-secret
                  key: POSTGRES_PASSWORD
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
        - name: fe-todos
          image: fe-todos
          resources:
            requests:
              memory: "200Mi"
              cpu: "250m"
            limits:
              memory: "300Mi"
              cpu: "350m"
          imagePullPolicy: Always
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30