Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
abdidarmawan007 opened this issue Sep 16, 2022 · 4 comments
Assignees

Comments

@abdidarmawan007
Copy link

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
Copy link
Collaborator

pengbo0328 commented Sep 20, 2022

@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 pengbo0328 self-assigned this Sep 20, 2022
@pengbo0328
Copy link
Collaborator

May I close this issue?

@brandizzi
Copy link

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
Copy link

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](https://github.com/pgpool/pgpool2_on_k8s/blob/master/pgpool.docker/Dockerfile.pgpool#L6). 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants