From e6b527aae6e98051bb7fa7ce7268e0ea3a7ee15d Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Wed, 12 May 2021 11:04:53 +0200 Subject: [PATCH 1/2] Removing deprecated apiVersion --- charts/onechart/templates/ingress.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/charts/onechart/templates/ingress.yaml b/charts/onechart/templates/ingress.yaml index 701b081..845b9dc 100644 --- a/charts/onechart/templates/ingress.yaml +++ b/charts/onechart/templates/ingress.yaml @@ -1,12 +1,7 @@ {{- $labels := include "helm-chart.labels" . -}} - {{- with .Values.ingress -}} {{- $robustName := include "robustName" $.Release.Name -}} -{{- if semverCompare ">=1.14-0" $.Capabilities.KubeVersion.GitVersion -}} apiVersion: networking.k8s.io/v1beta1 -{{- else -}} -apiVersion: extensions/v1beta1 -{{- end }} kind: Ingress metadata: name: {{ $robustName }} From eb78ab24e64a15bca8ded9b95d08b0b99200d705 Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Wed, 12 May 2021 13:03:10 +0200 Subject: [PATCH 2/2] Support for ingress and ingresses --- charts/onechart/templates/ingress.yaml | 37 +++++++++++++------ .../onechart/tests/ingress_domain_test.yaml | 28 ++++++++++++++ values.yaml | 28 ++++++-------- 3 files changed, 64 insertions(+), 29 deletions(-) diff --git a/charts/onechart/templates/ingress.yaml b/charts/onechart/templates/ingress.yaml index 845b9dc..b3368a7 100644 --- a/charts/onechart/templates/ingress.yaml +++ b/charts/onechart/templates/ingress.yaml @@ -1,29 +1,42 @@ -{{- $labels := include "helm-chart.labels" . -}} -{{- with .Values.ingress -}} -{{- $robustName := include "robustName" $.Release.Name -}} +{{/* OneChart ingress snippet */}} +{{- define "onechart.ingress" }} +{{- $robustName := include "robustName" .root.Release.Name -}} +--- apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: + {{- if .longName }} + name: {{ $robustName }}-{{ template "robustName" .ingress.host }} + {{- else }} name: {{ $robustName }} - namespace: {{ $.Release.Namespace }} + {{- end }} + namespace: {{ .root.Release.Namespace }} labels: - {{- $labels | nindent 4 }} - {{- with .annotations }} + {{- include "helm-chart.labels" .root | nindent 4 }} + {{- with .ingress.annotations }} annotations: {{- toYaml . | nindent 4 }} {{- end }} spec: - {{- if default false .tlsEnabled }} + {{- if default false .ingress.tlsEnabled }} tls: - hosts: - - {{ template "robustName" .host | quote }} + - {{ template "robustName" .ingress.host | quote }} secretName: {{ printf "tls-%s" $robustName }} {{- end }} rules: - - host: {{ template "robustName" .host | quote }} + - host: {{ template "robustName" .ingress.host | quote }} http: paths: - - backend: - serviceName: {{ template "robustName" $.Release.Name }} - servicePort: {{ $.Values.containerPort }} + - backend: + serviceName: {{ $robustName }} + servicePort: {{ .root.Values.containerPort }} +{{- end }} + +{{- with .Values.ingress }} + {{- template "onechart.ingress" (dict "root" $ "ingress" .) }} +{{- end }} + +{{- range .Values.ingresses }} +{{template "onechart.ingress" (dict "root" $ "ingress" . "longName" true) }} {{- end }} diff --git a/charts/onechart/tests/ingress_domain_test.yaml b/charts/onechart/tests/ingress_domain_test.yaml index e3b60b5..33e7d21 100644 --- a/charts/onechart/tests/ingress_domain_test.yaml +++ b/charts/onechart/tests/ingress_domain_test.yaml @@ -55,3 +55,31 @@ tests: path: metadata.annotations value: kubernetes.io/ingress.class: nginx + - it: Should generate multiple ingresses + set: + ingresses: + - host: chart-example.local + annotations: + kubernetes.io/ingress.class: nginx + - host: another.local + annotations: + kubernetes.io/ingress.class: nginx + asserts: + - hasDocuments: + count: 2 + - it: Should generate multiple ingresses + set: + ingress: + host: chart-example.local + annotations: + kubernetes.io/ingress.class: nginx + ingresses: + - host: chart-example.local + annotations: + kubernetes.io/ingress.class: nginx + - host: another.local + annotations: + kubernetes.io/ingress.class: nginx + asserts: + - hasDocuments: + count: 3 diff --git a/values.yaml b/values.yaml index 51e5ad0..8270ce0 100644 --- a/values.yaml +++ b/values.yaml @@ -1,17 +1,11 @@ -fileSecrets: - - name: google-account-key - path: /google-account-key - secrets: - key.json: supersecret - another.json: | - this - is - a - multiline - secret - -sidecar: - repository: debian - tag: stable-slim - shell: "/bin/bash" - command: "while true; do sleep 30; done;" +ingress: + host: chart-example.local + annotations: + kubernetes.io/ingress.class: nginx +ingresses: + - host: chart-example.local + annotations: + kubernetes.io/ingress.class: nginx + - host: another.local + annotations: + kubernetes.io/ingress.class: nginx \ No newline at end of file