Comments (10)
Hi @alex-arica ! I just stumbled upon this as I was adding metrics to all third-party stuff that I use. The way postgres-exporter
is usually deployed is as a container that is separate from the actual database, and you provide connection strings to point to the postgres database.
In the case of Kubernetes, this would be done by using sidecar containers, e.g:
apiVersion: apps/v1
kind: StatefulSet
metadata:
...
spec:
...
template:
...
spec:
...
containers:
- name: postgres-main-instance
...
- containerPort: ...
name: ...
- name: postgres-exporter
...
- containerPort: <different port from main instance>
name: metrics
Reasons to do it in a separate container:
- It's not necessary to create a custom image
- Even if the postgres server becomes unresponsive, the last state of the metrics is sill available, because it's isolated
- The separate container is the typical way to do it - here's the quickstart guide from their github readme:
# Start an example database docker run --net=host -it --rm -e POSTGRES_PASSWORD=password postgres # Connect to it docker run \ --net=host \ -e DATA_SOURCE_NAME="postgresql://postgres:password@localhost:5432/postgres?sslmode=disable" \ quay.io/prometheuscommunity/postgres-exporter
Reasons to not deploy it in a separate Deployment
, but attach it inside the StatefulSet
by kubegres:
- you need one instance per postgres replica, so you need to connect to the pods directly - and those might get killed & replaced etc.
So I think that the question here was: is it possible to specify such sidecar containers that get attached to the StatefulSet
controlling the kubegres pods? If not, here's how I imagine that this could be implemented:
- add an optional list of sidecars to the kubegres resource, that allows specifying image, port and args (environment variables would be a great plus, but are probably more work to implement). Specifying both the port number + name instead of only the number would also be a huge plus!
- this list of sidecars gets added to the StatefulSet
- the port specified will be used by the service to expose the endpoint for that container
And considering that monitoring is a must-have for production services, this would be a really nice feature!
from kubegres.
This would make kubegres fit really nicely into other production-ready environments in kubernetes:
- kube-prometheus is the easiest way to add monitoring to all of kubernetes, and will automatically spin up prometheus for metric collection & grafana for dashboards for you
- all that your pods need to do is expose prometheus metrics (in the case of postgres, this happens via postgres-exporter)
- point your prometheus to scrape these metrics
- download a dashboard for postgres from grafana (e.g. https://grafana.com/grafana/dashboards/9628)
-> look at all those pretty graphs that tell you about stuff like your database CPU & memory usage, number of transaction per time, etc. (you can click on the images in the dashboard that I linked to see an example of what you get out of the box if only your postgres instance exports prometheus metrics)
from kubegres.
@alex-arica can you add either @jgmartinez or me as assigned to this and #89?
We would like to add the support for our OTEL setup. We’ll most likely take a stab at it during the following two weeks 👍
from kubegres.
@CasperGN I assigned it to you. From now, I think you can assign it to anyone else if required.
from kubegres.
Thank you for your message.
If you would like to deploy a side container, it's only possible by creating your own custom container by extending Postgres container and then in your own custom container you can add anything you would like.
from kubegres.
Hello,
I have not heard from you. Is there an alternative method that you would suggest?
from kubegres.
I am closing this issue. If you would like to make a suggestion about an alternative solution, please do not hesitate to make a comment.
from kubegres.
@LanDinh Thank you for sharing this. I agree that for those who prefer the sidecar option, it would add value to be able to specify one or many sidecars in Kubegres YAML.
I am re-openning this issue and it will be about being able to specify one or many sidecars to Kubegres.
Thank you.
from kubegres.
Any news on this? The missing option for sidecar containers is currently the major reason for not using Kubegres in production. Anything else works pretty fine. I really like the simplicity of Kubegres compared to other much more complex operators. Many thanks for this awesome work!
from kubegres.
I agree that it will a useful feature.
If a developer is willing to implement this change, I am available to review their PR.
We decided to let the community to be more involved in the project and therefore until end of summer 2022, I will only make a code changes when it is required.
With this approach, we are hoping there would be additional developers involved in this project and more PRs submitted.
from kubegres.
Related Issues (20)
- CVEs in 1.16 version HOT 1
- Replicas are not synced completely HOT 3
- Locale(s) can not be set / won't be generated @setup
- Postgres 16 error due to eliminated promote_trigger_file config parameter HOT 2
- Is this project dead? HOT 3
- "storageClassName" definition doesn't work. HOT 4
- Upgrade Kubegres to Kubebuilder 3.12.0
- Update Kubegres installation URL from 1.16 to 1.17 HOT 2
- Upgrade between major versions HOT 1
- Fail-over did not work for me HOT 5
- unknown field "spec.volume.volumeClaimTemplates.name" HOT 6
- failover promblem of replica
- Kubegres Database files into shared PVC storage
- login issue
- Allow configuring serviceAccount to use. HOT 1
- Setting securityContext works for spec.securityContext but not for spec.container.securityContext HOT 5
- Re-check Primary-Failover / Disabling Fail-Over-Management HOT 1
- CVEs in latest version HOT 3
- 3 pods postgres replication issue after master's fail
- Backup jobs doesn't set resources limits as specified in resources limits entry in manifest
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kubegres.