diff --git a/stable/grafana/Chart.yaml b/stable/grafana/Chart.yaml index 4c1334b2ad..77f876ba98 100755 --- a/stable/grafana/Chart.yaml +++ b/stable/grafana/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: grafana -version: 3.0.1 +version: 3.1.0 appVersion: 6.0.2 kubeVersion: "^1.8.0-0" description: The leading tool for querying and visualizing time series and metrics. diff --git a/stable/grafana/README.md b/stable/grafana/README.md index 8a686b9ecc..79cd42308a 100644 --- a/stable/grafana/README.md +++ b/stable/grafana/README.md @@ -106,6 +106,9 @@ The command removes all the Kubernetes components associated with the chart and | `rbac.pspEnabled` | Create PodSecurityPolicy (with `rbac.create`, grant roles permissions as well) | `true` | | `rbac.pspUseAppArmor` | Enforce AppArmor in created PodSecurityPolicy (requires `rbac.pspEnabled`) | `true` | | `command` | Define command to be executed by grafana container at startup | `nil` | +| `testFramework.image` | `test-framework` image repository. | `dduportal/bats` | +| `testFramework.tag` | `test-framework` image tag. | `0.4.0` | + ### Example of extraVolumeMounts diff --git a/stable/grafana/templates/tests/test-configmap.yaml b/stable/grafana/templates/tests/test-configmap.yaml new file mode 100644 index 0000000000..da800b04b2 --- /dev/null +++ b/stable/grafana/templates/tests/test-configmap.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "grafana.fullname" . }}-test + labels: + app: {{ template "grafana.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + heritage: "{{ .Release.Service }}" + release: "{{ .Release.Name }}" +data: + run.sh: |- + @test "Test Health" { + url="http://{{ template "grafana.fullname" . }}/api/health" + + code=$(curl -s -o /dev/null -I -w "%{http_code}" $url) + [ "$code" == "200" ] + } diff --git a/stable/grafana/templates/tests/test.yaml b/stable/grafana/templates/tests/test.yaml new file mode 100644 index 0000000000..f50bf29c12 --- /dev/null +++ b/stable/grafana/templates/tests/test.yaml @@ -0,0 +1,42 @@ +apiVersion: v1 +kind: Pod +metadata: + name: {{ template "grafana.fullname" . }}-test + labels: + app: {{ template "grafana.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + heritage: "{{ .Release.Service }}" + release: "{{ .Release.Name }}" + annotations: + "helm.sh/hook": test-success +spec: + initContainers: + - name: test-framework + image: "{{ .Values.testFramework.image}}:{{ .Values.testFramework.tag }}" + command: + - "bash" + - "-c" + - | + set -ex + # copy bats to tools dir + cp -R /usr/local/libexec/ /tools/bats/ + volumeMounts: + - mountPath: /tools + name: tools + containers: + - name: {{ .Release.Name }}-test + image: "{{ .Values.testFramework.image}}:{{ .Values.testFramework.tag }}" + command: ["/tools/bats/bats", "-t", "/tests/run.sh"] + volumeMounts: + - mountPath: /tests + name: tests + readOnly: true + - mountPath: /tools + name: tools + volumes: + - name: tests + configMap: + name: {{ template "grafana.fullname" . }}-test + - name: tools + emptyDir: {} + restartPolicy: Never diff --git a/stable/grafana/values.yaml b/stable/grafana/values.yaml index 6d07c3bfaf..b57d070f7e 100644 --- a/stable/grafana/values.yaml +++ b/stable/grafana/values.yaml @@ -29,6 +29,10 @@ image: tag: 6.0.2 pullPolicy: IfNotPresent +testFramework: + image: "dduportal/bats" + tag: "0.4.0" + ## Optionally specify an array of imagePullSecrets. ## Secrets must be manually created in the namespace. ## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/