-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
salt: Dynamic rendering of Grafana INI config
Extract Grafana INI configuration and put it in a CSC ConfigMap to allow dynamic configuration. Re-render the chart with the following command: ``` ./charts/render.py prometheus-operator \ charts/kube-prometheus-stack.yaml \ charts/kube-prometheus-stack/ \ --namespace metalk8s-monitoring \ --service-config grafana \ metalk8s-grafana-config \ metalk8s/addons/prometheus-operator/config/grafana.yaml.j2 \ metalk8s-monitoring \ --service-config prometheus \ metalk8s-prometheus-config \ metalk8s/addons/prometheus-operator/config/prometheus.yaml \ metalk8s-monitoring \ --service-config alertmanager \ metalk8s-alertmanager-config \ metalk8s/addons/prometheus-operator/config/alertmanager.yaml \ metalk8s-monitoring \ --service-config dex \ metalk8s-dex-config \ metalk8s/addons/dex/config/dex.yaml.j2 metalk8s-auth \ --drop-prometheus-rules charts/drop-prometheus-rules.yaml \ --patch 'PrometheusRule,metalk8s-monitoring,prometheus-operator-kubernetes-system-kubelet,spec:groups:0:rules:1:for,"5m"' \ --remove-manifest ConfigMap prometheus-operator-grafana \ > salt/metalk8s/addons/prometheus-operator/deployed/chart.sls ```
- Loading branch information
1 parent
5f55bcf
commit b268f49
Showing
7 changed files
with
86 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
salt/metalk8s/addons/prometheus-operator/config/grafana.yaml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!jinja|yaml | ||
|
||
{%- if pillar.addons.dex.enabled %} | ||
{%- set dex_defaults = salt.slsutil.renderer('salt://metalk8s/addons/dex/config/dex.yaml.j2', saltenv=saltenv) %} | ||
{%- set dex = salt.metalk8s_service_configuration.get_service_conf('metalk8s-auth', 'metalk8s-dex-config', dex_defaults) %} | ||
{%- endif %} | ||
{%- set control_plane_ingress_endpoint = salt.metalk8s_network.get_control_plane_ingress_endpoint() %} | ||
|
||
# Configuration of the Grafana service | ||
apiVersion: addons.metalk8s.scality.com | ||
kind: GrafanaConfig | ||
spec: | ||
# Configure the Grafana Deployment | ||
deployment: | ||
replicas: 1 | ||
config: | ||
grafana.ini: | ||
analytics: | ||
check_for_updates: true | ||
reporting_enabled: falseœ | ||
paths: | ||
data: /var/lib/grafana/ | ||
logs: /var/log/grafana | ||
plugins: /var/lib/grafana/plugins | ||
provisioning: /etc/grafana/provisioning | ||
log: | ||
mode: console | ||
grafana_net: | ||
url: https://grafana.net | ||
server: | ||
root_url: "{{ control_plane_ingress_endpoint }}/grafana" | ||
{%- if pillar.addons.dex.enabled %} | ||
auth: | ||
oauth_auto_login: true | ||
auth.generic_oauth: | ||
api_url: "{{ control_plane_ingress_endpoint }}/oidc/userinfo" | ||
auth_url: "{{ control_plane_ingress_endpoint }}/oidc/auth" | ||
client_id: grafana-ui | ||
client_secret: 4lqK98NcsWG5qBRHJUqYM1 | ||
enabled: true | ||
role_attribute_path: contains(`{{ dex.spec.config.staticPasswords | map(attribute='email') | list | tojson }}`, email) && 'Admin' | ||
scopes: openid profile email groups | ||
tls_skip_verify_insecure: true | ||
token_url: "{{ control_plane_ingress_endpoint }}/oidc/token" | ||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
salt/metalk8s/addons/prometheus-operator/deployed/grafana-ini-configmap.sls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{%- set grafana_defaults = salt.slsutil.renderer( | ||
'salt://metalk8s/addons/prometheus-operator/config/grafana.yaml.j2', | ||
saltenv=saltenv | ||
) | ||
%} | ||
|
||
{%- set grafana = salt.metalk8s_service_configuration.get_service_conf( | ||
'metalk8s-monitoring', 'metalk8s-grafana-config', grafana_defaults | ||
) | ||
%} | ||
|
||
Create Grafana INI Configuration ConfigMap: | ||
metalk8s_kubernetes.object_present: | ||
- manifest: | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app.kubernetes.io/instance: prometheus-operator | ||
app.kubernetes.io/managed-by: salt | ||
app.kubernetes.io/name: grafana | ||
app.kubernetes.io/part-of: metalk8s | ||
name: prometheus-operator-grafana | ||
namespace: metalk8s-monitoring | ||
data: | ||
grafana.ini: |- | ||
{%- for key, value in grafana.spec.config["grafana.ini"].items() %} | ||
[{{ key }}] | ||
{%- for element, element_value in value.items() %} | ||
{{ element }} = {{ element_value }} | ||
{%- endfor %} | ||
{%- endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters