Open verdverm opened 7 months ago
Followup, I can connect to psql from within the container
/usr/src/ozone # psql postgresql://ts:P8uvpCrEheVuCAPYYPD7Ogt5BaiVPHkO06IULHXLVP7AIl7BkQ48IGCM321VLX6T@psql:5432/ozone
psql (15.6)
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
Type "help" for help.
ozone=>
I added the following to the spec
securityContext: {
runAsUser: 0
runAsGroup: 0
fsGroup: 0
}
and then exec'd in to run apk --update add postgresql-client
and psql
The config object (right before db connect) looks reasonable
https://github.com/bluesky-social/ozone/blob/main/service/index.js#L21
{
service: {
port: 3000,
publicUrl: 'https://ozone.topicalsource.com',
did: '...',
version: '0.1.3',
devMode: undefined
},
db: {
postgresUrl: 'postgresql://ts:<...password...>@psql:5432/ozone',
postgresSchema: 'public',
poolSize: undefined,
poolMaxUses: undefined,
poolIdleTimeoutMs: undefined
},
appview: {
url: 'https://api.bsky.app',
did: 'did:web:api.bsky.app',
pushEvents: false
},
pds: null,
cdn: { paths: [] },
identity: { plcUrl: 'https://plc.directory' },
blobDivert: null,
access: {
admins: [ '...' ],
moderators: [ '...' ],
triage: []
}
}
side note, I did set OZONE_VERSION=0.1.3 in the container. The 0.1.3 container was showing 0.1.1 by default
Reproducing:
# Start kind cluster
kind create cluster --name repro
# Add repo for postgres-operator
helm repo add postgres-operator-charts https://opensource.zalando.com/postgres-operator/charts/postgres-operator
# Install the postgres-operator
helm install postgres-operator postgres-operator-charts/postgres-operator
# Install the reproducer code
kubectl create namespace bsky
kubectl create secret generic -n bsky ozone-env --from-env-file reproducer.env # extra env file from OP comment
kubectl apply -f reproducer.yaml # <--- the yaml content in OP comment
# Check the logs
kubectl get pods -n bsky
kubectl logs -n bsky <pod>
# Cleanup
kind delete cluster --name repro
pg_hba.conf
root@psql-0:/home/postgres/pgdata/pgroot/data# cat pg_hba.conf
# Do not edit this file manually!
# It will be overwritten by Patroni!
local all all trust
hostssl all +zalandos 127.0.0.1/32 pam
host all all 127.0.0.1/32 md5
hostssl all +zalandos ::1/128 pam
host all all ::1/128 md5
local replication standby trust
hostssl replication standby all md5
hostnossl all all all reject
hostssl all +zalandos all pam
hostssl all all all md5
Just to be transparent, I think this is probably specific enough to your setup that we (Bluesky team) probably aren't going to jump in an help debug.
I do encourage you to post updates here though, might help others trying to do a similar deployment!
@bnewbold understandable, but it might be a security hardening thing too, which might be in Bluesky interest
Looking at a pg container (docker hub postgres
) that works, the pg_hba.conf
is mostly set to trust, though maybe that last line is the one that matters
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
host all all all scram-sha-256
Or maybe this line from above is what is blocking Ozone connection...?
hostnossl all all all reject
More breadcrumbs indicating this reject
line may be the problematic setting in Zalando
https://github.com/zalando/postgres-operator/issues/1034#issuecomment-984760984
@bnewbold is there any interest on the Bluesky team for supporting SSL with DB connections?
This looks like the easiest escape hatch in Zalando, will try in the coming days and report back
I just ran into the same problem in Azure and I think the resolution was to add this environment variable to the ozone container in the compose file:
PGSSLMODE: require
Hi, first off, thanks for making this awesome service open source! I'm really liking the ATProto paradigm
I'm having issues getting Ozone up in Kubernetes. The database connection appears to be rejected with the following error from the Ozone container.
I've verified the uname/pword do work with the
psql
clientThe Kubernetes manifest
ENV vars in
ozone-env