apiVersion: apps/v1
kind: Deployment
metadata:
  name: oidc-postgres
  labels:
    app: oidc-postgres
spec:
  replicas: 1
  selector:
    matchLabels:
      app: oidc-postgres
  template:
    metadata:
      labels:
        app: oidc-postgres
    spec:
      initContainers:
        - name: hydra-migrations
          imagePullPolicy: Always
          image: localhost:32000/hydra:latest
          command: ['hydra']
          args: ['migrate','-c', "/etc/config/hydra/hydra.yml", "sql", "-e", "--yes"]
          env:
            - name: DSN
              value: postgres://hydra:hydrapostgres@oidc-db.default.svc.cluster.local:5432/hydra?sslmode=disable&max_conns=20&max_idle_conns=4
      containers:
        - name: hydra
          image: localhost:32000/hydra:latest
          ports:
            - containerPort: 4444
            - containerPort: 4445
            - containerPort: 5555 #TODO: remove?
          env:
            - name: DSN
              value: postgres://hydra:hydrapostgres@oidc-db.default.svc.cluster.local:5432/hydra?sslmode=disable&max_conns=20&max_idle_conns=4
          command: ["hydra"]
          args: ["serve","-c", "/etc/config/hydra/hydra.yml","all","--dangerous-force-http"]
        - name: oidc
          image: localhost:32000/oidc:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 3000
          env:
            - name: HYDRA_ADMIN_URL
              value: http://localhost:4445/