From 44a85b418543ea36e3a22063fac7546298fd5051 Mon Sep 17 00:00:00 2001 From: "remi.butet" Date: Fri, 27 Aug 2021 20:20:31 +0200 Subject: [PATCH] [HELM] Kubernetes 1.22: Deprecated apiVersion --- helm/README.md | 2 ++ helm/opendistro-es/templates/_helpers.tpl | 24 +++++++++++++++++++ .../elasticsearch/es-client-ingress.yaml | 12 +++++++++- .../templates/elasticsearch/role.yaml | 2 +- .../templates/kibana/kibana-ingress.yml | 12 +++++++++- helm/opendistro-es/templates/kibana/role.yaml | 2 +- helm/opendistro-es/values-nonroot.yaml | 2 ++ helm/opendistro-es/values.yaml | 2 ++ 8 files changed, 54 insertions(+), 4 deletions(-) diff --git a/helm/README.md b/helm/README.md index afc1d67ab..7e49de390 100644 --- a/helm/README.md +++ b/helm/README.md @@ -498,6 +498,7 @@ The following table lists the configurable parameters of the opendistro elastics | `kibana.ingress.tls` | Kibana Ingress TLS configuration | `[]` | | `kibana.ingress.labels` | Kibana Ingress labels | `{}` | | `kibana.ingress.path` | Kibana Ingress paths | `[]` | +| `kibana.ingress.pathType` | Kibana Ingress path type | `ImplementationSpecific` | | `kibana.config` | Kibana Configuration (`kibana.yml`) | `{}` | | `kibana.nodeSelector` | Define which Nodes the Pods are scheduled on. | `{}` | | `kibana.podAnnotations` | Kibana pods annotations | `{}` | @@ -576,6 +577,7 @@ The following table lists the configurable parameters of the opendistro elastics | `elasticsearch.client.ingress.hosts` | Elasticsearch clients Ingress Hostnames | `[]` | | `elasticsearch.client.ingress.tls` | Elasticsearch clients Ingress TLS configuration | `[]` | | `elasticsearch.client.ingress.labels` | Elasticsearch clients Ingress labels | `{}` | +| `elasticsearch.client.ingress.pathType` | Elasticsearch clients Ingress path type | `ImplementationSpecific` | | `elasticsearch.client.livenessProbe` | Configuration for the [livenessProbe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/) | `[]` | | `elasticsearch.client.readinessProbe` | Configuration for the [readinessProbe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/) | `[]` | | `elasticsearch.client.startupProbe` | Configuration for the [startupProbe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/) | `[]` | diff --git a/helm/opendistro-es/templates/_helpers.tpl b/helm/opendistro-es/templates/_helpers.tpl index 15275ecab..cad9e2d9e 100755 --- a/helm/opendistro-es/templates/_helpers.tpl +++ b/helm/opendistro-es/templates/_helpers.tpl @@ -133,3 +133,27 @@ imagePullSecrets: {{ template "master-nodes" $ }}-{{ $i }}, {{- end -}} {{- end -}} + +{{/* +Return the appropriate apiVersion for Ingress. +*/}} +{{- define "ingress.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" -}} +{{- print "networking.k8s.io/v1" -}} +{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress" -}} +{{- print "networking.k8s.io/v1beta1" -}} +{{- else -}} +{{- print "extensions/v1beta1" -}} +{{- end -}} +{{- end -}} + +{{/* +Return the appropriate apiVersion for RBAC. +*/}} +{{- define "rbac.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1" -}} +{{- print "rbac.authorization.k8s.io/v1" -}} +{{- else -}} +{{- print "rbac.authorization.k8s.io/v1beta1" -}} +{{- end -}} +{{- end -}} diff --git a/helm/opendistro-es/templates/elasticsearch/es-client-ingress.yaml b/helm/opendistro-es/templates/elasticsearch/es-client-ingress.yaml index 0267bc212..9ab20690d 100755 --- a/helm/opendistro-es/templates/elasticsearch/es-client-ingress.yaml +++ b/helm/opendistro-es/templates/elasticsearch/es-client-ingress.yaml @@ -15,8 +15,10 @@ {{- if and .Values.elasticsearch.client.ingress.enabled .Values.elasticsearch.client.enabled }} {{ $fullName := printf "%s-%s" (include "opendistro-es.fullname" .) "client-service" }} {{ $ingressPath := .Values.elasticsearch.client.ingress.path }} +{{ $ingressPathType := .Values.elasticsearch.client.ingress.pathType }} +{{- $hasNetworkingIngress := $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }} kind: Ingress -apiVersion: extensions/v1beta1 +apiVersion: {{ template "ingress.apiVersion" $}} metadata: name: {{ $fullName }} labels: @@ -43,7 +45,15 @@ spec: paths: - path: {{ $ingressPath }} backend: + {{- if $hasNetworkingIngress }} + service: + name: {{ $fullName }} + port: + name: http + pathType: {{ $ingressPathType }} + {{- else }} serviceName: {{ $fullName }} servicePort: http + {{- end }} {{- end }} {{- end }} diff --git a/helm/opendistro-es/templates/elasticsearch/role.yaml b/helm/opendistro-es/templates/elasticsearch/role.yaml index 6bc871732..8ebc07402 100755 --- a/helm/opendistro-es/templates/elasticsearch/role.yaml +++ b/helm/opendistro-es/templates/elasticsearch/role.yaml @@ -13,7 +13,7 @@ # @formatter:off {{- if .Values.global.rbac.enabled }} -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: {{ template "rbac.apiVersion" $}} kind: Role metadata: name: {{ template "opendistro-es.elasticsearch.serviceAccountName" . }} diff --git a/helm/opendistro-es/templates/kibana/kibana-ingress.yml b/helm/opendistro-es/templates/kibana/kibana-ingress.yml index 3817b0cc8..6040037de 100755 --- a/helm/opendistro-es/templates/kibana/kibana-ingress.yml +++ b/helm/opendistro-es/templates/kibana/kibana-ingress.yml @@ -16,7 +16,9 @@ {{- $serviceName := printf "%s-%s" (include "opendistro-es.fullname" .) "kibana-svc" }} {{- $servicePort := .Values.kibana.externalPort }} {{- $ingressPath := .Values.kibana.ingress.path }} -apiVersion: extensions/v1beta1 +{{- $ingressPathType := .Values.kibana.ingress.pathType }} +{{- $hasNetworkingIngress := $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }} +apiVersion: {{ template "ingress.apiVersion" $}} kind: Ingress metadata: name: {{ template "opendistro-es.fullname" . }}-kibana-ing @@ -34,8 +36,16 @@ spec: paths: - path: {{ $ingressPath }} backend: + {{- if $hasNetworkingIngress }} + service: + name: {{ $serviceName }} + port: + number: {{ $servicePort }} + pathType: {{ $ingressPathType }} + {{- else }} serviceName: {{ $serviceName }} servicePort: {{ $servicePort }} + {{- end }} {{- end }} {{- if .Values.kibana.ingress.tls }} tls: {{ toYaml .Values.kibana.ingress.tls | nindent 4 }} diff --git a/helm/opendistro-es/templates/kibana/role.yaml b/helm/opendistro-es/templates/kibana/role.yaml index a7e7bf99f..0b8cfb233 100755 --- a/helm/opendistro-es/templates/kibana/role.yaml +++ b/helm/opendistro-es/templates/kibana/role.yaml @@ -13,7 +13,7 @@ # @formatter:off {{- if and .Values.global.rbac.enabled .Values.kibana.enabled }} -apiVersion: rbac.authorization.k8s.io/v1beta1 +apiVersion: {{ template "rbac.apiVersion" $}} kind: Role metadata: name: {{ template "opendistro-es.kibana.serviceAccountName" . }} diff --git a/helm/opendistro-es/values-nonroot.yaml b/helm/opendistro-es/values-nonroot.yaml index b15f48dce..48baef479 100644 --- a/helm/opendistro-es/values-nonroot.yaml +++ b/helm/opendistro-es/values-nonroot.yaml @@ -85,6 +85,7 @@ kibana: # kubernetes.io/tls-acme: "true" labels: {} path: / + pathType: ImplementationSpecific hosts: - chart-example.local tls: [] @@ -421,6 +422,7 @@ elasticsearch: # nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" labels: {} path: / + pathType: ImplementationSpecific hosts: - chart-example.local tls: [] diff --git a/helm/opendistro-es/values.yaml b/helm/opendistro-es/values.yaml index 4fbe4bd9f..fafbc520b 100644 --- a/helm/opendistro-es/values.yaml +++ b/helm/opendistro-es/values.yaml @@ -85,6 +85,7 @@ kibana: # kubernetes.io/tls-acme: "true" labels: {} path: / + pathType: ImplementationSpecific hosts: - chart-example.local tls: [] @@ -419,6 +420,7 @@ elasticsearch: # nginx.ingress.kubernetes.io/backend-protocol: "HTTPS" labels: {} path: / + pathType: ImplementationSpecific hosts: - chart-example.local tls: []