From c2f81472598f4c0a132583f55d62a4fd7f8dbccf Mon Sep 17 00:00:00 2001 From: Christian Kotzbauer Date: Sat, 28 Sep 2019 12:08:08 +0200 Subject: [PATCH] [elasticsearch] 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 d651d5671..ccfd8c338 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 39167ca0b..1715b97c1 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 004578f2c..36c7af689 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" . }}