apiVersion: apps/v1
kind: Deployment
metadata:
  name: flask-realworld-example-app
  labels:
    app: flask-realworld-example-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: flask-realworld-example-app
  template:
    metadata:
      labels:
        app: flask-realworld-example-app
    spec:
      initContainers:
        - name: upgrade-db
          envFrom:
            - configMapRef:
                name: flask-config
          image: willischou/flask-realworld-example-app:{{.Env.VERSION}}
          command: ['sh', '-c', 'flask db upgrade']
      containers:
        - name: flask-realworld-example-app
          image: willischou/flask-realworld-example-app:{{.Env.VERSION}}
          envFrom:
            - configMapRef:
                name: flask-config
          ports:
            - containerPort: 5000
              protocol: TCP
          readinessProbe:
            httpGet:
              path: /api/articles
              port: 5000
            initialDelaySeconds: 15
            periodSeconds: 10
            timeoutSeconds: 2
          livenessProbe:
            httpGet:
              path: /api/articles
              port: 5000
            initialDelaySeconds: 15
            periodSeconds: 20
            timeoutSeconds: 2
          resources:
            requests:
              memory: "128Mi"
              cpu: "100m"
