-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_ingress.yaml
More file actions
95 lines (86 loc) · 2.34 KB
/
_ingress.yaml
File metadata and controls
95 lines (86 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "sample.fullname" . -}}
{{- $servicePort := .Values.service.port -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app: {{ template "sample.name" . }}
chart: {{ template "sample.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}
{{- toYaml $ | include "null" -}}
### variable($x) vs root($.x)
{{- define "null" }}{{ end }}
$fullName >> {{ "<undefined>" }}{{/* $fullName | default "<null>" */}}
$.fullName >> {{ $.fullName | default "<null>" }}
### handle root dict
{{- $container := "aaa" }}
{{- set $ "container" "bbb" | include "null" }}
$container >> {{ $container }}
$.container >> {{ $.container }}
### handle template as dict
{{- define "ingress" -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "sample.fullname" . }}
labels:
app: {{ template "sample.name" . }}
chart: {{ template "sample.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- end -}}
{{- define "expend" -}}
labels:
new: "append"
chart: "replace"
{{- end }}
{{- include "ingress" $ | fromYaml | set $ "ingress" | include "null" }}
{{- include "expend" $ | fromYaml | set $ "expend" | include "null" }}
$.ingress >>
{{ toYaml $.ingress | indent 2 }}
$.expend >>
{{ toYaml $.expend | indent 4 }}
$.ingress + $.expend >>
{{- merge $.ingress.metadata $.expend | include "null" }}
{{ toYaml $.ingress | indent 2 }}
### helm template sample
expend:
- path: ingress@metadata.labels
#labels:
new: "append"
chart: "replace"
- path: deployment@spec.template.spec.containers[0]
#containers:
name: hygieia-web
image: "hygieia-web:stable"
imagePullPolicy: Always