Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 17 additions & 48 deletions kubernetes/grafana.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,51 +34,9 @@ spec:
cpu: 175m
ports:
- containerPort: 3000
volumeMounts:
- mountPath: /etc/secrets
name: secrets
env:
- name: GF_SERVER_ROOT_URL
value: https://grafana.ocf.berkeley.edu/
- name: GF_DATABASE_TYPE
value: mysql
- name: GF_DATABASE_HOST
value: mysql
- name: GF_DATABASE_NAME
value: ocfgrafana
- name: GF_DATABASE_USER
value: ocfgrafana
- name: GF_SESSION_PROVIDER
value: mysql
- name: GF_SESSION_COOKIE_SECURE
value: "true"

- name: GF_DATABASE_PASSWORD__FILE
value: /etc/secrets/mysql-pass
- name: GF_SECURITY_ADMIN_PASSWORD__FILE
value: /etc/secrets/admin-pass
- name: GF_SESSION_PROVIDER_CONFIG__FILE
value: /etc/secrets/provider-config
- name: GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET__FILE
value: /etc/secrets/keycloak-secret

- name: PROMETHEUS_AUTH_USER
valueFrom:
secretKeyRef:
name: prometheus-auth
key: username
- name: PROMETHEUS_AUTH_PASSWORD
valueFrom:
secretKeyRef:
name: prometheus-auth
key: password

volumes:
- name: secrets
hostPath:
path: /opt/share/kubernetes/secrets/grafana
type: Directory

envFrom:
- secretRef:
name: grafana-secret
dnsPolicy: ClusterFirst
dnsConfig:
searches:
Expand All @@ -100,8 +58,19 @@ spec:
apiVersion: v1
kind: Secret
metadata:
name: prometheus-auth
name: grafana-secret
type: Opaque
stringData:
username: ocfgrafana
password: "<%= prometheus_pass %>"
GF_SERVER_ROOT_URL: "https://grafana.ocf.berkeley.edu"
Copy link
Member

Choose a reason for hiding this comment

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

I don't know what the established convention is here, though I have assumed Kubernetes secrets should be reserved for... things that are actually secret.

Grafana makes this even easier for us-- we don't have to use Kubernetes "Secrets" at all, since we can place passwords in individual files in the Puppet private share and point to them with GF_SETTINGNAME__FILE options (see GF_DATABASE_PASSWORD__FILE above for an example). I slightly prefer this because I think our templating code for secrets is a little weird (I don't like how it passes through Jenkins).

It's probably not a huge deal either way, though I'd recommend consolidating on one way instead of the awkward hybrid we have now.

Copy link
Member

Choose a reason for hiding this comment

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

agree that non-secrets should just be specified in a configmap or directly in the pod template, not in a Secret resource. I don't think there is a problem with templates over files (in fact I like the templating system better, it's more clear what's going on).

GF_DATABASE_TYPE: mysql
GF_DATABASE_HOST: mysql
GF_DATABASE_NAME: ocfgrafana
GF_DATABASE_USER: ocfgrafana
GF_SESSION_PROVIDER: mysql
GF_SESSION_COOKIE_SECURE: "true"
GF_DATABASE_PASSWORD: "<%= mysql_pass %>"
GF_SECURITY_ADMIN_PASSWORD: "<%= admin_pass %>"
GF_SESSION_PROVIDER_CONFIG: "<%= provider_config %>"
GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET: "<%= keycloak_secret %>"
PROMETHEUS_AUTH_USER: ocfgrafana
PROMETHEUS_AUTH_PASSWORD: "<%= prometheus_pass %>"
16 changes: 16 additions & 0 deletions provisioning/datasources/mysql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: 1

datasources:
- name: MySQL Printing
type: mysql
url: mysql
database: ocfprinting
user: $GF_DATABASE_USER
password: $GF_DATABASE_PASSWORD

- name: MySQL Stats
type: mysql
url: mysql
database: ocfstats
user: $GF_DATABASE_USER
password: $GF_DATABASE_PASSWORD