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

#556: Adds example GrafanaDatasource for postgres #588

Merged
merged 6 commits into from
Nov 9, 2021

Conversation

Voigtus
Copy link
Contributor

@Voigtus Voigtus commented Oct 30, 2021

Description

Adds an example to use a postgres DB as GrafanaDatasource

Relevant issues/tickets

#556

Type of change

  • Enhancement: adds new example for Datasource
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Verification steps

  • Spin up any Kubernetes Distribution
  • Install and deploy Operator & CRD
  • Add example Grafana Instance
    • kubectl apply -n grafana-operator-system -f Grafana.yaml
  • Deploy Postgres to Kubernetes cluster
apiVersion: v1
kind: ConfigMap
metadata:
  name: postgres-config
  labels:
    app: postgres
data:
  POSTGRES_DB: postgresdb
  POSTGRES_USER: postgresadmin
  POSTGRES_PASSWORD: admin123
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: postgres
        image: postgres:11
        imagePullPolicy: IfNotPresent
        ports:
          - containerPort: 5432
        envFrom:
          - configMapRef:
              name: postgres-config
---
apiVersion: v1
kind: Service
metadata:
  name: postgres
  labels:
    app: postgres
spec:
  type: ClusterIP
  ports:
   - port: 5432
  selector:
   app: postgres

@NissesSenap NissesSenap self-requested a review November 2, 2021 21:44
Copy link
Collaborator

@NissesSenap NissesSenap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment.
Thanks allot @Voigtus keep up the good work!

secureJsonData:
password: admin123 # password of your user
url: postgres.default.svc.cluster.local:5432 #change to url of your postgres instance
user: postgresadmin # user to access your database
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silly thing but I know I will think about it in the future. Trying to add \n at the end of all our yaml files.
It's on my todo to add a CI rule for this.
Other then that I think it looks great

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.
On further notice: Would it be a possibility to add an .editorconfig file to the repo?
It would be insured, that something like this might not happen as easily again.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There have been talk about editorconfig before #516 if you want to take a look at it again please do.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NissesSenap I force-pushed the change, can you approve?

@NissesSenap NissesSenap added documentation Issues relating to documentation, missing, non-clear etc. v4 Major version 4 labels Nov 2, 2021
Copy link
Collaborator

@hubeadmin hubeadmin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this @Voigtus 👍

@NissesSenap NissesSenap merged commit 22fa672 into grafana:master Nov 9, 2021
@krzwiatrzyk
Copy link
Contributor

It seems that is example got lost and is not available anymore in the repo?

@NissesSenap
Copy link
Collaborator

@krzwiatrzyk it's in the v4 branch. But we would love a PR with a v5 version.

@krzwiatrzyk
Copy link
Contributor

I made it work, just change datasources (list) to datasource (object) and add an access: proxy field (Grafana was rejecting datasource without it)

@NissesSenap
Copy link
Collaborator

Great @krzwiatrzyk , we would love a PR with an example

@krzwiatrzyk
Copy link
Contributor

Here #1076

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issues relating to documentation, missing, non-clear etc. v4 Major version 4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants