From f79169b8e6a57881952ca4d2c338eeda179471e9 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Mon, 7 Oct 2019 11:18:05 -0400 Subject: [PATCH 1/1] Add compatibility for k8s 1.16 --- elasticsearch/templates/_helpers.tpl | 22 ++++++++++++++++++++++ elasticsearch/templates/ingress.yaml | 2 +- elasticsearch/templates/statefulset.yaml | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/elasticsearch/templates/_helpers.tpl b/elasticsearch/templates/_helpers.tpl index d651d56..ccfd8c3 100755 --- a/elasticsearch/templates/_helpers.tpl +++ b/elasticsearch/templates/_helpers.tpl @@ -47,3 +47,25 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- end -}} {{- end -}} {{- end -}} + +{{/* +Return the appropriate apiVersion for statefulset. +*/}} +{{- define "elasticsearch.statefulset.apiVersion" -}} +{{- if semverCompare "<1.9-0" .Capabilities.KubeVersion.GitVersion -}} +{{- print "apps/v1beta2" -}} +{{- else -}} +{{- print "apps/v1" -}} +{{- end -}} +{{- end -}} + +{{/* +Return the appropriate apiVersion for ingress. +*/}} +{{- define "elasticsearch.ingress.apiVersion" -}} +{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}} +{{- print "extensions/v1beta1" -}} +{{- else -}} +{{- print "networking.k8s.io/v1beta1" -}} +{{- end -}} +{{- end -}} diff --git a/elasticsearch/templates/ingress.yaml b/elasticsearch/templates/ingress.yaml index 39167ca..1715b97 100644 --- a/elasticsearch/templates/ingress.yaml +++ b/elasticsearch/templates/ingress.yaml @@ -2,7 +2,7 @@ {{- $fullName := include "uname" . -}} {{- $servicePort := .Values.httpPort -}} {{- $ingressPath := .Values.ingress.path -}} -apiVersion: extensions/v1beta1 +apiVersion: {{ template "elasticsearch.ingress.apiVersion" . }} kind: Ingress metadata: name: {{ $fullName }} diff --git a/elasticsearch/templates/statefulset.yaml b/elasticsearch/templates/statefulset.yaml index 004578f..36c7af6 100644 --- a/elasticsearch/templates/statefulset.yaml +++ b/elasticsearch/templates/statefulset.yaml @@ -1,5 +1,5 @@ --- -apiVersion: apps/v1beta1 +apiVersion: {{ template "elasticsearch.statefulset.apiVersion" . }} kind: StatefulSet metadata: name: {{ template "uname" . }} -- 1.8.3.1