Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

[HELM] Kubernetes 1.22: Deprecated apiVersion #782

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | `{}` |
Expand Down Expand Up @@ -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/) | `[]` |
Expand Down
24 changes: 24 additions & 0 deletions helm/opendistro-es/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
2 changes: 1 addition & 1 deletion helm/opendistro-es/templates/elasticsearch/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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" . }}
Expand Down
12 changes: 11 additions & 1 deletion helm/opendistro-es/templates/kibana/kibana-ingress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion helm/opendistro-es/templates/kibana/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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" . }}
Expand Down
2 changes: 2 additions & 0 deletions helm/opendistro-es/values-nonroot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ kibana:
# kubernetes.io/tls-acme: "true"
labels: {}
path: /
pathType: ImplementationSpecific
hosts:
- chart-example.local
tls: []
Expand Down Expand Up @@ -421,6 +422,7 @@ elasticsearch:
# nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
labels: {}
path: /
pathType: ImplementationSpecific
hosts:
- chart-example.local
tls: []
Expand Down
2 changes: 2 additions & 0 deletions helm/opendistro-es/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ kibana:
# kubernetes.io/tls-acme: "true"
labels: {}
path: /
pathType: ImplementationSpecific
hosts:
- chart-example.local
tls: []
Expand Down Expand Up @@ -419,6 +420,7 @@ elasticsearch:
# nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
labels: {}
path: /
pathType: ImplementationSpecific
hosts:
- chart-example.local
tls: []
Expand Down