apiVersion: apps/v1
kind: Deployment
metadata:
  name: trgenerator
  namespace: <NS>
  labels:
    app: trgenerator
    app.kubernetes.io/part-of: trgenerator
spec:
  replicas: 1
  selector:
    matchLabels:
      app: trgenerator
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: trgenerator
    spec:
      containers:
      - name: trgenerator
        image: <REGISTRO>/trgenerator:<TAG>
        env:
        - name: IMG_VERSION
          value: "<TAG>"
        - name: DEBUG
          valueFrom:
            configMapKeyRef:
              key: DEBUG
              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
        - name: SQL_ENGINE
          valueFrom:
            configMapKeyRef:
              key: SQL_ENGINE
              name: env-prod
        - name: SQL_DATABASE
          valueFrom:
            configMapKeyRef:
              key: SQL_DATABASE
              name: env-prod
        - name: SQL_USER
          valueFrom:
            configMapKeyRef:
              key: SQL_USER
              name: env-prod
        - name: SQL_PASSWORD
          valueFrom:
            configMapKeyRef:
              key: SQL_PASSWORD
              name: env-prod        
        ports:
        - containerPort: 8000
          protocol: TCP
        volumeMounts:
        - mountPath: /app/mediafiles
          name: trgenerator-media

        - mountPath: /app/textdocs/migrations
          name: trgenerator-textdocs-migrations

        - mountPath: /app/doc_generator/migrations
          name: trgenerator-gestionreservas-migrations

        - mountPath: /app/siemensusers/migrations
          name: trgenerator-siemensusers-migrations

        - mountPath: /app/staticfiles
          name: static-volume
      imagePullSecrets:
      - name: myregistrykey
      restartPolicy: Always
      volumes:
      - name: trgenerator-media
        persistentVolumeClaim:
          claimName: trgenerator-media

      - name: trgenerator-textdocs-migrations
        persistentVolumeClaim:
          claimName: trgenerator-textdocs-migrations

      - name: trgenerator-gestionreservas-migrations
        persistentVolumeClaim:
          claimName: trgenerator-gestionreservas-migrations
          
      - name: trgenerator-siemensusers-migrations
        persistentVolumeClaim:
          claimName: trgenerator-siemensusers-migrations

      - name: static-volume
        persistentVolumeClaim:
          claimName: static-volume
status: {}
