Closed lanmarti closed 4 years ago
I'm not trying to add a new dashboard, the configmap contains a file needed for a cluster-specific problem.
Could you elaborate what it is that you are trying to solve?
Usually, add a new dashboard works by adding a new object to the global grafanaDashboards
object. As we loop over that object to generate the configmaps and volumes those object are added as dashboards automatically.
Basically:
{
grafanaDashboards+:: {
'mydashboard.json':
...
}
}
I'm adding an nsswitch.conf file containing hosts: files dns
so that host aliases are resolved in the correct order. I'm not fully clear about the details, but basically, some go/alpine based containers ignore the hosts file as set by Kubernetes when using hostAlias specifications in the deployment .yaml, unless the nsswitch.conf file is added.
See for example https://github.com/golang/go/issues/22846
I have to use host aliases to make sure the authentication setup for this cluster works correctly. Manually updating the grafana deployment yaml works for now, but obviously adding a few lines to my .jsonnet file is vastly preferred.
@metalmatze thanks for your reply, but this is specifically NOT about dashboards, but a separate configMap, see my previous reply. I already have some custom dashboards up and running, indeed through grafanaDashboards, which works like a charm!
I think this is something that is pretty specific to your environment so I would suggest you to do a patch specific to your problem. A jsonnet patch for this would look something like this:
{
grafana+:: {
deployment+:
{
spec+: {
template+: {
spec+: {
volumes+: [ * volume definition * ],
containers:
std.map(
function(c)
if c.name == 'grafana' then
c {
volumeMounts+: [
* volume mount definition *,
],
}
else
c,
super.containers,
),
},
},
},
},
},
}
Thank you, that did the trick!
What did you do? I'm trying to add a configmap to the grafana deployment, without modifying the original /vendor/grafana/grafana.libsonnet file. However, due to inexperience with jsonnet/ksonnet, I seem to be stuck. By trying to add a new volume, I'm actually overwriting the existing volumes attached to the deployment. I'm looking for a way to add to rather than overwrite the existing volumes, as well as add a mount to the volume mounts of the grafana container that is already defined in grafana.libsonnet.
Did you expect to see some different? Ideally, I would be able to mount the custom config map in the grafana container without modifying grafana.libsonnet itself.
Manifests: I added this block to my own custom.jsonnet file
Relevant parts from grafana.libsonnet
Anything else we need to know?: I'm not trying to add a new dashboard, the configmap contains a file needed for a cluster-specific problem.