Closed Keshav0690 closed 6 years ago
Hi @Keshav0690,
that's probably related to your specific Kubernetes deployment. You can look into Kubernetes docs on container communication/networking https://kubernetes.io/docs/concepts/workloads/pods/pod/#resource-sharing-and-communication. Maybe you can share your Kubernetes deployment yaml.
To make sure that this is not related to our prometheus-postgresql-adapter
docker image you can try it locally with docker-compose
. There is a tutorial https://docs.timescale.com/v0.11/tutorials/prometheus-adapter
Hi Niksa,
I have created the adapter image using the available binary. Below is the Docker file:
_FROM oraclelinux:7-slim
COPY --from=timescale/prometheus-postgresql-adapter /prometheus-postgresql-adapter /prometheus-postgresql-adapter COPY launch.sh /launch.sh RUN chmod +x /launch.sh
EXPOSE 9201
CMD ["sh","/launch.sh"]_
launch.sh contains below content:
touch /posgtres_prom_adpater.log;sleep 3;/prometheus-postgresql-adapter -pg.host=127.0.0.1 -pg.prometheus-log-samples 2> /posgtres_prom_adpater.log; tail -f /posgtres_prom_adpater.log
It is just for launching adapter and redirecting logs to some file.
This is deployment file:
apiVersion: apps/v1beta1 kind: Deployment metadata: name: postgresql spec: replicas: 1 template: metadata: labels: app: postgresql spec: containers:
- name: postgres-prom-adapter
image: pg_prometheus_adapter:v1
ports:
- name: ppadpt-port
containerPort: 9201
#Container for postgresql
- name: postgresql
image: pg_prometheus:v1
env:
- name: PGDATA
value: /var/lib/pgsql/10/data
ports:
- name: pp-port
containerPort: 5432
Regards, Keshav Sharma
Do you have any existing pg_prometheus + postgreSQL image having base image as centos7/oraclelinux7. I can refer that If you have 1.
@Keshav0690, you can find pg_prometheus
images here https://hub.docker.com/r/timescale/pg_prometheus/, and the Dockerfile https://github.com/timescale/pg_prometheus/blob/master/Dockerfile
Hi, If my database is password protected, how can I use adapter to connect via creds. Any help would be appreciated.
Regards, Keshav Sharma
You can supply username/password via command line arguments: -pg.user
and -pg.password
HI Niksa,
Thanks. But what if I am using kubernetes secret. It is showing password in base64 form and with single quotes. It seems it is taking it as string eg 'D&799DNDXn=' and failing with password authentication error.
Hi All,
I have created the docker image for PostgreSQL (along with timescaleDB) using centos as base image. and 1 image for adapter . Below is the output when I run this PostgreSQL Image:
< 2018-08-23 06:15:40.412 UTC >LOG: listening on IPv4 address "0.0.0.0", port 5432 < 2018-08-23 06:15:40.412 UTC >LOG: listening on IPv6 address "::", port 5432 < 2018-08-23 06:15:40.415 UTC >LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" < 2018-08-23 06:15:40.416 UTC >LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" < 2018-08-23 06:15:40.425 UTC >LOG: redirecting log output to logging collector process < 2018-08-23 06:15:40.425 UTC >HINT: Future log output will appear in directory "pg_log". < 2018-08-23 06:15:40.428 UTC >LOG: database system was shut down at 2018-08-23 05:52:23 UTC < 2018-08-23 06:15:40.432 UTC >LOG: database system is ready to accept connections
Also, When I logged in to the container , I can able to access the DB
sh-4.2$ psql -U postgres -h 127.0.0.1 psql (10.5) Type "help" for help. postgres=# postgres=#
Third I checked the 5432 port status using netstat command: sh-4.2$ netstat -ntl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:5432 0.0.0.0: LISTEN
tcp6 0 0 :::5432 ::: LISTEN
But, when I tried to run the adapter image, I am getting below error:
level=info ts=2018-08-23T06:15:31.270935952Z caller=log.go:25 msg="host=127.0.0.1 port=5432 user=postgres dbname=postgres password='' sslmode=disable connect_timeout=10" level=error ts=2018-08-23T06:15:31.271753696Z caller=log.go:33 err="dial tcp 127.0.0.1:5432: connect: connection refused"
Can anyone tell what's the issue here.
Note: Created Pod in kubernetes having 2 container one with PostgreSQL Image and another is with adapter image. So adapter should connect with localhost:5432.
Any help would be appreciated.
Regards, Keshav Sharma