diff --git a/charts/nebraska/Chart.yaml b/charts/nebraska/Chart.yaml index b9b112ac0..56d69fd73 100644 --- a/charts/nebraska/Chart.yaml +++ b/charts/nebraska/Chart.yaml @@ -19,7 +19,7 @@ sources: maintainers: - name: kinvolk url: https://kinvolk.io/ -version: 0.1.11 +version: 0.2.0 appVersion: "2.5.1" dependencies: diff --git a/charts/nebraska/README.md b/charts/nebraska/README.md index e1d984e5e..f684b6760 100644 --- a/charts/nebraska/README.md +++ b/charts/nebraska/README.md @@ -43,7 +43,11 @@ $ helm install my-nebraska nebraska/nebraska | `ingress.enabled` | Enable ingress controller resource | `true` | | `ingress.annotations` | Annotations for Ingress resource | `{}` | | `ingress.hosts` | Hostname(s) for the Ingress resource | `["flatcar.example.com"]` | +| `ingress.ingressClassName` | Ingress controller which implements the resource. This replaces the deprecated `kubernetes.io/ingress.class` annotation on K8s > 1.19 | `""` | | `ingress.tls` | Ingress TLS configuration | `[]` | +| `ingress.update.enabled` | Create a separate ingress for the `/v1/update` and `/flatcar` paths, with it's own annotations. | `false` | +| `ingress.update.annotations` | Annotations for Ingress resource | `{}` | +| `ingress.update.ingressClassName` | Ingress controller which implements the resource. This replaces the deprecated `kubernetes.io/ingress.class` annotation on K8s > 1.19 | `""` | | `resources` | CPU/Memory resource requests/limits | `{}` | | `nodeSelector` | Node labels for pod assignment | `{}` | | `tolerations` | Toleration labels for pod assignment | `[]` | diff --git a/charts/nebraska/templates/_helpers.tpl b/charts/nebraska/templates/_helpers.tpl index ec1fd205b..c94f9af07 100644 --- a/charts/nebraska/templates/_helpers.tpl +++ b/charts/nebraska/templates/_helpers.tpl @@ -70,6 +70,19 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{/* +Return the appropriate apiVersion for ingress +*/}} +{{- define "nebraska.ingress.apiVersion" -}} +{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.Version -}} +{{- print "extensions/v1beta1" -}} +{{- else if semverCompare "<1.19-0" .Capabilities.KubeVersion.Version -}} +{{- print "networking.k8s.io/v1beta1" -}} +{{- else -}} +{{- print "networking.k8s.io/v1" -}} +{{- end -}} +{{- end -}} + {{- define "nebraska.ingressScheme" -}} http{{ if $.Values.ingress.tls }}s{{ end }} {{- end -}} diff --git a/charts/nebraska/templates/ingress.yaml b/charts/nebraska/templates/ingress.yaml index 96404398a..529e82764 100644 --- a/charts/nebraska/templates/ingress.yaml +++ b/charts/nebraska/templates/ingress.yaml @@ -1,14 +1,7 @@ {{- if .Values.ingress.enabled }} {{- $fullName := include "nebraska.fullname" . }} {{- $svcPort := .Values.service.port }} -{{- $kubeGitVersion := .Capabilities.KubeVersion.GitVersion }} -{{- if semverCompare ">=1.19-0" $kubeGitVersion }} -apiVersion: networking.k8s.io/v1 -{{- else if semverCompare ">=1.14-0" $kubeGitVersion }} -apiVersion: networking.k8s.io/v1beta1 -{{- else }} -apiVersion: extensions/v1beta1 -{{- end }} +apiVersion: {{ include "nebraska.ingress.apiVersion" . }} kind: Ingress metadata: name: {{ $fullName }} @@ -19,6 +12,11 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} spec: + {{- if eq (include "nebraska.ingress.apiVersion" $) "networking.k8s.io/v1" }} + {{- with .Values.ingress.ingressClassName }} + ingressClassName: {{ . }} + {{- end }} + {{- end }} {{- if .Values.ingress.tls }} tls: {{- range .Values.ingress.tls }} @@ -36,7 +34,7 @@ spec: paths: - path: / backend: - {{- if semverCompare ">=1.19-0" $kubeGitVersion }} + {{- if eq (include "nebraska.ingress.apiVersion" $) "networking.k8s.io/v1" }} service: name: {{ $fullName }} port: diff --git a/charts/nebraska/templates/update-ingress.yaml b/charts/nebraska/templates/update-ingress.yaml index e992543c0..99ee94180 100644 --- a/charts/nebraska/templates/update-ingress.yaml +++ b/charts/nebraska/templates/update-ingress.yaml @@ -1,14 +1,7 @@ {{- if and .Values.ingress.enabled .Values.ingress.update.enabled }} {{- $fullName := include "nebraska.fullname" . }} {{- $svcPort := .Values.service.port }} -{{- $kubeGitVersion := .Capabilities.KubeVersion.GitVersion }} -{{- if semverCompare ">=1.19-0" $kubeGitVersion }} -apiVersion: networking.k8s.io/v1 -{{- else if semverCompare ">=1.14-0" $kubeGitVersion }} -apiVersion: networking.k8s.io/v1beta1 -{{- else }} -apiVersion: extensions/v1beta1 -{{- end }} +apiVersion: {{ include "nebraska.ingress.apiVersion" . }} kind: Ingress metadata: name: {{ $fullName | trunc 56 | trimSuffix "-" }}-update @@ -19,6 +12,11 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} spec: + {{- if eq (include "nebraska.ingress.apiVersion" $) "networking.k8s.io/v1" }} + {{- with .Values.ingress.update.ingressClassName }} + ingressClassName: {{ . }} + {{- end }} + {{- end }} {{- if .Values.ingress.tls }} tls: {{- range .Values.ingress.tls }} @@ -36,7 +34,7 @@ spec: paths: - path: /v1/update backend: - {{- if semverCompare ">=1.19-0" $kubeGitVersion }} + {{- if eq (include "nebraska.ingress.apiVersion" $) "networking.k8s.io/v1" }} service: name: {{ $fullName }} port: @@ -53,7 +51,7 @@ spec: - path: /flatcar {{- end }} backend: - {{- if semverCompare ">=1.19-0" $kubeGitVersion }} + {{- if eq (include "nebraska.ingress.apiVersion" $) "networking.k8s.io/v1" }} service: name: {{ $fullName }} port: diff --git a/charts/nebraska/values.yaml b/charts/nebraska/values.yaml index 54dc9e267..7b1c85f28 100644 --- a/charts/nebraska/values.yaml +++ b/charts/nebraska/values.yaml @@ -143,11 +143,13 @@ ingress: annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" + ingressClassName: "" update: # Create a separate ingress for the /v1/update and /flatcar paths, # with it's own annotations. enabled: false annotations: {} + ingressClassName: "" hosts: - flatcar.example.com tls: []