diff --git a/stable/consul/Chart.yaml b/stable/consul/Chart.yaml index 3e49532781..c3f592da8c 100755 --- a/stable/consul/Chart.yaml +++ b/stable/consul/Chart.yaml @@ -1,7 +1,7 @@ name: consul home: https://github.com/hashicorp/consul -version: 0.2.5 -appVersion: 0.7.5 +version: 0.3.0 +appVersion: 0.8.3 description: Highly available and distributed service discovery and key-value store designed with support for the modern data center to make distributed systems and configuration easy. icon: https://raw.githubusercontent.com/hashicorp/consul/bce3809dfca37b883828c3715b84143dd71c0f85/website/source/assets/images/favicons/android-chrome-512x512.png sources: diff --git a/stable/consul/README.md b/stable/consul/README.md index 45cb0b0524..090f75c2c7 100644 --- a/stable/consul/README.md +++ b/stable/consul/README.md @@ -49,6 +49,8 @@ The following tables lists the configurable parameters of the consul chart and t | `ui.enabled` | Enable Consul Web UI | `false` | | `uiService.enabled` | Create dedicated Consul Web UI svc | `false` | | `uiService.type` | Dedicate Consul Web UI svc type | `NodePort` | +| `test.image` | Test container image requires kubectl + bash (used for helm test) | `lachlanevenson/k8s-kubectl` | +| `test.imageTag` | Test container image tag (used for helm test) | `v1.4.8-bash` | Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. @@ -72,7 +74,15 @@ $ kubectl delete pvc -l component=${RELEASE-NAME}-consul ## Testing -Execute test.sh. It will confirm that there are at least 3 consul servers present. +Helm tests are included and they confirm the first three cluster members have quorum. + +```bash +helm test +RUNNING: inky-marsupial-ui-test-nn6lv +PASSED: inky-marsupial-ui-test-nn6lv +``` + +It will confirm that there are at least 3 consul servers present. ## Cluster Health diff --git a/stable/consul/templates/NOTES.txt b/stable/consul/templates/NOTES.txt index 156e3bf8b4..0e3a5b6f08 100644 --- a/stable/consul/templates/NOTES.txt +++ b/stable/consul/templates/NOTES.txt @@ -1,4 +1,6 @@ 1. Watch all cluster members come up. $ kubectl get pods --namespace={{ .Release.Namespace }} -w -2. Confirm consul cluster is healthy - $ kubectl exec {{ .Release.Name }}-consul-0 consul members --namespace={{ .Release.Namespace }} | grep server +2. Test cluster health using Helm test. + $ helm test {{ .Release.Name }} +3. (Optional) Manually confirm consul cluster is healthy. + $ kubectl exec {{ .Release.Name }}-consul-0 consul members --namespace={{ .Release.Namespace }} | grep server \ No newline at end of file diff --git a/stable/consul/templates/consul-test.yaml b/stable/consul/templates/consul-test.yaml new file mode 100644 index 0000000000..b3129b3b80 --- /dev/null +++ b/stable/consul/templates/consul-test.yaml @@ -0,0 +1,38 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{.Release.Name}}-ui-test-{{ randAlphaNum 5 | lower }}" + annotations: + "helm.sh/hook": test-success + "pod.beta.kubernetes.io/init-containers": '[ + { + "name": "test-framework", + "image": "dduportal/bats:0.4.0", + "command": ["bash", "-c", " + set -ex\n + # copy bats to tools dir\n + cp -R /usr/local/libexec/ /tools/bats/\n + "], + "volumeMounts": [ + {"name": "tools", "mountPath": "/tools"} + ] + } + ]' +spec: + containers: + - name: {{.Release.Name}}-ui-test + image: {{.Values.test.image}}:{{.Values.test.imageTag}} + 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 "fullname" . }}-tests + - name: tools + emptyDir: {} + restartPolicy: Never diff --git a/stable/consul/templates/test-config.yaml b/stable/consul/templates/test-config.yaml new file mode 100644 index 0000000000..4a8ae7a005 --- /dev/null +++ b/stable/consul/templates/test-config.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "fullname" . }}-tests +data: + run.sh: |- + @test "Testing Consul cluster has quorum" { + for i in {0..2}; do + if [ `kubectl exec {{.Release.Name}}-consul-$i consul members --namespace={{.Release.Namespace}} | grep server | wc -l` -ge "3" ]; then + echo "{{.Release.Name}}-consul-$i OK. consul members returning at least 3 records." + else + echo "{{.Release.Name}}-consul-$i ERROR. consul members returning less than 3 records." + exit 1 + fi + done + } \ No newline at end of file diff --git a/stable/consul/test.sh b/stable/consul/test.sh deleted file mode 100755 index f30843b976..0000000000 --- a/stable/consul/test.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -# Copyright 2016 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -RELEASE=$1 -NS=$2 - -if [ -z $RELEASE ]; then - echo "Please specify Helm release name. eg. test.sh winsome-shark consul" - exit 1 -elif [ -z $NS ]; then - echo "Please specify a Kubernetes namespace. eg. test.sh winsome-shark consul" - exit 1 -fi - -for i in {0..2}; do - if [ `kubectl exec $RELEASE-consul-$i consul members --namespace=$NS | grep server | wc -l` -ge "3" ]; then - echo "$RELEASE-consul-$i OK. consul members returning at least 3 records." - else - echo "$RELEASE-consul-$i ERROR. consul members returning less than 3 records." - exit 1 - fi -done diff --git a/stable/consul/values.yaml b/stable/consul/values.yaml index f6405b29e0..31f0f3ea82 100644 --- a/stable/consul/values.yaml +++ b/stable/consul/values.yaml @@ -16,7 +16,7 @@ ConsulDnsPort: 8600 Component: "consul" Replicas: 3 Image: "consul" -ImageTag: "0.7.5" +ImageTag: "0.8.3" ImagePullPolicy: "Always" Cpu: "100m" Memory: "256Mi" @@ -44,3 +44,8 @@ ui: uiService: enabled: true type: "NodePort" + +## test container details +test: + image: lachlanevenson/k8s-kubectl + imageTag: v1.4.8-bash