apiVersion: apps/v1
kind: Deployment
metadata:
  name: tickets
  labels:
    app: tickets
spec:
  replicas: 1
  selector:
    matchLabels:
      name: tickets
  template:
    metadata:
      labels:
        name: tickets
    spec:
      containers:
        - name: tickets
          image: ckreuzberger/tickets:1.0
          imagePullPolicy: Always
          ports:
            - containerPort: 8000
          env:
            - name: POSTGRES_USER
              valueFrom:
                secretKeyRef:
                  name: postgres-credentials
                  key: user
            - name: POSTGRES_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: postgres-credentials
                  key: password
            - name: POSTGRES_DB
              value: 'tickets'
            - name: DATABASE_URL
              value: postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@postgres:5432/$(POSTGRES_DB)
            - name: DJANGO_SETTINGS_MODULE
              value: 'tickets.settings.prod'
            - name: SECRET_KEY
              valueFrom:
                secretKeyRef:
                  name: django-secret-key
                  key: secret_key
