Hello, does anyone please have an example of how t...
# pact-broker
t
Hello, does anyone please have an example of how they bring up a cloud postgresql instance via Terraform? I have everything working but for some reason the
PACT_BROKER_BASIC_AUTH
stuff doesnt seem to be working. I know I had it working before I terraformed my infra. When I made the database manually and ran the psql commands
Copy code
CREATE DATABASE pact_broker;
CREATE ROLE pact_broker WITH LOGIN PASSWORD 'CHANGE_ME';
GRANT ALL PRIVILEGES ON DATABASE pact_broker TO pact_broker;
the basic auth stuff worked fine
m
sorry, you mention postgres but then basic auth
is the issue that the broker is not presenting basic auth to you or that it can’t connect to postgres?
t
sorry, the issue is the broker is not presenting basic auth to me, but it used to before i terraformed my infra, so thought maybe its somehow related to how i created the database
m
mind sharing the env vars it has?
or redacted boot logs? (it should print its configuration)
t
Copy code
# Source: pact-broker/templates/secrets.yaml
apiVersion: v1
kind: Secret
metadata:
  name: pact-broker-secrets
type: Opaque
data:
    pact-broker-basic-auth-password: "RG9qb1BhY3RCcm9rZXIh"
    pact-broker-basic-auth-username: "YWRtaW4="
    pact-broker-basic-read-only-auth-password: "UmVhZFBhY3RzIQ=="
    pact-broker-basic-read-only-auth-username: "ZGV2"
    pact-broker-database-url: "cG9zdGdyZXM6Ly9wYWN0X2Jyb2tlcjpEb2pvUGFjdERCIUAxMjcuMC4wLjE6NTQzMi9wYWN0X2Jyb2tlcg=="
---
# Source: pact-broker/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: pact-broker-service
spec:
  type: ClusterIP
  selector:
    app: pact-broker
  ports:
    - port: 9292
      targetPort: 9292
---
# Source: pact-broker/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: pact-broker-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pact-broker
  template:
    metadata:
      labels:
        app: pact-broker
    spec:
      serviceAccountName: pact-broker-service-account
      containers:
        - name: cloud-sql-proxy
          image: <http://gcr.io/cloudsql-docker/gce-proxy:1.17|gcr.io/cloudsql-docker/gce-proxy:1.17>
          command:
            - "/cloud_sql_proxy"
            - "-instances=ag-staging-mobile:europe-west2:pact-broker-cloud-sql-instance=tcp:5432"
          securityContext:
            runAsNonRoot: true
          resources:
            requests:
              memory: "2Gi"
              cpu: "1"
        - name: pact-broker
          image: pactfoundation/pact-broker
          env:
            - name: PACT_BROKER_PUBLIC_HEARTBEAT
              value: "true"
            - name: PACT_BROKER_DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: pact-broker-secrets
                  key: pact-broker-database-url
            - name: PACT_BROKER_BASIC_AUTH_USERNAME
              valueFrom:
                secretKeyRef:
                  name: pact-broker-secrets
                  key: pact-broker-basic-auth-username
            - name: PACT_BROKER_AUTH_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: pact-broker-secrets
                  key: pact-broker-basic-auth-password
            - name: PACT_BROKER_BASIC_READ_ONLY_AUTH_USERNAME
              valueFrom:
                secretKeyRef:
                  name: pact-broker-secrets
                  key: pact-broker-basic-read-only-auth-username
            - name: PACT_BROKER_BASIC_READ_ONLY_AUTH_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: pact-broker-secrets
                  key: pact-broker-basic-read-only-auth-password
          ports:
            - name: http
              containerPort: 9292
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /diagnostics/status/heartbeat
              port: http
            initialDelaySeconds: 300
            periodSeconds: 20
          readinessProbe:
            httpGet:
              path: /diagnostic/status/heartbeat
              port: http
            initialDelaySeconds: 300
            periodSeconds: 20
          resources:
            requests:
              cpu: "200m"
              memory: "512Mi"
            limits:
              cpu: "2500m"
              memory: "1024Mi"
---
base64 decoding those secrets gives me the correct values
👍 1
m
looks like
PACT_BROKER_AUTH_PASSWORD
should be
PACT_BROKER_BASIC_AUTH_PASSWORD
t
Oh my god
thank you!!
hahaha
m
haha
also the read only ones are also slightly out
t
oh ?
the prefix for all four is
PACT_BROKER_BASIC_AUTH...
t
aaah ok BASIC_AUTH_READ_ONLY
m
yeah
t
thank you it couldve taken me ages to figure out, always the simplest thing
i probably changed the env var by mistake when templating everything
m
hahah all good
I was about to say it LGTM and then I saw the inconsistency and thought “let me check if it matches”
🙌 1
always basic stuff (see what I did there? 😛 )
t
hahahaa