1 {{/* vim: set filetype=mustache: */}}
3 Create a default fully qualified app name.
4 We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
7 {{- define "kong.name" -}}
8 {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
11 {{- define "kong.fullname" -}}
12 {{- $name := default .Chart.Name .Values.nameOverride -}}
13 {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
16 {{- define "kong.postgresql.fullname" -}}
17 {{- $name := default "postgresql" .Values.postgresql.nameOverride -}}
18 {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
21 {{- define "kong.cassandra.fullname" -}}
22 {{- $name := default "cassandra" .Values.cassandra.nameOverride -}}
23 {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
27 Create the name of the service account to use
29 {{- define "kong.serviceAccountName" -}}
30 {{- if .Values.ingressController.serviceAccount.create -}}
31 {{ default (include "kong.fullname" .) .Values.ingressController.serviceAccount.name }}
33 {{ default "default" .Values.serviceAccount.name }}
38 Create the KONG_PROXY_LISTEN value string
40 {{- define "kong.kongProxyListenValue" -}}
42 {{- if and .Values.proxy.http.enabled .Values.proxy.tls.enabled -}}
43 0.0.0.0:{{ .Values.proxy.http.containerPort }},0.0.0.0:{{ .Values.proxy.tls.containerPort }} ssl
45 {{- if .Values.proxy.http.enabled -}}
46 0.0.0.0:{{ .Values.proxy.http.containerPort }}
48 {{- if .Values.proxy.tls.enabled -}}
49 0.0.0.0:{{ .Values.proxy.tls.containerPort }} ssl
56 Create the KONG_ADMIN_GUI_LISTEN value string
58 {{- define "kong.kongManagerListenValue" -}}
60 {{- if and .Values.manager.http.enabled .Values.manager.tls.enabled -}}
61 0.0.0.0:{{ .Values.manager.http.containerPort }},0.0.0.0:{{ .Values.manager.tls.containerPort }} ssl
63 {{- if .Values.manager.http.enabled -}}
64 0.0.0.0:{{ .Values.manager.http.containerPort }}
66 {{- if .Values.manager.tls.enabled -}}
67 0.0.0.0:{{ .Values.manager.tls.containerPort }} ssl
74 Create the KONG_PORTAL_GUI_LISTEN value string
76 {{- define "kong.kongPortalListenValue" -}}
78 {{- if and .Values.portal.http.enabled .Values.portal.tls.enabled -}}
79 0.0.0.0:{{ .Values.portal.http.containerPort }},0.0.0.0:{{ .Values.portal.tls.containerPort }} ssl
81 {{- if .Values.portal.http.enabled -}}
82 0.0.0.0:{{ .Values.portal.http.containerPort }}
84 {{- if .Values.portal.tls.enabled -}}
85 0.0.0.0:{{ .Values.portal.tls.containerPort }} ssl
92 Create the KONG_PORTAL_API_LISTEN value string
94 {{- define "kong.kongPortalApiListenValue" -}}
96 {{- if and .Values.portalapi.http.enabled .Values.portalapi.tls.enabled -}}
97 0.0.0.0:{{ .Values.portalapi.http.containerPort }},0.0.0.0:{{ .Values.portalapi.tls.containerPort }} ssl
99 {{- if .Values.portalapi.http.enabled -}}
100 0.0.0.0:{{ .Values.portalapi.http.containerPort }}
102 {{- if .Values.portalapi.tls.enabled -}}
103 0.0.0.0:{{ .Values.portalapi.tls.containerPort }} ssl
110 Create the ingress servicePort value string
113 {{- define "kong.ingress.servicePort" -}}
114 {{- if .tls.enabled -}}
115 {{ .tls.servicePort }}
117 {{ .http.servicePort }}
122 {{- define "kong.env" -}}
123 {{- range $key, $val := .Values.env }}
124 - name: KONG_{{ $key | upper}}
125 {{- $valueType := printf "%T" $val -}}
126 {{ if eq $valueType "map[string]interface {}" }}
127 {{ toYaml $val | indent 2 -}}
129 value: {{ $val | quote -}}
134 {{- define "kong.wait-for-db" -}}
136 image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
137 imagePullPolicy: {{ .Values.image.pullPolicy }}
139 {{- if .Values.enterprise.enabled }}
140 {{- include "kong.license" . | nindent 2 }}
142 {{- if .Values.postgresql.enabled }}
144 value: {{ template "kong.postgresql.fullname" . }}
146 value: "{{ .Values.postgresql.service.port }}"
147 - name: KONG_PG_PASSWORD
150 name: {{ template "kong.postgresql.fullname" . }}
151 key: postgresql-password
153 {{- if .Values.cassandra.enabled }}
154 - name: KONG_CASSANDRA_CONTACT_POINTS
155 value: {{ template "kong.cassandra.fullname" . }}
157 {{- include "kong.env" . | nindent 2 }}
158 command: [ "/bin/sh", "-c", "until kong start; do echo 'waiting for db'; sleep 1; done; kong stop" ]
161 {{- define "kong.controller-container" -}}
162 - name: ingress-controller
164 - /kong-ingress-controller
165 # Service from were we extract the IP address/es to use in Ingress status
166 - --publish-service={{ .Release.Namespace }}/{{ template "kong.fullname" . }}-proxy
167 # Set the ingress class
168 - --ingress-class={{ .Values.ingressController.ingressClass }}
169 - --election-id=kong-ingress-controller-leader-{{ .Values.ingressController.ingressClass }}
170 # the kong URL points to the kong admin api server
171 {{- if .Values.admin.useTLS }}
172 - --kong-url=https://localhost:{{ .Values.admin.containerPort }}
173 - --admin-tls-skip-verify # TODO make this configurable
175 - --kong-url=http://localhost:{{ .Values.admin.containerPort }}
182 fieldPath: metadata.name
183 - name: POD_NAMESPACE
187 fieldPath: metadata.namespace
188 image: "{{ .Values.ingressController.image.repository }}:{{ .Values.ingressController.image.tag }}"
189 imagePullPolicy: {{ .Values.image.pullPolicy }}
196 initialDelaySeconds: 30
210 {{ toYaml .Values.ingressController.resources | indent 10 }}
214 Retrieve Kong Enterprise license from a secret and make it available in env vars
216 {{- define "kong.license" -}}
217 - name: KONG_LICENSE_DATA
220 name: {{ .Values.enterprise.license_secret }}