diff --git a/stable/consul/Chart.yaml b/stable/consul/Chart.yaml index 7747b2895f..57fc7f81e4 100755 --- a/stable/consul/Chart.yaml +++ b/stable/consul/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 name: consul home: https://github.com/hashicorp/consul -version: 3.9.1 +version: 3.9.2 appVersion: 1.5.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 diff --git a/stable/consul/templates/_helpers.tpl b/stable/consul/templates/_helpers.tpl index 61af0722c8..574eadf828 100644 --- a/stable/consul/templates/_helpers.tpl +++ b/stable/consul/templates/_helpers.tpl @@ -30,3 +30,14 @@ Create chart name and version as used by the chart label. {{- define "consul.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{/* +Return the apiVersion of statefulset. +*/}} +{{- define "statefulset.apiVersion" -}} +{{- if semverCompare "<1.9-0" .Capabilities.KubeVersion.GitVersion -}} +{{- print "apps/v1beta2" -}} +{{- else if semverCompare ">=1.9-0" .Capabilities.KubeVersion.GitVersion -}} +{{- print "apps/v1" -}} +{{- end -}} +{{- end -}} diff --git a/stable/consul/templates/consul-statefulset.yaml b/stable/consul/templates/consul-statefulset.yaml index 377f026d79..8f18824550 100644 --- a/stable/consul/templates/consul-statefulset.yaml +++ b/stable/consul/templates/consul-statefulset.yaml @@ -1,4 +1,4 @@ -apiVersion: apps/v1 +apiVersion: {{ template "statefulset.apiVersion" . }} kind: StatefulSet metadata: name: "{{ template "consul.fullname" . }}" @@ -160,7 +160,7 @@ spec: JOIN_LAN="" for THIS_PEER in $JOIN_PEERS; do # Make sure we can resolve hostname and ping IP - if PEER_IP="$(ping -c 1 $THIS_PEER | awk -F'[()]' '/PING/{print $2}')" && [ "$PEER_IP" != "" ]; then + if PEER_IP="$(ping -c 1 $THIS_PEER | awk -F'[()]' '/PING/{print $2}')" && [ "$PEER_IP" != "" ]; then if [ "${PEER_IP}" != "${POD_IP}" ]; then JOIN_LAN="${JOIN_LAN}${JOIN_LAN:+ } -retry-join=$THIS_PEER" fi @@ -191,7 +191,7 @@ spec: JOIN_WAN="" for THIS_PEER in $WAN_PEERS; do # We don't care if we can ping the peer, but we do care that we can get its IP - if PEER_IP="$( ( ping -c 1 $THIS_PEER || true ) | awk -F'[()]' '/PING/{print $2}')" && [ "$PEER_IP" != "" ]; then + if PEER_IP="$( ( ping -c 1 $THIS_PEER || true ) | awk -F'[()]' '/PING/{print $2}')" && [ "$PEER_IP" != "" ]; then if [ "${PEER_IP}" != "${POD_IP}" ]; then JOIN_WAN="${JOIN_WAN}${JOIN_WAN:+ } -retry-join-wan=$THIS_PEER" fi