# deploy
apiVersion: apps/v1
kind: Deployment
metadata:
  name: flask-app
  namespace: flask-app-extions-stage
  labels:
    app: flask-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: flask-app
      tier: frontend
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: flask-app
        tier: frontend
    spec:
      containers:
      - image: guomaoqiu/python27baseenv:v2
        name: flask-app
        # 在容器启动3秒后，kubelet将发送第一个readinessProbe探针，这将连接到容器的3031端口，如果探测成功，则该Pod将被标识为ready，5秒后，kubelet将进行第二次连接。
        readinessProbe:
          tcpSocket:
            port: 3031
          initialDelaySeconds: 3  # 首次检查时间
          periodSeconds: 5       # 检查时间间隔
        # 在容器启动10秒后，kubelet将发送第一个livenessProbe探针，仍然尝试连接容器的3031端口，如果连接失败则重启容器。
        livenessProbe:
          tcpSocket:
            port: 3031
          initialDelaySeconds: 10   
          periodSeconds: 15
        command: ["/usr/bin/supervisord"]
        args: ["-c","/usr/local/code/supervisord.conf"]
        #command: ["python", "/usr/local/code/manage.py"]
        env:
        - name: FLASK-APP-DB-PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql-pass
              key: password
        ports:
        - containerPort: 3031
          name: flask-app
        volumeMounts:
        - name: flask-app-persistent-storage
          mountPath: /usr/local/code
        - name: host-time
          mountPath: /etc/localtime
      volumes:
      - name: flask-app-persistent-storage
        persistentVolumeClaim:
          claimName: flask-app-data-pv-claim
      - name: host-time
        hostPath:
          path: /usr/share/zoneinfo/Asia/Shanghai
