Giter Site home page Giter Site logo

Comments (10)

LanDinh avatar LanDinh commented on August 22, 2024 5

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.

LanDinh avatar LanDinh commented on August 22, 2024 2

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.

CasperGN avatar CasperGN commented on August 22, 2024 1

@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.

alex-arica avatar alex-arica commented on August 22, 2024 1

@CasperGN I assigned it to you. From now, I think you can assign it to anyone else if required.

from kubegres.

alex-arica avatar alex-arica commented on August 22, 2024

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.

alex-arica avatar alex-arica commented on August 22, 2024

Hello,
I have not heard from you. Is there an alternative method that you would suggest?

from kubegres.

alex-arica avatar alex-arica commented on August 22, 2024

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.

alex-arica avatar alex-arica commented on August 22, 2024

@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.

bm-skutzke avatar bm-skutzke commented on August 22, 2024

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.

alex-arica avatar alex-arica commented on August 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.