apiVersion: apps/v1
kind: Deployment
metadata:
  name: ${KUBE_WEB_LABEL}
  namespace: ${CF_PROJECT}
  labels:
    app.kubernetes.io/name: ${CF_PROJECT}
    app.kubernetes.io/component: ${KUBE_WEB_LABEL}
spec:
  replicas: 2
  selector:
    matchLabels:
      app.kubernetes.io/name: ${CF_PROJECT}
      app.kubernetes.io/component: ${KUBE_WEB_LABEL}
  minReadySeconds: 10
  template:
    metadata:
      labels:
        app.kubernetes.io/name: ${CF_PROJECT}
        app.kubernetes.io/component: ${KUBE_WEB_LABEL}
    spec:
      securityContext:
        runAsUser: 999
        fsGroup: 999
      imagePullSecrets:
      - name: oss-registry
      containers:
      - name: ${KUBE_WEB_LABEL}
        image: ${DOCKER_IMAGE}
        imagePullPolicy: IfNotPresent
        command:
        - uwsgi
        args:
        - --http
        - 0.0.0.0:8000
        - --module
        - localshop.wsgi
        - --master
        - --die-on-term
        - --processes=2
        - --log-4xx
        - --log-5xx
        - --log-ioerror
        - --log-sendfile
        - --single-interpreter
        - --catch-exceptions
        envFrom:
        - secretRef:
            name: ${CF_PROJECT}-auth
        - secretRef:
            name: ${CF_PROJECT}-config
        ports:
          - name: http
            containerPort: 8000
        livenessProbe:
          httpGet:
            path: /ping/
            port: http
          initialDelaySeconds: 5
        readinessProbe:
          httpGet:
            path: /ping/
            port: http
          initialDelaySeconds: 5
        resources:
          requests:
            cpu: 100m
            memory: 512Mi
          limits:
            cpu: 300m
            memory: 512Mi
        volumeMounts:
        - name: localshop-data
          mountPath: /media
      volumes:
      - name: localshop-data
        persistentVolumeClaim:
          claimName: localshop-data
