Skip to content

Commit

Permalink
Support for ingress and ingresses
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlocph committed May 12, 2021
1 parent e6b527a commit eb78ab2
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 29 deletions.
37 changes: 25 additions & 12 deletions charts/onechart/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
28 changes: 28 additions & 0 deletions charts/onechart/tests/ingress_domain_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 11 additions & 17 deletions values.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit eb78ab2

Please sign in to comment.