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 "-" -}}
26 {{- define "kong.dblessConfig.fullname" -}}
27 {{- $name := default "kong-custom-dbless-config" .Values.dblessConfig.nameOverride -}}
28 {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
32 Create the name of the service account to use
34 {{- define "kong.serviceAccountName" -}}
35 {{- if .Values.ingressController.serviceAccount.create -}}
36 {{ default (include "kong.fullname" .) .Values.ingressController.serviceAccount.name }}
38 {{ default "default" .Values.serviceAccount.name }}
43 Create the KONG_PROXY_LISTEN value string
45 {{- define "kong.kongProxyListenValue" -}}
47 {{- if and .Values.proxy.http.enabled .Values.proxy.tls.enabled -}}
48 0.0.0.0:{{ .Values.proxy.http.containerPort }},0.0.0.0:{{ .Values.proxy.tls.containerPort }} ssl
50 {{- if .Values.proxy.http.enabled -}}
51 0.0.0.0:{{ .Values.proxy.http.containerPort }}
53 {{- if .Values.proxy.tls.enabled -}}
54 0.0.0.0:{{ .Values.proxy.tls.containerPort }} ssl
61 Create the KONG_ADMIN_GUI_LISTEN value string
63 {{- define "kong.kongManagerListenValue" -}}
65 {{- if and .Values.manager.http.enabled .Values.manager.tls.enabled -}}
66 0.0.0.0:{{ .Values.manager.http.containerPort }},0.0.0.0:{{ .Values.manager.tls.containerPort }} ssl
68 {{- if .Values.manager.http.enabled -}}
69 0.0.0.0:{{ .Values.manager.http.containerPort }}
71 {{- if .Values.manager.tls.enabled -}}
72 0.0.0.0:{{ .Values.manager.tls.containerPort }} ssl
79 Create the KONG_PORTAL_GUI_LISTEN value string
81 {{- define "kong.kongPortalListenValue" -}}
83 {{- if and .Values.portal.http.enabled .Values.portal.tls.enabled -}}
84 0.0.0.0:{{ .Values.portal.http.containerPort }},0.0.0.0:{{ .Values.portal.tls.containerPort }} ssl
86 {{- if .Values.portal.http.enabled -}}
87 0.0.0.0:{{ .Values.portal.http.containerPort }}
89 {{- if .Values.portal.tls.enabled -}}
90 0.0.0.0:{{ .Values.portal.tls.containerPort }} ssl
97 Create the KONG_PORTAL_API_LISTEN value string
99 {{- define "kong.kongPortalApiListenValue" -}}
101 {{- if and .Values.portalapi.http.enabled .Values.portalapi.tls.enabled -}}
102 0.0.0.0:{{ .Values.portalapi.http.containerPort }},0.0.0.0:{{ .Values.portalapi.tls.containerPort }} ssl
104 {{- if .Values.portalapi.http.enabled -}}
105 0.0.0.0:{{ .Values.portalapi.http.containerPort }}
107 {{- if .Values.portalapi.tls.enabled -}}
108 0.0.0.0:{{ .Values.portalapi.tls.containerPort }} ssl
115 Create the ingress servicePort value string
118 {{- define "kong.ingress.servicePort" -}}
119 {{- if .tls.enabled -}}
120 {{ .tls.servicePort }}
122 {{ .http.servicePort }}
127 {{- define "kong.env" -}}
128 {{- range $key, $val := .Values.env }}
129 - name: KONG_{{ $key | upper}}
130 {{- $valueType := printf "%T" $val -}}
131 {{ if eq $valueType "map[string]interface {}" }}
132 {{ toYaml $val | indent 2 -}}
134 value: {{ $val | quote -}}
139 {{- define "kong.wait-for-db" -}}
141 image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
142 imagePullPolicy: {{ .Values.image.pullPolicy }}
144 {{- if .Values.enterprise.enabled }}
145 {{- include "kong.license" . | nindent 2 }}
147 {{- if .Values.postgresql.enabled }}
149 value: {{ template "kong.postgresql.fullname" . }}
151 value: "{{ .Values.postgresql.service.port }}"
152 - name: KONG_PG_PASSWORD
155 name: {{ template "kong.postgresql.fullname" . }}
156 key: postgresql-password
158 {{- if .Values.cassandra.enabled }}
159 - name: KONG_CASSANDRA_CONTACT_POINTS
160 value: {{ template "kong.cassandra.fullname" . }}
162 {{- include "kong.env" . | nindent 2 }}
163 command: [ "/bin/sh", "-c", "until kong start; do echo 'waiting for db'; sleep 1; done; kong stop" ]
166 {{- define "kong.controller-container" -}}
167 - name: ingress-controller
169 - /kong-ingress-controller
170 # Service from were we extract the IP address/es to use in Ingress status
171 - --publish-service={{ .Release.Namespace }}/{{ template "kong.fullname" . }}-proxy
172 # Set the ingress class
173 - --ingress-class={{ .Values.ingressController.ingressClass }}
174 - --election-id=kong-ingress-controller-leader-{{ .Values.ingressController.ingressClass }}
175 # the kong URL points to the kong admin api server
176 {{- if .Values.admin.useTLS }}
177 - --kong-url=https://localhost:{{ .Values.admin.containerPort }}
178 - --admin-tls-skip-verify # TODO make this configurable
180 - --kong-url=http://localhost:{{ .Values.admin.containerPort }}
187 fieldPath: metadata.name
188 - name: POD_NAMESPACE
192 fieldPath: metadata.namespace
193 image: "{{ .Values.ingressController.image.repository }}:{{ .Values.ingressController.image.tag }}"
194 imagePullPolicy: {{ .Values.image.pullPolicy }}
201 initialDelaySeconds: 30
215 {{ toYaml .Values.ingressController.resources | indent 10 }}
219 Retrieve Kong Enterprise license from a secret and make it available in env vars
221 {{- define "kong.license" -}}
222 - name: KONG_LICENSE_DATA
225 name: {{ .Values.enterprise.license_secret }}