Summary:
When client_tls settings were configured liked below, it gives these errors:
2024-12-02 12:12:56.629 UTC [1] ERROR TLS setup failed: failed to load CA: (null)
2024-12-02 12:12:56.629 UTC [1] FATAL TLS setup failed
client_tls_sslmode = require
client_tls_key_file = /etc/ssl/certs/tls.key
client_tls_cert_file = /etc/ssl/certs/tls.crt
Cert is created by cert-manager(let's encrypt) and verified that it's working on an nginx ingress.
deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: pgbouncer-test
name: pgbouncer-test
namespace: default
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: pgbouncer-test
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: pgbouncer-test
spec:
containers:
- env:
- name: PGBOUNCER_PORT
value: "6432"
- name: POSTGRESQL_USERNAME
valueFrom:
secretKeyRef:
key: PGUSER
name: pg-credentials
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
key: PGPASSWORD
name: pg-credentials
- name: POSTGRESQL_HOST
value: 127.0.0.1
- name: POSTGRESQL_PORT
value: "5432"
image: docker.io/bitnami/pgbouncer:latest
imagePullPolicy: IfNotPresent
name: pgbouncer-test
ports:
- containerPort: 6432
protocol: TCP
resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 100m
memory: 128Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /bitnami/pgbouncer/conf/
name: pgbouncer-config
- mountPath: /etc/ssl/certs
name: ssl-certs
- mountPath: /var/log/pgbouncer
name: pgbouncer-log
- mountPath: /var/run/pgbouncer
name: pgbouncer-run
- mountPath: /etc/ssl/le
name: pgbouncer-le-ca-cert
- command:
- /cloud-sql-proxy
- -c=/secrets/credentials.json
- "this section contains sensitive information so i've removed."
image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.14.0
imagePullPolicy: IfNotPresent
name: cloud-sql-proxy
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /secrets
name: cloudsql-instance-credentials
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- configMap:
defaultMode: 420
name: pgbouncer-config
name: pgbouncer-config
- name: ssl-certs
secret:
defaultMode: 420
secretName: smart-mycompany-com-tls
- name: pgbouncer-le-ca-cert
secret:
defaultMode: 420
secretName: pgbouncer-le-ca-cert
- name: cloudsql-instance-credentials
secret:
defaultMode: 420
secretName: cloudsql-instance-credentials
- emptyDir: {}
name: pgbouncer-log
- emptyDir: {}
name: pgbouncer-run
configmap.yaml
apiVersion: v1
data:
pgbouncer.ini: |
[databases]
* = host=127.0.0.1 port=5432
[pgbouncer]
verbose=2
listen_addr = 0.0.0.0
listen_port = 6432
auth_type = trust
auth_file = /bitnami/pgbouncer/conf/userlist.txt
client_tls_sslmode = require
client_tls_key_file = /etc/ssl/certs/tls.key
client_tls_cert_file = /etc/ssl/certs/tls.crt
logfile = /var/log/pgbouncer/pgbouncer.log
pidfile = /var/run/pgbouncer/pgbouncer.pid
admin_users = pgbouncer_user
ignore_startup_parameters = extra_float_digits
userlist.txt: |
"pgbouncer" "sensitive"
kind: ConfigMap
Full logs, verbose=2
Defaulted container "pgbouncer-test" out of: pgbouncer-test, cloud-sql-proxy
pgbouncer 12:33:20.32 INFO ==>
pgbouncer 12:33:20.32 INFO ==> Welcome to the Bitnami pgbouncer container
pgbouncer 12:33:20.33 INFO ==> Subscribe to project updates by watching https://github.com/bitnami/containers
pgbouncer 12:33:20.33 INFO ==> Submit issues and feature requests at https://github.com/bitnami/containers/issues
pgbouncer 12:33:20.33 INFO ==> Upgrade to Tanzu Application Catalog for production environments to access custom-configured and pre-packaged software components. Gain enhanced features, including Software Bill of Materials (SBOM), CVE scan result reports, and VEX documents. To learn more, visit https://bitnami.com/enterprise
pgbouncer 12:33:20.34 INFO ==>
pgbouncer 12:33:20.40 INFO ==> ** Starting PgBouncer setup **
pgbouncer 12:33:20.42 INFO ==> Validating settings in PGBOUNCER_* env vars...
pgbouncer 12:33:20.43 INFO ==> Initializing PgBouncer...
pgbouncer 12:33:20.44 INFO ==> Found configuration files in
pgbouncer 12:33:20.50 INFO ==> Waiting for PostgreSQL backend to be accessible
pgbouncer 12:33:20.52 INFO ==> Backend 127.0.0.1:5432 accessible
pgbouncer 12:33:20.53 INFO ==> Configuring credentials
pgbouncer 12:33:20.53 INFO ==> Creating configuration file
pgbouncer 12:33:20.54 INFO ==> Loading custom scripts...
pgbouncer 12:33:20.54 INFO ==> ** PgBouncer setup finished! **
pgbouncer 12:33:20.61 INFO ==> ** Starting PgBouncer **
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'verbose' = '2' ok:1
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'listen_addr' = '0.0.0.0'
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'listen_addr' = '0.0.0.0' ok:1
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'listen_port' = '6432'
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'listen_port' = '6432' ok:1
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'auth_type' = 'trust'
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'auth_type' = 'trust' ok:1
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'auth_file' = '/bitnami/pgbouncer/conf/userlist.txt'
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'auth_file' = '/bitnami/pgbouncer/conf/userlist.txt' ok:1
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'client_tls_sslmode' = 'require'
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'client_tls_sslmode' = 'require' ok:1
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'client_tls_key_file' = '/etc/ssl/certs/tls.key'
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'client_tls_key_file' = '/etc/ssl/certs/tls.key' ok:1
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'client_tls_cert_file' = '/etc/ssl/certs/tls.crt'
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'client_tls_cert_file' = '/etc/ssl/certs/tls.crt' ok:1
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'logfile' = '/var/log/pgbouncer/pgbouncer.log'
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'logfile' = '/var/log/pgbouncer/pgbouncer.log' ok:1
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'pidfile' = '/var/run/pgbouncer/pgbouncer.pid'
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'pidfile' = '/var/run/pgbouncer/pgbouncer.pid' ok:1
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'admin_users' = 'pgbouncer_user'
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'admin_users' = 'pgbouncer_user' ok:1
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'ignore_startup_parameters' = 'extra_float_digits'
2024-12-02 12:33:20.627 UTC [1] DEBUG parse_ini_file: 'ignore_startup_parameters' = 'extra_float_digits' ok:1
2024-12-02 12:33:20.628 UTC [1] DEBUG loading auth_file: "/bitnami/pgbouncer/conf/userlist.txt"
2024-12-02 12:33:20.633 UTC [1] ERROR TLS setup failed: failed to load CA: (null)
2024-12-02 12:33:20.633 UTC [1] FATAL TLS setup failed
Summary:
When client_tls settings were configured liked below, it gives these errors:
2024-12-02 12:12:56.629 UTC [1] ERROR TLS setup failed: failed to load CA: (null)
2024-12-02 12:12:56.629 UTC [1] FATAL TLS setup failed
Cert is created by cert-manager(let's encrypt) and verified that it's working on an nginx ingress.
deployment.yaml
configmap.yaml
Full logs, verbose=2