Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/grafana] Utilize 5.x datasource and dashboard import tooling and general refactor #4713

Merged
merged 6 commits into from
Apr 10, 2018
Merged

[stable/grafana] Utilize 5.x datasource and dashboard import tooling and general refactor #4713

merged 6 commits into from
Apr 10, 2018

Conversation

rtluckie
Copy link
Contributor

@rtluckie rtluckie commented Apr 4, 2018

  • utilize new features of grafana 5.x to configure datasources and dashboards
    • removed all jobs
  • update ingress manifest to align with helm create
  • remove opinionated affinity config
  • consolidate configmaps
  • cleanup and refactor values.yaml
  • removed unnecessary nesting from values.yaml
  • add initContainer to download dashboards
  • update labels and selectors to align with helm best practices
  • general cleanup to align with helm best practices/patterns observed in helm create
  • update values, NOTES, README and _helpers accordingly
  • cleanup service manifest to allow more flexibility
  • add rtluckie to maintainers
  • bump chart version

NOTE: This change is not backwards compatible with grafana < 5.0.0

Tested on:
k8s 1.8.10, 1.9.6 and 1.10.0

Limitations:

  • Imported dashboards only support a single datasource

- rename manifest to align with helm create
- remove unnecessary manifests
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 4, 2018
@rtluckie
Copy link
Contributor Author

rtluckie commented Apr 5, 2018

/assign @unguiculus

@rtluckie
Copy link
Contributor Author

rtluckie commented Apr 5, 2018

/assign @foxish

- utilize new features of grafana 5.x to configure datasources and dashboards
  - remove all jobs
- update ingress manifest to align with helm create
- consolidate configmaps
- cleanup and refactor values.yaml
- remove unnecessary nesting from values.yaml
- add initContainer to download dashboards
- update labels and selectors to align with helm best practices
- general cleanup to align with helm best practices/patterns observed in `helm create`
- update values, NOTES, README and _helpers accordingly
- cleanup service manifest to allow more flexibility
- add rtluckie to maintainers
- bump chart version

Tested on:
k8s 1.8.10, 1.9.6 and 1.10.0

Limitations:
- Imported dashboards only support a single datasource
image: busybox
command: ['sh', '-c', 'cp /tmp/config-volume-configmap/* /tmp/config-volume 2>/dev/null || true; cp /tmp/dashboard-volume-configmap/* /tmp/dashboard-volume 2>/dev/null || true']
- name: download-dashboards
image: appropriate/curl
Copy link
Contributor

@DaytonG DaytonG Apr 5, 2018

Choose a reason for hiding this comment

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

Could this also be a setting in values.yaml? Use case there: using a private mirror for deployment

Another little thing: this init container is gonna launch even if we have 0 dashboards to download (perhaps you only provide them via config or retrieve them from grafana via ID). Would be nice if there was some simple way to disable this container or have it only launch when it's necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DaytonG Sure. I can make the download-dashboard image a setting in values.yaml

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re: the init container: It was my intention to have it only run when there were dashboards to download, but I haven't been able to figure out how. I will restructure .Values.dashboards to hopefully make it a bit easier.
Any help would be appreciated!

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm. The simplest change could be to just move the downloaded dashboards to its own variable and process it independently of the dashboards provided locally. Could potentially increase configuration complexity a little, but it may also simplify some of the template code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about that, but I'd like to avoid the configuration complexity. I'll ruminate on it for a while. Even if the initContainer runs unnecessarily, the image is light (~7mb) and with nothing to download the script is benign.

# disableDeletion: false
# editable: true
# options:
# path: /var/lib/grafana/dashboards
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps it's just me, but I find that I always need to provision dashboards. It would be ideal if provisioning was enabled by default, so I just needed to fill in dashboards

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DaytonG I think its a general best practice to have minimal sane defaults in values.yaml

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea, I can see that. My only concern is if someone tried to set dashboards but didn't know they also needed to configure providioners it may be difficult to figure out what to do. Perhaps a comment would do for dashboards saying "if you need this, you must uncomment the providers configuration"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment to values.yaml

level: info
dashboards.json:
enabled: true
path: /var/lib/grafana/dashboards
Copy link
Contributor

Choose a reason for hiding this comment

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

In G5, dashboards.json is deprecated. Since this change is not backwards compatible with G4, could we just nuke the section, for clarity?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DaytonG Good catch. Fixed

{{ $key }}: |
{{ toYaml $value | indent 4 }}
{{- end -}}
{{- end -}}
Copy link
Contributor

Choose a reason for hiding this comment

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

The datasources configuration can contain passwords and other sensitive information. Seems like it should go into a Secret instead of a ConfigMap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. grafana.ini should probably also be a secret. Will fix in follow-up PR.

@@ -1,5 +1,5 @@
name: grafana
version: 0.8.5
version: 0.9.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicky: I would argue 1.0.0 is more appropriate here, since this is a backwards incompatible change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@DaytonG
Copy link
Contributor

DaytonG commented Apr 5, 2018

(Sorry, I think I may have posted review comments a little wrong. Not used to making them much here on github).

Overall, I think your PR is much better than mine. We should approve yours.

@timstoop
Copy link
Contributor

timstoop commented Apr 5, 2018

@DaytonG in that case, I recommend you close the other one in favour of this one?

- remove deprecated grafana.ini option
- rework .Values.dashboards to make triggering download initContainer easier
- make initContainer image configurable
- add note to values.yaml regarding dashboards' dependency on dashboardProviders
- bump chart version to 1.0.0
@timstoop
Copy link
Contributor

timstoop commented Apr 6, 2018

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 6, 2018
@DaytonG
Copy link
Contributor

DaytonG commented Apr 6, 2018

/lgtm

@k8s-ci-robot
Copy link
Contributor

@DaytonG: changing LGTM is restricted to assignees, and only kubernetes org members may be assigned issues.

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "grafana.fullname" . }},component={{ .Values.server.name }}" -o jsonpath="{.items[0].metadata.name}")
You can watch the status of by running 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "grafana.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "grafana.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.httpPort -}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the "echo" in this line needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@timstoop good catch! fixed.

- remove unnecessary echo
- fix service.port references
@timstoop
Copy link
Contributor

timstoop commented Apr 6, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 6, 2018
@@ -9,4 +9,6 @@ sources:
maintainers:
- name: Ming Hsieh
email: [email protected]
- name: Ryan Luckie
Copy link
Member

Choose a reason for hiding this comment

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

Use Github usernames

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

{{- if .Values.server.installPlugins }}
grafana-install-plugins: {{ .Values.server.installPlugins | quote }}
{{- if .Values.plugins }}
plugins: {{ default "" .Values.plugins | quote }}
Copy link
Member

Choose a reason for hiding this comment

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

Don't use the default function. Default values should come from values.yaml. Apply everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if (or (eq .Values.service.type "ClusterIP" "") (empty .Values.service.type)) }}
Copy link
Member

Choose a reason for hiding this comment

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

Why would this make sense? eq .Values.service.type "ClusterIP" ""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It really doesn't-- it was a relic from refactor. Fixed.

@unguiculus unguiculus removed the lgtm Indicates that a PR is ready to be merged. label Apr 7, 2018
- use default when using templated value for pv name when existingClaim
  is not defined
@unguiculus
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 10, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: DaytonG, rtluckie, timstoop, unguiculus

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 10, 2018
@k8s-ci-robot k8s-ci-robot merged commit 3672ec1 into helm:master Apr 10, 2018
@rtluckie rtluckie deleted the feature/grafana_rewrite branch April 10, 2018 18:09
@amnk
Copy link

amnk commented Apr 10, 2018

@rtluckie I always get Error: YAML parse error on grafana/templates/dashboards-json-configmap.yaml: error converting YAML to JSON: yaml: line 14: did not find expected key when trying to use this, but I can't figure out what is wrong. My dashboards were working with previous Grafana chart - did we change something with this 1.0 release (except required json key)?

EDIT: I figured the workaround. Basically, $RAW_JSON should be one liner. Otherwise I always get the above output.

@rtluckie
Copy link
Contributor Author

rtluckie commented Apr 10, 2018

@amnk can you post your values.yaml and I will try to help.
Also, please review changes to values.yaml. Specifically, https://github.com/kubernetes/charts/blob/master/stable/grafana/values.yaml#L111

@amnk
Copy link

amnk commented Apr 10, 2018

@rtluckie Thanks for reply :) yeah, I have that all done. And I've figured out the problem - all dashboards definitions should be one-liners in $RAW_JSON, otherwise Helm parser fails. Not sure if it is intended or not, but not vary handy :(

@Jokero
Copy link
Contributor

Jokero commented Apr 11, 2018

@rtluckie Also faced with the same error.
values.yaml https://gist.github.com/Jokero/abd444598e819c961fc773ca7bccd69d

@Jokero
Copy link
Contributor

Jokero commented Apr 11, 2018

If one-liner solution works, it's really not very convenient

@DaytonG
Copy link
Contributor

DaytonG commented Apr 11, 2018

Think I got a fix. In the json-configmap:

{{- if .Values.dashboards }}
  {{- range $key, $value := .Values.dashboards }}
    {{- if hasKey $value "json" }}
  {{ $key }}.json: |
{{ $value.json | indent 4 }}  <-- this line is changed
    {{- end }}
  {{- end }}
{{- end -}}

Basically, the json needed to be indented properly so the YAML could be parsed.

Will make a PR shortly.

@amnk
Copy link

amnk commented Apr 11, 2018

@DaytonG thanks!

@Jokero
Copy link
Contributor

Jokero commented Apr 14, 2018

Is there any working example of values.yaml? Grafana even does not load dashboards from grafana.net

@monotek
Copy link
Collaborator

monotek commented Apr 14, 2018

@Jokero
Copy link
Contributor

Jokero commented Apr 14, 2018

@monotek It does not work. See my example https://gist.github.com/Jokero/abd444598e819c961fc773ca7bccd69d
I tested without custom json dashboard

@monotek
Copy link
Collaborator

monotek commented Apr 14, 2018

I use it for a week like this.

Edit: Seems you're using Minikube.
Please make sure you updated your local helm repo via: "helm repo update"

@Jokero
Copy link
Contributor

Jokero commented Apr 14, 2018

Ok. Figured out that I have to use exactly dashboardProviders.dashboardproviders.yaml but I changed it to be consistent to dashboardProviders.dashboardProviders.yaml (camelCase for both).

nazarewk pushed a commit to nazarewk/charts that referenced this pull request Apr 18, 2018
…and general refactor (helm#4713)

* Refactor grafana

- rename manifest to align with helm create
- remove unnecessary manifests

* Grafana refactor

- utilize new features of grafana 5.x to configure datasources and dashboards
  - remove all jobs
- update ingress manifest to align with helm create
- consolidate configmaps
- cleanup and refactor values.yaml
- remove unnecessary nesting from values.yaml
- add initContainer to download dashboards
- update labels and selectors to align with helm best practices
- general cleanup to align with helm best practices/patterns observed in `helm create`
- update values, NOTES, README and _helpers accordingly
- cleanup service manifest to allow more flexibility
- add rtluckie to maintainers
- bump chart version

Tested on:
k8s 1.8.10, 1.9.6 and 1.10.0

Limitations:
- Imported dashboards only support a single datasource

* Changes from comments

- remove deprecated grafana.ini option
- rework .Values.dashboards to make triggering download initContainer easier
- make initContainer image configurable
- add note to values.yaml regarding dashboards' dependency on dashboardProviders
- bump chart version to 1.0.0

* NOTES fixes

- remove unnecessary echo
- fix service.port references

* More changes from comments

- update name to gh username in Charts.yaml
- cleanup plugins install
- cleanup dashboards install -- don't rely on `defaults`
- cleanup reusing pv claim -- don't reply on `defaults`
- cleanup secrets -- don't rely on `defaults`
- cleanup service manifest -- don't rely `defaults`
- use storageClassName instead of storageClass (don't rely on `defaults`)
- remove redundant defaults from grafana.ini configmap

* Fix small regression

- use default when using templated value for pv name when existingClaim
  is not defined
ichtar pushed a commit to Bestmile/charts that referenced this pull request May 15, 2018
…and general refactor (helm#4713)

* Refactor grafana

- rename manifest to align with helm create
- remove unnecessary manifests

* Grafana refactor

- utilize new features of grafana 5.x to configure datasources and dashboards
  - remove all jobs
- update ingress manifest to align with helm create
- consolidate configmaps
- cleanup and refactor values.yaml
- remove unnecessary nesting from values.yaml
- add initContainer to download dashboards
- update labels and selectors to align with helm best practices
- general cleanup to align with helm best practices/patterns observed in `helm create`
- update values, NOTES, README and _helpers accordingly
- cleanup service manifest to allow more flexibility
- add rtluckie to maintainers
- bump chart version

Tested on:
k8s 1.8.10, 1.9.6 and 1.10.0

Limitations:
- Imported dashboards only support a single datasource

* Changes from comments

- remove deprecated grafana.ini option
- rework .Values.dashboards to make triggering download initContainer easier
- make initContainer image configurable
- add note to values.yaml regarding dashboards' dependency on dashboardProviders
- bump chart version to 1.0.0

* NOTES fixes

- remove unnecessary echo
- fix service.port references

* More changes from comments

- update name to gh username in Charts.yaml
- cleanup plugins install
- cleanup dashboards install -- don't rely on `defaults`
- cleanup reusing pv claim -- don't reply on `defaults`
- cleanup secrets -- don't rely on `defaults`
- cleanup service manifest -- don't rely `defaults`
- use storageClassName instead of storageClass (don't rely on `defaults`)
- remove redundant defaults from grafana.ini configmap

* Fix small regression

- use default when using templated value for pv name when existingClaim
  is not defined
voron pushed a commit to dysnix/helm-charts that referenced this pull request Sep 5, 2018
…and general refactor (helm#4713)

* Refactor grafana

- rename manifest to align with helm create
- remove unnecessary manifests

* Grafana refactor

- utilize new features of grafana 5.x to configure datasources and dashboards
  - remove all jobs
- update ingress manifest to align with helm create
- consolidate configmaps
- cleanup and refactor values.yaml
- remove unnecessary nesting from values.yaml
- add initContainer to download dashboards
- update labels and selectors to align with helm best practices
- general cleanup to align with helm best practices/patterns observed in `helm create`
- update values, NOTES, README and _helpers accordingly
- cleanup service manifest to allow more flexibility
- add rtluckie to maintainers
- bump chart version

Tested on:
k8s 1.8.10, 1.9.6 and 1.10.0

Limitations:
- Imported dashboards only support a single datasource

* Changes from comments

- remove deprecated grafana.ini option
- rework .Values.dashboards to make triggering download initContainer easier
- make initContainer image configurable
- add note to values.yaml regarding dashboards' dependency on dashboardProviders
- bump chart version to 1.0.0

* NOTES fixes

- remove unnecessary echo
- fix service.port references

* More changes from comments

- update name to gh username in Charts.yaml
- cleanup plugins install
- cleanup dashboards install -- don't rely on `defaults`
- cleanup reusing pv claim -- don't reply on `defaults`
- cleanup secrets -- don't rely on `defaults`
- cleanup service manifest -- don't rely `defaults`
- use storageClassName instead of storageClass (don't rely on `defaults`)
- remove redundant defaults from grafana.ini configmap

* Fix small regression

- use default when using templated value for pv name when existingClaim
  is not defined

Signed-off-by: voron <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants