apiVersion: v1
kind: Service
metadata:
  name: finanzas
  namespace: finanzas
spec:
  ports:
    - name: "8000"
      port: 8000
      targetPort: 8000
  selector:
    app: finanzas
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: finanzas
  namespace: finanzas
  labels:
    app: finanzas
spec:
  replicas: 1
  selector:
    matchLabels:
      app: finanzas
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: finanzas
    spec:
      containers:
      - args:
          - gunicorn
          - misfinanzas.wsgi:application
          - --bind
          - 0.0.0.0:8000
        name: finanzas
        image: $REGISTRY/finanzas-$ARQUITECTURA:$IMG_VERSION
        env:
        - name: IMG_VERSION
          value: "$IMG_VERSION"
        - name: OPENSHIFT
          value: "False"
        - name: ENVIRONMENT
          valueFrom:
            configMapKeyRef:
              key: ENTORNO
              name: env-prod
        - name: DEBUG
          valueFrom:
            configMapKeyRef:
              key: DEBUG
              name: env-prod
#        - name: APP_VERSION
#          valueFrom:
#            configMapKeyRef:
#              key: APP_VERSION
#              name: env-prod
        - name: DATABASE
          valueFrom:
            configMapKeyRef:
              key: DATABASE
              name: env-prod
        - name: SQL_HOST
          valueFrom:
            configMapKeyRef:
              key: SQL_HOST
              name: env-prod
        - name: SQL_PORT
          valueFrom:
            configMapKeyRef:
              key: SQL_PORT
              name: env-prod
        ports:
        - containerPort: 8000
          protocol: TCP
        volumeMounts:
        - mountPath: /app/src/mediafiles
          name: finanzas-media
        - mountPath: /app/src/finanzas/migrations
          name: finanzas-finanzas-migrations
        - mountPath: /app/src/reymotausers/migrations
          name: finanzas-reymotausers-migrations

        - mountPath: /app/src/staticfiles
          name: static-volume
      imagePullSecrets:
      - name: myregistrykey
      restartPolicy: Always
      volumes:
      - name: finanzas-media
        persistentVolumeClaim:
          claimName: finanzas-media
      - name: finanzas-finanzas-migrations
        persistentVolumeClaim:
          claimName: finanzas-finanzas-migrations
      - name: finanzas-reymotausers-migrations
        persistentVolumeClaim:
          claimName: finanzas-reymotausers-migrations
      - name: static-volume
        persistentVolumeClaim:
          claimName: static-volume
status: {}
