-
Notifications
You must be signed in to change notification settings - Fork 413
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
[Bug] Deployed GrafanaDashboards don't use nameSuffixHashes of ConfigMaps #869
Comments
@bergerst is the issue here that when using kustomize, the name of the configmap cannot be known? And if you suppress this behaviour using the flag, then the operator won't be notified when the configmap is updated? |
@pb82 Yes, you're right. After I researched some more using different search keywords than before, I was able to find this: https://github.com/kubernetes-sigs/kustomize/tree/master/examples/transformerconfigs#name-reference-transformer I've added a transformer in this branch and it works: https://github.com/bergerst/grafana-operator-nameSuffixHash/tree/transformer-configuration The resulting file looks like this: apiVersion: v1
data:
simple-dashboard.json: "{\r\n \"id\": null,\r\n \"title\": \"Simple Dashboard
from Config Map\",\r\n \"tags\": [],\r\n \"style\": \"dark\",\r\n \"timezone\":
\"browser\",\r\n \"editable\": true,\r\n \"hideControls\": false,\r\n \"graphTooltip\":
1,\r\n \"panels\": [],\r\n \"time\": {\r\n \"from\": \"now-6h\",\r\n
\ \"to\": \"now\"\r\n },\r\n \"timepicker\": {\r\n \"time_options\":
[],\r\n \"refresh_intervals\": []\r\n },\r\n \"templating\": {\r\n
\ \"list\": []\r\n },\r\n \"annotations\": {\r\n \"list\":
[]\r\n },\r\n \"refresh\": \"5s\",\r\n \"schemaVersion\": 17,\r\n \"version\":
0,\r\n \"links\": []\r\n}"
kind: ConfigMap
metadata:
name: simple-dashboard-from-cm-bg87454kb7
---
apiVersion: integreatly.org/v1alpha1
kind: GrafanaDashboard
metadata:
labels:
app: grafana
name: grafana-dashboard-from-config-map
spec:
configMapRef:
key: simple-dashboard.json
name: simple-dashboard-from-cm-bg87454kb7 The 2nd part of the solution described in kubernetes-sigs/kustomize#97 (comment) can probably only be used if you have the CRD JSON in your local file system or hosted somewhere. So if the CRD YAML in this repo contains the apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
crds:
- https://raw.githubusercontent.com/grafana-operator/grafana-operator/master/bundle/manifests/integreatly.org_grafanadashboards.yaml
resources:
- dashboard.yaml
configMapGenerator:
- name: simple-dashboard-from-cm
files:
- simple-dashboard.json But since downloading the CRD YAML on every deployment is not failsafe in case of downtimes, users should use a local copy of the CRD YAML file from this repo. I'll definitely use the name reference transformer until the CRD YAML is properly annotated. |
@bergerst I'm closing this, please reopen if you keep seeing issues. |
@pb82 Users can only reopen issues if they closed them themselves. Regarding my issue, I tried using the CRD file feature of kustomize, but it's not documented well and doesn't accept any current form of OpenAPI CRD definition. Seems like the solution of annotating the fields with |
Describe the bug
Normally, when you use kustomize to create a Deployment referencing a ConfigMap, the ConfigMap will be deployed with a hash suffix in the name. (e.g. app-config-88g924ftgk). The Deployment will reference the suffixed name instead of using the original name.
When you update the ConfigMap and redeploy, the Deployment will then reference the ConfigMap with the new hash suffix.
For the GrafanaDashboard objects, this is not how it works. For example if you deploy https://github.com/bergerst/grafana-operator-nameSuffixHash with kustomize, the GrafanaDashboard will use "simple-dashboard-from-cm" while the ConfigMap is actually named something like "simple-dashboard-from-cm-bg87454kb7".
This can be circumvented using
disableNameSuffixHash: true
, but then the dashboards in Grafana will not be updated when the ConfigMap changes.Version
4.8.0
To Reproduce
Steps to reproduce the behavior:
Expected behavior
If the ConfigMap is changed with nameSuffixHash enabled, the deployed GrafanaDashboard object should reference the ConfigMap with the nameSuffixHash.
Suspect component/Location where the bug might be occuring
The CRD is incorrectly defined here https://github.com/grafana-operator/grafana-operator/blob/a7d7fa58455730a734baf20e6bee8843c6e0f1af/bundle/manifests/integreatly.org_grafanadashboards.yaml#L37
I have found this guide on how to correctly implement
configMapRef
fields, but I'm not sure how to correctly apply it: kubernetes-sigs/kustomize#97 (comment)Runtime (please complete the following information):
The text was updated successfully, but these errors were encountered: