Support for ingress and ingresses
This commit is contained in:
@@ -1,29 +1,42 @@
|
|||||||
{{- $labels := include "helm-chart.labels" . -}}
|
{{/* OneChart ingress snippet */}}
|
||||||
{{- with .Values.ingress -}}
|
{{- define "onechart.ingress" }}
|
||||||
{{- $robustName := include "robustName" $.Release.Name -}}
|
{{- $robustName := include "robustName" .root.Release.Name -}}
|
||||||
|
---
|
||||||
apiVersion: networking.k8s.io/v1beta1
|
apiVersion: networking.k8s.io/v1beta1
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
metadata:
|
metadata:
|
||||||
|
{{- if .longName }}
|
||||||
|
name: {{ $robustName }}-{{ template "robustName" .ingress.host }}
|
||||||
|
{{- else }}
|
||||||
name: {{ $robustName }}
|
name: {{ $robustName }}
|
||||||
namespace: {{ $.Release.Namespace }}
|
{{- end }}
|
||||||
|
namespace: {{ .root.Release.Namespace }}
|
||||||
labels:
|
labels:
|
||||||
{{- $labels | nindent 4 }}
|
{{- include "helm-chart.labels" .root | nindent 4 }}
|
||||||
{{- with .annotations }}
|
{{- with .ingress.annotations }}
|
||||||
annotations:
|
annotations:
|
||||||
{{- toYaml . | nindent 4 }}
|
{{- toYaml . | nindent 4 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
spec:
|
spec:
|
||||||
{{- if default false .tlsEnabled }}
|
{{- if default false .ingress.tlsEnabled }}
|
||||||
tls:
|
tls:
|
||||||
- hosts:
|
- hosts:
|
||||||
- {{ template "robustName" .host | quote }}
|
- {{ template "robustName" .ingress.host | quote }}
|
||||||
secretName: {{ printf "tls-%s" $robustName }}
|
secretName: {{ printf "tls-%s" $robustName }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
rules:
|
rules:
|
||||||
- host: {{ template "robustName" .host | quote }}
|
- host: {{ template "robustName" .ingress.host | quote }}
|
||||||
http:
|
http:
|
||||||
paths:
|
paths:
|
||||||
- backend:
|
- backend:
|
||||||
serviceName: {{ template "robustName" $.Release.Name }}
|
serviceName: {{ $robustName }}
|
||||||
servicePort: {{ $.Values.containerPort }}
|
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 }}
|
{{- end }}
|
||||||
|
|||||||
@@ -55,3 +55,31 @@ tests:
|
|||||||
path: metadata.annotations
|
path: metadata.annotations
|
||||||
value:
|
value:
|
||||||
kubernetes.io/ingress.class: nginx
|
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
|
||||||
|
|||||||
+11
-17
@@ -1,17 +1,11 @@
|
|||||||
fileSecrets:
|
ingress:
|
||||||
- name: google-account-key
|
host: chart-example.local
|
||||||
path: /google-account-key
|
annotations:
|
||||||
secrets:
|
kubernetes.io/ingress.class: nginx
|
||||||
key.json: supersecret
|
ingresses:
|
||||||
another.json: |
|
- host: chart-example.local
|
||||||
this
|
annotations:
|
||||||
is
|
kubernetes.io/ingress.class: nginx
|
||||||
a
|
- host: another.local
|
||||||
multiline
|
annotations:
|
||||||
secret
|
kubernetes.io/ingress.class: nginx
|
||||||
|
|
||||||
sidecar:
|
|
||||||
repository: debian
|
|
||||||
tag: stable-slim
|
|
||||||
shell: "/bin/bash"
|
|
||||||
command: "while true; do sleep 30; done;"
|
|
||||||
Reference in New Issue
Block a user