Back to Charts

⚠️ DEPRECATED

stable/grafana/README.md

latest30.2 KB
Original Source

⚠️ DEPRECATED

This chart was moved to https://github.com/grafana/helm2-grafana

Grafana Helm Chart

  • Installs the web dashboarding system Grafana

TL;DR;

console
$ helm install stable/grafana

Installing the Chart

To install the chart with the release name my-release:

console
$ helm install --name my-release stable/grafana

Uninstalling the Chart

To uninstall/delete the my-release deployment:

console
$ helm delete my-release

The command removes all the Kubernetes components associated with the chart and deletes the release.

Upgrading an existing Release to a new major version

A major chart version change (like v1.2.3 -> v2.0.0) indicates that there is an incompatible breaking change needing manual actions.

To 4.0.0 (And 3.12.1)

This version requires Helm >= 2.12.0.

To 5.0.0

You have to add --force to your helm upgrade command as the labels of the chart have changed.

Configuration

ParameterDescriptionDefault
replicasNumber of nodes1
podDisruptionBudget.minAvailablePod disruption minimum availablenil
podDisruptionBudget.maxUnavailablePod disruption maximum unavailablenil
deploymentStrategyDeployment strategy{ "type": "RollingUpdate" }
livenessProbeLiveness Probe settings{ "httpGet": { "path": "/api/health", "port": 3000 } "initialDelaySeconds": 60, "timeoutSeconds": 30, "failureThreshold": 10 }
readinessProbeReadiness Probe settings{ "httpGet": { "path": "/api/health", "port": 3000 } }
securityContextDeployment securityContext{"runAsUser": 472, "runAsGroup": 472, "fsGroup": 472}
priorityClassNameName of Priority Class to assign podsnil
image.repositoryImage repositorygrafana/grafana
image.tagImage tag (Must be >= 5.0.0)7.0.3
image.shaImage sha (optional)17cbd08b9515fda889ca959e9d72ee6f3327c8f1844a3336dfd952134f38e2fe
image.pullPolicyImage pull policyIfNotPresent
image.pullSecretsImage pull secrets{}
service.typeKubernetes service typeClusterIP
service.portKubernetes port where service is exposed80
service.portNameName of the port on the serviceservice
service.targetPortInternal service is port3000
service.nodePortKubernetes service nodePortnil
service.annotationsService annotations{}
service.labelsCustom labels{}
service.clusterIPinternal cluster service IPnil
service.loadBalancerIPIP address to assign to load balancer (if supported)nil
service.loadBalancerSourceRangeslist of IP CIDRs allowed access to lb (if supported)[]
service.externalIPsservice external IP addresses[]
extraExposePortsAdditional service ports for sidecar containers[]
hostAliasesadds rules to the pod's /etc/hosts[]
ingress.enabledEnables Ingressfalse
ingress.annotationsIngress annotations (values are templated){}
ingress.labelsCustom labels{}
ingress.pathIngress accepted path/
ingress.hostsIngress accepted hostnames["chart-example.local"]
ingress.extraPathsIngress extra paths to prepend to every host configuration. Useful when configuring custom actions with AWS ALB Ingress Controller.[]
ingress.tlsIngress TLS configuration[]
resourcesCPU/Memory resource requests/limits{}
nodeSelectorNode labels for pod assignment{}
tolerationsToleration labels for pod assignment[]
affinityAffinity settings for pod assignment{}
extraInitContainersInit containers to add to the grafana pod{}
extraContainersSidecar containers to add to the grafana pod{}
extraContainerVolumesVolumes that can be mounted in sidecar containers[]
schedulerNameName of the k8s scheduler (other than default)nil
persistence.enabledUse persistent volume to store datafalse
persistence.typeType of persistence (pvc or statefulset)pvc
persistence.sizeSize of persistent volume claim10Gi
persistence.existingClaimUse an existing PVC to persist datanil
persistence.storageClassNameType of persistent volume claimnil
persistence.accessModesPersistence access modes[ReadWriteOnce]
persistence.annotationsPersistentVolumeClaim annotations{}
persistence.finalizersPersistentVolumeClaim finalizers[ "kubernetes.io/pvc-protection" ]
persistence.subPathMount a sub dir of the persistent volumenil
initChownData.enabledIf false, don't reset data ownership at startuptrue
initChownData.image.repositoryinit-chown-data container image repositorybusybox
initChownData.image.taginit-chown-data container image tag1.31.1
initChownData.image.shainit-chown-data container image sha (optional)""
initChownData.image.pullPolicyinit-chown-data container image pull policyIfNotPresent
initChownData.resourcesinit-chown-data pod resource requests & limits{}
schedulerNameAlternate scheduler namenil
envExtra environment variables passed to pods{}
envValueFromEnvironment variables from alternate sources. See the API docs on EnvVarSource for format details.{}
envFromSecretName of a Kubernetes secret (must be manually created in the same namespace) containing values to be added to the environment. Can be templated""
envRenderSecretSensible environment variables passed to pods and stored as secret{}
extraSecretMountsAdditional grafana server secret mounts[]
extraVolumeMountsAdditional grafana server volume mounts[]
extraConfigmapMountsAdditional grafana server configMap volume mounts[]
extraEmptyDirMountsAdditional grafana server emptyDir volume mounts[]
pluginsPlugins to be loaded along with Grafana[]
datasourcesConfigure grafana datasources (passed through tpl){}
notifiersConfigure grafana notifiers{}
dashboardProvidersConfigure grafana dashboard providers{}
dashboardsDashboards to import{}
dashboardsConfigMapsConfigMaps reference that contains dashboards{}
grafana.iniGrafana's primary configuration{}
ldap.enabledEnable LDAP authenticationfalse
ldap.existingSecretThe name of an existing secret containing the ldap.toml file, this must have the key ldap-toml.""
ldap.configGrafana's LDAP configuration""
annotationsDeployment annotations{}
labelsDeployment labels{}
podAnnotationsPod annotations{}
podLabelsPod labels{}
podPortNameName of the grafana port on the podgrafana
sidecar.image.repositorySidecar image repositorykiwigrid/k8s-sidecar
sidecar.image.tagSidecar image tag0.1.151
sidecar.image.shaSidecar image sha (optional)""
sidecar.imagePullPolicySidecar image pull policyIfNotPresent
sidecar.resourcesSidecar resources{}
sidecar.enableUniqueFilenamesSets the kiwigrid/k8s-sidecar UNIQUE_FILENAMES environment variablefalse
sidecar.dashboards.enabledEnables the cluster wide search for dashboards and adds/updates/deletes them in grafanafalse
sidecar.dashboards.SCProviderEnables creation of sidecar providertrue
sidecar.dashboards.provider.nameUnique name of the grafana providersidecarProvider
sidecar.dashboards.provider.orgidId of the organisation, to which the dashboards should be added1
sidecar.dashboards.provider.folderLogical folder in which grafana groups dashboards""
sidecar.dashboards.provider.disableDeleteActivate to avoid the deletion of imported dashboardsfalse
sidecar.dashboards.provider.allowUiUpdatesAllow updating provisioned dashboards from the UIfalse
sidecar.dashboards.provider.typeProvider typefile
sidecar.dashboards.watchMethodMethod to use to detect ConfigMap changes. With WATCH the sidecar will do a WATCH requests, with SLEEP it will list all ConfigMaps, then sleep for 60 seconds.WATCH
sidecar.skipTlsVerifySet to true to skip tls verification for kube api callsnil
sidecar.dashboards.labelLabel that config maps with dashboards should have to be addedgrafana_dashboard
sidecar.dashboards.folderFolder in the pod that should hold the collected dashboards (unless sidecar.dashboards.defaultFolderName is set). This path will be mounted./tmp/dashboards
sidecar.dashboards.defaultFolderNameThe default folder name, it will create a subfolder under the sidecar.dashboards.folder and put dashboards in there insteadnil
sidecar.dashboards.searchNamespaceIf specified, the sidecar will search for dashboard config-maps inside this namespace. Otherwise the namespace in which the sidecar is running will be used. It's also possible to specify ALL to search in all namespacesnil
sidecar.datasources.enabledEnables the cluster wide search for datasources and adds/updates/deletes them in grafanafalse
sidecar.datasources.labelLabel that config maps with datasources should have to be addedgrafana_datasource
sidecar.datasources.searchNamespaceIf specified, the sidecar will search for datasources config-maps inside this namespace. Otherwise the namespace in which the sidecar is running will be used. It's also possible to specify ALL to search in all namespacesnil
sidecar.notifiers.enabledEnables the cluster wide search for notifiers and adds/updates/deletes them in grafanafalse
sidecar.notifiers.labelLabel that config maps with notifiers should have to be addedgrafana_notifier
sidecar.notifiers.searchNamespaceIf specified, the sidecar will search for notifiers config-maps (or secrets) inside this namespace. Otherwise the namespace in which the sidecar is running will be used. It's also possible to specify ALL to search in all namespacesnil
smtp.existingSecretThe name of an existing secret containing the SMTP credentials.""
smtp.userKeyThe key in the existing SMTP secret containing the username."user"
smtp.passwordKeyThe key in the existing SMTP secret containing the password."password"
admin.existingSecretThe name of an existing secret containing the admin credentials.""
admin.userKeyThe key in the existing admin secret containing the username."admin-user"
admin.passwordKeyThe key in the existing admin secret containing the password."admin-password"
serviceAccount.annotationsServiceAccount annotations
serviceAccount.createCreate service accounttrue
serviceAccount.nameService account name to use, when empty will be set to created account if serviceAccount.create is set else to default``
serviceAccount.nameTestService account name to use for test, when empty will be set to created account if serviceAccount.create is set else to default``
rbac.createCreate and use RBAC resourcestrue
rbac.namespacedCreates Role and Rolebinding instead of the default ClusterRole and ClusteRoleBindings for the grafana instancefalse
rbac.pspEnabledCreate PodSecurityPolicy (with rbac.create, grant roles permissions as well)true
rbac.pspUseAppArmorEnforce AppArmor in created PodSecurityPolicy (requires rbac.pspEnabled)true
rbac.extraRoleRulesAdditional rules to add to the Role[]
rbac.extraClusterRoleRulesAdditional rules to add to the ClusterRole[]
commandDefine command to be executed by grafana container at startupnil
testFramework.enabledWhether to create test-related resourcestrue
testFramework.imagetest-framework image repository.bats/bats
testFramework.tagtest-framework image tag.v1.1.0
testFramework.imagePullPolicytest-framework image pull policy.IfNotPresent
testFramework.securityContexttest-framework securityContext{}
downloadDashboards.envEnvironment variables to be passed to the download-dashboards container{}
downloadDashboards.resourcesResources of download-dashboards container{}
downloadDashboardsImage.repositoryCurl docker image repocurlimages/curl
downloadDashboardsImage.tagCurl docker image tag7.70.0
downloadDashboardsImage.shaCurl docker image sha (optional)""
downloadDashboardsImage.pullPolicyCurl docker image pull policyIfNotPresent
namespaceOverrideOverride the deployment namespace"" (Release.Namespace)

Example ingress with path

With grafana 6.3 and above

yaml
grafana.ini:
  server:
    domain: monitoring.example.com
    root_url: "%(protocol)s://%(domain)s/grafana"
    serve_from_sub_path: true
ingress:
  enabled: true
  hosts:
    - "monitoring.example.com"
  path: "/grafana"

Example of extraVolumeMounts

yaml
- extraVolumeMounts:
  - name: plugins
    mountPath: /var/lib/grafana/plugins
    subPath: configs/grafana/plugins
    existingClaim: existing-grafana-claim
    readOnly: false

Import dashboards

There are a few methods to import dashboards to Grafana. Below are some examples and explanations as to how to use each method:

yaml
dashboards:
  default:
    some-dashboard:
      json: |
        {
          "annotations":

          ...
          # Complete json file here
          ...

          "title": "Some Dashboard",
          "uid": "abcd1234",
          "version": 1
        }
    custom-dashboard:
      # This is a path to a file inside the dashboards directory inside the chart directory
      file: dashboards/custom-dashboard.json
    prometheus-stats:
      # Ref: https://grafana.com/dashboards/2
      gnetId: 2
      revision: 2
      datasource: Prometheus
    local-dashboard:
      url: https://raw.githubusercontent.com/user/repository/master/dashboards/dashboard.json

BASE64 dashboards

Dashboards could be storaged in a server that does not return JSON directly and instead of it returns a Base64 encoded file (e.g. Gerrit) A new parameter has been added to the url use case so if you specify a b64content value equals to true after the url entry a Base64 decoding is applied before save the file to disk. If this entry is not set or is equals to false not decoding is applied to the file before saving it to disk.

Gerrit use case:

Gerrit API for download files has the following schema: https://yourgerritserver/a/{project-name}/branches/{branch-id}/files/{file-id}/content where {project-name} and {file-id} usualy has '/' in their values and so they MUST be replaced by %2F so if project-name is user/repo, branch-id is master and file-id is equals to dir1/dir2/dashboard the url value is https://yourgerritserver/a/user%2Frepo/branches/master/files/dir1%2Fdir2%2Fdashboard/content

Sidecar for dashboards

If the parameter sidecar.dashboards.enabled is set, a sidecar container is deployed in the grafana pod. This container watches all configmaps (or secrets) in the cluster and filters out the ones with a label as defined in sidecar.dashboards.label. The files defined in those configmaps are written to a folder and accessed by grafana. Changes to the configmaps are monitored and the imported dashboards are deleted/updated.

A recommendation is to use one configmap per dashboard, as a reduction of multiple dashboards inside one configmap is currently not properly mirrored in grafana.

Example dashboard config:

apiVersion: v1
kind: ConfigMap
metadata:
  name: sample-grafana-dashboard
  labels:
     grafana_dashboard: "1"
data:
  k8s-dashboard.json: |-
  [...]

Sidecar for datasources

If the parameter sidecar.datasources.enabled is set, an init container is deployed in the grafana pod. This container lists all secrets (or configmaps, though not recommended) in the cluster and filters out the ones with a label as defined in sidecar.datasources.label. The files defined in those secrets are written to a folder and accessed by grafana on startup. Using these yaml files, the data sources in grafana can be imported. The secrets must be created before helm install so that the datasources init container can list the secrets.

Secrets are recommended over configmaps for this usecase because datasources usually contain private data like usernames and passwords. Secrets are the more appropriate cluster ressource to manage those.

Example datasource config adapted from Grafana:

apiVersion: v1
kind: Secret
metadata:
  name: sample-grafana-datasource
  labels:
     grafana_datasource: "1"
type: Opaque
stringData:
  datasource.yaml: |-
    # config file version
    apiVersion: 1

    # list of datasources that should be deleted from the database
    deleteDatasources:
      - name: Graphite
        orgId: 1

    # list of datasources to insert/update depending
    # whats available in the database
    datasources:
      # <string, required> name of the datasource. Required
    - name: Graphite
      # <string, required> datasource type. Required
      type: graphite
      # <string, required> access mode. proxy or direct (Server or Browser in the UI). Required
      access: proxy
      # <int> org id. will default to orgId 1 if not specified
      orgId: 1
      # <string> url
      url: http://localhost:8080
      # <string> database password, if used
      password:
      # <string> database user, if used
      user:
      # <string> database name, if used
      database:
      # <bool> enable/disable basic auth
      basicAuth:
      # <string> basic auth username
      basicAuthUser:
      # <string> basic auth password
      basicAuthPassword:
      # <bool> enable/disable with credentials headers
      withCredentials:
      # <bool> mark as default datasource. Max one per org
      isDefault:
      # <map> fields that will be converted to json and stored in json_data
      jsonData:
         graphiteVersion: "1.1"
         tlsAuth: true
         tlsAuthWithCACert: true
      # <string> json object of data that will be encrypted.
      secureJsonData:
        tlsCACert: "..."
        tlsClientCert: "..."
        tlsClientKey: "..."
      version: 1
      # <bool> allow users to edit datasources from the UI.
      editable: false

Sidecar for notifiers

If the parameter sidecar.notifiers.enabled is set, an init container is deployed in the grafana pod. This container lists all secrets (or configmaps, though not recommended) in the cluster and filters out the ones with a label as defined in sidecar.notifiers.label. The files defined in those secrets are written to a folder and accessed by grafana on startup. Using these yaml files, the notification channels in grafana can be imported. The secrets must be created before helm install so that the notifiers init container can list the secrets.

Secrets are recommended over configmaps for this usecase because alert notification channels usually contain private data like SMTP usernames and passwords. Secrets are the more appropriate cluster ressource to manage those.

Example datasource config adapted from Grafana:

notifiers:
  - name: notification-channel-1
    type: slack
    uid: notifier1
    # either
    org_id: 2
    # or
    org_name: Main Org.
    is_default: true
    send_reminder: true
    frequency: 1h
    disable_resolve_message: false
    # See `Supported Settings` section for settings supporter for each
    # alert notification type.
    settings:
      recipient: 'XXX'
      token: 'xoxb'
      uploadImage: true
      url: https://slack.com

delete_notifiers:
  - name: notification-channel-1
    uid: notifier1
    org_id: 2
  - name: notification-channel-2
    # default org_id: 1

How to serve Grafana with a path prefix (/grafana)

In order to serve Grafana with a prefix (e.g., http://example.com/grafana), add the following to your values.yaml.

yaml
ingress:
  enabled: true
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/use-regex: "true"

  path: /grafana/?(.*)
  hosts:
    - k8s.example.dev

grafana.ini:
  server:
    root_url: http://localhost:3000/grafana # this host can be localhost