
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tanzu-ui
  labels:
    app: tanzu-ui
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tanzu-ui
  template:
    metadata:
      labels:
        app: tanzu-ui
    spec:
      containers:
      - name: tanzu-ui
        image: ghcr.io/vchrisb/tanzu-ui:latest
        ports:
        - containerPort: 8080
        volumeMounts:
          - mountPath: /app/staticfiles
            name: staticfiles
        env:
        - name: POSTGRESQL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: tanzu-postgresql
              key: postgresql-password
        - name: DATABASE_URL
          value: postgres://postgres:$(POSTGRESQL_PASSWORD)@tanzu-postgresql-headless.default.svc.cluster.local:5432/tanzu-ui
        envFrom:
          - secretRef:
              name: tanzu-ui-secret
      initContainers:
      - name: collectstatic
        image: ghcr.io/vchrisb/tanzu-ui:latest
        imagePullPolicy: Always
        command: ['sh', '-c', 'python manage.py collectstatic --noinput']
        volumeMounts:
          - mountPath: /app/staticfiles
            name: staticfiles
        env:
        - name: POSTGRESQL_PASSWORD
          valueFrom:
            secretKeyRef:
              name: tanzu-postgresql
              key: postgresql-password
        - name: DATABASE_URL
          value: postgres://postgres:$(POSTGRESQL_PASSWORD)@tanzu-postgresql-headless.default.svc.cluster.local:5432/postgres
        envFrom:
          - secretRef:
              name: tanzu-ui-secret
      volumes:
        - name: staticfiles
          emptyDir: {}