-
I am trying to change the default password for admin I have tried the solutions given in #514 The issue is the grafana-deployment.yaml that is generated/rendered is missing the environment variables (GF_SECURITY_ADMIN_USER, GF_SECURITY_ADMIN_PASSWORD) kube-prometheus version - 0.3 My custom jsonnet file local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
}, { ['setup/0namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } + |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
(I converted the issue to a discussion as I feel that format works better for these types of questions) You were super close, the only thing is that the local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
{
_config+:: {
namespace: 'monitoring',
},
grafana+:: {
deployment+: {
spec+: {
template+: {
spec+: {
containers: [
if c.name == 'grafana' then c {
env: [
{
name: 'GF_SECURITY_ADMIN_USER',
valueFrom: {
secretKeyRef: {
name: 'grafana-credentials',
key: 'user',
},
},
},
{
name: 'GF_SECURITY_ADMIN_PASSWORD',
valueFrom: {
secretKeyRef: {
name: 'grafana-credentials',
key: 'password',
},
},
},
],
}
for c in super.containers
],
},
},
},
},
},
};
{ ['setup/0namespace-' + name]: kp.kubePrometheus[name] for name in std.objectFields(kp.kubePrometheus) } +
{
['setup/prometheus-operator-' + name]: kp.prometheusOperator[name]
for name in std.filter((function(name) name != 'serviceMonitor'), std.objectFields(kp.prometheusOperator))
} +
// serviceMonitor is separated so that it can be created after the CRDs are ready
{ 'prometheus-operator-serviceMonitor': kp.prometheusOperator.serviceMonitor } +
{ ['node-exporter-' + name]: kp.nodeExporter[name] for name in std.objectFields(kp.nodeExporter) } +
{ ['kube-state-metrics-' + name]: kp.kubeStateMetrics[name] for name in std.objectFields(kp.kubeStateMetrics) } +
{ ['alertmanager-' + name]: kp.alertmanager[name] for name in std.objectFields(kp.alertmanager) } +
{ ['prometheus-' + name]: kp.prometheus[name] for name in std.objectFields(kp.prometheus) } +
{ ['prometheus-adapter-' + name]: kp.prometheusAdapter[name] for name in std.objectFields(kp.prometheusAdapter) } +
{ ['grafana-' + name]: kp.grafana[name] for name in std.objectFields(kp.grafana) } |
Beta Was this translation helpful? Give feedback.
-
Thank you. That did the trick. |
Beta Was this translation helpful? Give feedback.
(I converted the issue to a discussion as I feel that format works better for these types of questions)
You were super close, the only thing is that the
grafana
object you specified is under_config
, whereas it should be a sibling. I tend to write jsonnet code like this rather by iterating over all containers, even if there may currently only be one (you never know what happens in the future 🙂 ). This worked for me and is in the style how I would write it: