zalando / postgres-operator

Postgres operator creates and manages PostgreSQL clusters running in Kubernetes
https://postgres-operator.readthedocs.io/
MIT License
4.35k stars 980 forks source link

Connection pooler configuration #1925

Open gorbak25 opened 2 years ago

gorbak25 commented 2 years ago

I'm trying to enable server_fast_close in the connection pooler, the CRD doesn't expose this. The operator should expose more configuration options for the connection pooler directly in the CRD.

FxKu commented 2 years ago

We can think of including the connection pooler image to the OS repo, so that you can configure it yourself. But, the idea once was that you can also specify your own pgBouncer image in the operator. But, I guess it would require the following function:

CREATE SCHEMA IF NOT EXISTS pooler;

CREATE OR REPLACE FUNCTION pooler.user_lookup(
    in i_username text, out uname text, out phash text)
RETURNS record AS $$
BEGIN
    SELECT usename, passwd FROM pg_catalog.pg_shadow
    WHERE usename = i_username INTO uname, phash;
    RETURN;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;

REVOKE ALL ON FUNCTION pooler.user_lookup(text) FROM public, pooler;
GRANT EXECUTE ON FUNCTION pooler.user_lookup(text) TO pooler;
GRANT USAGE ON SCHEMA pooler TO pooler;

And we are also patching pgBouncer. I'm not sure if it would work out-of-the box with your own pgBouncer image.