pgpool / pgpool2_on_k8s

57 stars 36 forks source link

k8s pgpool/pgpool:4.2 error PGPOOL_PARAMS_BACKEND_HOSTNAME0 environment variable is not set, exiting #21

Open abdidarmawan007 opened 2 years ago

abdidarmawan007 commented 2 years ago

image: pgpool/pgpool:4.2

Error Logs 2022-09-16 15:07:53.940 ICTNo custom pgpool.conf detected. Use environment variables and default config. Info 2022-09-16 15:07:53.943 ICTERROR: PGPOOL_PARAMS_BACKEND_HOSTNAME0 environment variable is not set, exiting...

Deployment and configmap follow from https://www.pgpool.net/docs/pgpool-II-4.2.3/en/html/example-kubernetes.html

pengbo0328 commented 1 year ago

@abdidarmawan007

Error Logs 2022-09-16 15:07:53.940 ICTNo custom pgpool.conf detected. Use environment variables and default config. Info 2022-09-16 15:07:53.943 ICTERROR: PGPOOL_PARAMS_BACKEND_HOSTNAME0 environment variable is not set, exiting...

The error message shows backend_hostname0 wasn't specified. Did you specify backend_hostname0 in your configmap?

Deployment and configmap follow from https://www.pgpool.net/docs/pgpool-II-4.2.3/en/html/example-kubernetes.html

Sorry, this document is old. Please refer to the doc below: https://github.com/pgpool/pgpool2_on_k8s/blob/master/docs/index.md

pengbo0328 commented 1 year ago

May I close this issue?

brandizzi commented 1 year ago

I had the same issue following the tutorial, here is my YAML file:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: pgpool
  namespace: postgresql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pgpool
  template:
    metadata:
      labels:
        app: pgpool
    spec:
      containers:
      - name: pgpool
        image: pgpool/pgpool:4.2
        volumeMounts:
        - name: pgpool-config
          mountPath: /usr/local/pgpool-II/etc
      - name: pgpool-stats
        image: pgpool/pgpool2_exporter:1.0
      volumes:
      - name: pgpool-config
        configMap:
          name: pgpool-config
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: pgpool-config
  namespace: postgresql
  labels:
    app: pgpool-config
data:
  pgpool.conf: |-
    listen_addresses = '*'
    port = 9999
    socket_dir = '/var/run/postgresql'
    pcp_listen_addresses = '*'
    pcp_port = 9898
    pcp_socket_dir = '/var/run/postgresql'
    backend_hostname0 = '<...>'
    backend_port0 = 5432
    backend_weight0 = 1
    backend_flag0 = 'ALWAYS_PRIMARY|DISALLOW_TO_FAILOVER'
    backend_hostname1 = '<...>'
    backend_port1 = 5432
    backend_weight1 = 1
    backend_flag1 = 'DISALLOW_TO_FAILOVER'
    backend_hostname2 = '<...>'
    backend_port2 = 5432
    backend_weight2 = 1
    backend_flag2 = 'DISALLOW_TO_FAILOVER'
    sr_check_user = 'postgres'
    sr_check_period = 10
    enable_pool_hba = on
    master_slave_mode = on
    num_init_children = 32
    max_pool = 4
    child_life_time = 300
    child_max_connections = 0
    connection_life_time = 0
    client_idle_limit = 0
    connection_cache = on
    load_balance_mode = on
  pcp.conf: |-
    postgres:<...>
  pool_passwd: |-
    postgres:<...>
  pool_hba.conf: |-
    local   all         all                               trust
    host    all         all         127.0.0.1/32          trust
    host    all         all         ::1/128               trust
    host    all         all         0.0.0.0/0             md5

I'll keep investigating here and share anything I learn about it.

brandizzi commented 1 year ago

I solved the issue here.

entrypoint.sh tries to copy the configuration file from $PGPOOL_CONFIG_VOLUME to the expected directory. The Dockerfile defines $PGPOOL_CONF_VOLUMEas/config`. Yet, the documentation example tells us to mount the ConfigMap into /usr/local/pgpool-II/etc.

I got it to work by changing

          mountPath: /usr/local/pgpool-II/etc

to

          mountPath: /config