apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: pythonflask
spec:
  serviceName: pythonflask
  replicas: 2
  selector:
    matchLabels:
      app: pythonflask
  template:
    metadata:
      labels:
        app: pythonflask
      annotations:
        rollme: "1"
    spec:
      initContainers:
        - name: initpv
          image: 'quay.io/worsco/ocp4-exp01-initcont:latest'
          resources:
            requests:
              memory: 96Mi
            limits:
              memory: 256Mi
          env:
            - name: AWS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: initcont-aws-ro
                  key: AWS_ACCESS_KEY_ID
            - name: AWS_SECRET_ACCESS_KEY
              valueFrom:
                secretKeyRef:
                  name: initcont-aws-ro
                  key: AWS_SECRET_ACCESS_KEY
            - name: AWS_DEFAULT_REGION
              valueFrom:
                secretKeyRef:
                  name: initcont-aws-ro
                  key: AWS_DEFAULT_REGION
            - name: S3BUCKET
              valueFrom:
                configMapKeyRef:
                  name: ocp4-exp01-initcont
                  key: S3BUCKET
            - name: S3BUCKETNAME
              valueFrom:
                configMapKeyRef:
                  name: ocp4-exp01-initcont
                  key: S3BUCKETNAME
            - name: S3FOLDER
              valueFrom:
                configMapKeyRef:
                  name: ocp4-exp01-initcont
                  key: S3FOLDER
          volumeMounts:
            - name: www
              mountPath: /usr/share/html
      terminationGracePeriodSeconds: 10
      containers:
        - name: pythonflask
          image: 'quay.io/worsco/ocp4-exp01-web:latest'
          resources:
              requests:
                memory: 144Mi
              limits:
                memory: 256Mi
          env:
            - name: MYDATA_SOURCE_DIR
              valueFrom:
                configMapKeyRef:
                  name: ocp4-exp01-web
                  key: MYDATA_SOURCE_DIR
            - name: MYTEMPLATE_SOURCE_DIR
              valueFrom:
                configMapKeyRef:
                  name: ocp4-exp01-web
                  key: MYTEMPLATE_SOURCE_DIR
          ports:
            - containerPort: 8080
              name: web
          volumeMounts:
            - name: www
              mountPath: /usr/share/html
  volumeClaimTemplates:
    - metadata:
        name: www
      spec:
        accessModes:
          - ReadWriteOnce
        storageClassName: gp2
        resources:
          requests:
            storage: 1Gi
