pg_hba.conf

255 views
Skip to first unread message

Roger Parkinson

unread,
Aug 26, 2021, 9:49:52 AM8/26/21
to Postgres Operator

I need to add a trusted CIDR to my pg_hba.conf file and I see hints of how to do this but nothing I can quite follow. I'm running the latest postgres-operator under microk8s. My script to get it all working looks like this:
    git clone https://github.com/CrunchyData/postgres-operator-examples # ignore errors
    cd postgres-operator-examples
    microk8s kubectl apply -k kustomize/install
    retry_command "microk8s kubectl -n postgres-operator get pods \
      --selector=postgres-operator.crunchydata.com/control-plane=postgres-operator \
      --field-selector=status.phase=Running | grep postgres-operator | wc -l"
   
What do I need to add to get a custom pg_hba.conf into that?
Thanks
R
    microk8s kubectl apply -k kustomize/postgres

Jonathan S. Katz

unread,
Aug 26, 2021, 11:44:33 AM8/26/21
to Roger Parkinson, Postgres Operator
Postgres customizations are covered in the documentation here:


Here is an example of modifying the pg_hba rules specifically:


Jonathan

Jonathan S. Katz
VP Platform Engineering

Crunchy Data
Enterprise PostgreSQL 


Jonathan S. Katz

unread,
Aug 26, 2021, 7:02:46 PM8/26/21
to Roger Parkinson, Postgres Operator
I had missed a directive in the example, the updated example is here:


Jonathan

Jonathan S. Katz
VP Platform Engineering

Crunchy Data
Enterprise PostgreSQL 



On Thu, Aug 26, 2021 at 6:30 PM Roger Parkinson <roger.pa...@gmail.com> wrote:
(Message might be a duplicate, I posted earlier but I can't find that message)
Thanks for the quick reply.
I pulled a fresh copy of postgres-operator-examples and edited the patroni section to the end of postgres-operator-examples/kustomize/postgres/postgres.yaml
ie
  patroni:
    postgresql:
      pg_hba:
        - "host all all all md5"

(I'm not worried about getting the CIDR right at this stage so 'all' is good enough)
I reset my microk8s instance to ensure the old postgres operator and everything else was cleared out. Then I ran:

    microk8s kubectl apply -k kustomize/install
.. waited for the operator pod to get status running
    microk8s kubectl apply -k kustomize/postgres
And I get this error:
error: error validating "kustomize/postgres": error validating data: ValidationError(PostgresCluster.spec.patroni): unknown field "postgresql" in com.crunchydata.postgres-operator.v1beta1.PostgresCluster.spec.patroni; if you choose to ignore these errors, turn validation off with --validate=false
which looks like I am not really running 5.0.1, though a search of my copy of postgres-operator-examples shows two references to 5.0.1 so I think I am running.
What did I miss?

Roger Parkinson

unread,
Aug 27, 2021, 12:31:06 AM8/27/21
to Postgres Operator, jonath...@crunchydata.com, Postgres Operator, Roger Parkinson
That worked fine, thanks

Roger Parkinson

unread,
Aug 27, 2021, 9:27:06 AM8/27/21
to Postgres Operator, jonath...@crunchydata.com, Postgres Operator, Roger Parkinson
Thanks for the quick reply.
I have now cloned the postgres-operator-examples/kustomize/postgres into postgres-operator-examples/kustomize/bonanza
And I've added the following to my postgres-operator-examples/kustomize/bonanza/postgres.yaml (otherwise this file is the same as the original)
  patroni:
    postgresql:
      pg_hba:
        - "host all all all md5" 

(I'm not worrying about getting the right CIDR in there yet, so 'all' is good enough)
When I run
microk8s kubectl apply -k kustomize/bonanza
I get ValidationError(PostgresCluster.spec.patroni): unknown field "postgresql" in com.crunchydata.postgres-operator.v1beta1.PostgresCluster.spec.patroni
which looks like I am not running the latest version, ie 5.0.1
So I shut everything down and cleared out microk8s and then did a git pull of postgres-operator-examples. Some changes came down and I re-cloned the postgres.yaml file and re-edited in my changes.
But I get the same error.
I wondered if I am running 5.0.1 after all but a search of postgres-operator-examples shows two references to 5.0.1 so I guess I am.
What did I do wrong?
On Friday, August 27, 2021 at 3:44:33 AM UTC+12 jonath...@crunchydata.com wrote:
Reply all
Reply to author
Forward
0 new messages