[stable/kong] Allow for declarative configuration (#15284) (#15286)

* [stable/kong] Allow for declarative configuration (#15284)

This commit adds the capabilities to specify a declarative configuration. This
is necessary if you would like to run in DB-less mode with deploying the Kong
ingress controller. Documentation has also been adapted.

Signed-off-by: Christof Debaes <cdebaes@isabel.eu>

* [stable/kong] Allow for declarative configuration (#15284)

Removed trailing spaces, and the include spaces in comments to pass upstream linting.

Signed-off-by: Christof Debaes <cdebaes@isabel.eu>

* [stable/kong] Allow for declarative configuration, add config checksum (#15284)

Added the a configuration checksum such that all pods get restarted if an update
of the declarativeConfig values has been made (as opposed to merely updating the
configMap).

Signed-off-by: Christof Debaes <cdebaes@isabel.eu>

* [stable/kong] Allow for declarative configuration, reorganize toYaml to pass linting (#15284)

Signed-off-by: Christof Debaes <cdebaes@isabel.eu>

* [stable/kong] Add support for existing ConfigMap in declarative mode (helm#15284)

Signed-off-by: Michaël Van de Borne <mvandeborne@isabel.eu>

* [stable/kong] Updating README.md and changed naming from declarative towards dbless (helm#15284)

Signed-off-by: Christof Debaes <cdebaes@isabel.eu>

* [stable/kong] Adding separate CI test for dbless with and without configMap (no KIC). Updated default configMap name and updated sha256 checksum (helm#15284)

Signed-off-by: Christof Debaes <cdebaes@isabel.eu>

* [stable/kong] Renaming the CI test values file so they are picked up by CI (chart-testing)

Signed-off-by: Christof Debaes <cdebaes@isabel.eu>

* [stable/kong] Removed test case with external declarative ConfigMap + Add previous test case with no ingress controllers and no config

Signed-off-by: Christof Debaes <cdebaes@isabel.eu>
This commit is contained in:
Debaes
2019-08-14 09:44:24 -07:00
committed by Kubernetes Prow Robot
parent 9a8032f311
commit 3583a19ff2
9 changed files with 114 additions and 22 deletions
+1 -1
View File
@@ -12,5 +12,5 @@ maintainers:
name: kong
sources:
- https://github.com/Kong/kong
version: 0.14.3
version: 0.15.0
appVersion: 1.2
+28 -17
View File
@@ -135,23 +135,24 @@ Enabling both will create both databases in your cluster, but only one
will be used by Kong based on the `env.database` parameter.
Postgres is enabled by default.
| Parameter | Description | Default |
| ------------------------------ | -------------------------------------------------------------------- | ------------------- |
| cassandra.enabled | Spin up a new cassandra cluster for Kong | `false` |
| postgresql.enabled | Spin up a new postgres instance for Kong | `true` |
| waitImage.repository | Image used to wait for database to become ready | `busybox` |
| waitImage.tag | Tag for image used to wait for database to become ready | `latest` |
| env.database | Choose either `postgres` or `cassandra` | `postgres` |
| env.pg_user | Postgres username | `kong` |
| env.pg_database | Postgres database name | `kong` |
| env.pg_password | Postgres database password (required if you are using your own database)| `kong` |
| env.pg_host | Postgres database host (required if you are using your own database) | `` |
| env.pg_port | Postgres database port | `5432` |
| env.cassandra_contact_points | Cassandra contact points (required if you are using your own database) | `` |
| env.cassandra_port | Cassandra query port | `9042` |
| env.cassandra_keyspace | Cassandra keyspace | `kong` |
| env.cassandra_repl_factor | Replication factor for the Kong keyspace | `2` |
| Parameter | Description | Default |
| ------------------------------| ------------------------------------------------------------------------| ----------------------|
| cassandra.enabled | Spin up a new cassandra cluster for Kong | `false` |
| postgresql.enabled | Spin up a new postgres instance for Kong | `true` |
| waitImage.repository | Image used to wait for database to become ready | `busybox` |
| waitImage.tag | Tag for image used to wait for database to become ready | `latest` |
| env.database | Choose either `postgres`, `cassandra` or `"off"` (for dbless mode) | `postgres` |
| env.pg_user | Postgres username | `kong` |
| env.pg_database | Postgres database name | `kong` |
| env.pg_password | Postgres database password (required if you are using your own database)| `kong` |
| env.pg_host | Postgres database host (required if you are using your own database) | `` |
| env.pg_port | Postgres database port | `5432` |
| env.cassandra_contact_points | Cassandra contact points (required if you are using your own database) | `` |
| env.cassandra_port | Cassandra query port | `9042` |
| env.cassandra_keyspace | Cassandra keyspace | `kong` |
| env.cassandra_repl_factor | Replication factor for the Kong keyspace | `2` |
| dblessConfig.configMap | Name of an existing ConfigMap containing the `kong.yml` file. This must have the key `kong.yml`.| `` |
| dblessConfig.config | Yaml configuration file for the dbless (declarative) configuration of Kong | see in `values.yaml` |
All `kong.env` parameters can also accept a mapping instead of a value to ensure the parameters can be set through configmaps and secrets.
@@ -324,6 +325,16 @@ If your SMTP server requires authentication, you should the `username` and
`smtp_password_secret` must be a Secret containing an `smtp_password` key whose
value is your SMTP password.
### DB-less Configuration
When deploying Kong in DB-less mode (`env.database: "off"`) and without the Ingress
Controller (`ingressController.enabled: false`), Kong needs a config to run. In
this case, configuration can be provided using an exsiting ConfigMap
(`dblessConfig.configMap`) or pushed directly into the values file under
`dblessConfig.config`. See the example configuration in the default values.yaml
for more details.
### Kong Ingress Controller
Kong Ingress Controller's primary purpose is to satisfy Ingress resources
@@ -0,0 +1,23 @@
# CI test for testing dbless deployment without ingress controllers
ingressController:
enabled: false
env:
database: "off"
postgresql:
enabled: false
dblessConfig:
# Or the configuration is passed in full-text below
config:
_format_version: "1.1"
services:
- name: test-svc
url: http://example.com
routes:
- name: test
paths:
- /test
plugins:
- name: request-termination
config:
status_code: 200
message: "dbless-config"
+5
View File
@@ -23,6 +23,11 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- define "kong.dblessConfig.fullname" -}}
{{- $name := default "kong-custom-dbless-config" .Values.dblessConfig.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
+16
View File
@@ -0,0 +1,16 @@
{{- if (and (not .Values.ingressController.enabled) (eq .Values.env.database "off")) }}
{{- if not .Values.dblessConfig.configMap }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "kong.dblessConfig.fullname" . }}
labels:
app: {{ template "kong.name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
data:
kong.yml: |
{{ .Values.dblessConfig.config | toYaml | indent 4 }}
{{- end }}
{{- end }}
+25 -4
View File
@@ -17,10 +17,15 @@ spec:
component: app
template:
metadata:
{{- if .Values.podAnnotations }}
annotations:
{{- if (and (not .Values.ingressController.enabled) (eq .Values.env.database "off" )) }}
{{- if .Values.dblessConfig.config }}
checksum/dbless.config: {{ toYaml .Values.dblessConfig.config | sha256sum }}
{{- end }}
{{- end }}
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
{{- end }}
labels:
app: {{ template "kong.name" . }}
release: {{ .Release.Name }}
@@ -40,7 +45,7 @@ spec:
{{- include "kong.wait-for-db" . | nindent 6 }}
{{ end }}
containers:
{{- if (and (.Values.ingressController) (eq .Values.env.database "off")) }}
{{- if (and (.Values.ingressController.enabled) (eq .Values.env.database "off")) }}
{{- include "kong.controller-container" . | nindent 6 }}
{{ end }}
- name: {{ template "kong.name" . }}
@@ -152,6 +157,10 @@ spec:
- name: KONG_CASSANDRA_CONTACT_POINTS
value: {{ template "kong.cassandra.fullname" . }}
{{- end }}
{{- if (and (not .Values.ingressController.enabled) (eq .Values.env.database "off")) }}
- name: KONG_DECLARATIVE_CONFIG
value: "/kong_dbless/kong.yml"
{{- end }}
{{- include "kong.env" . | indent 8 }}
ports:
- name: admin
@@ -232,6 +241,10 @@ spec:
volumeMounts:
- name: custom-nginx-template-volume
mountPath: /kong
{{- if (and (not .Values.ingressController.enabled) (eq .Values.env.database "off")) }}
- name: kong-custom-dbless-config-volume
mountPath: /kong_dbless/
{{- end }}
readinessProbe:
{{ toYaml .Values.readinessProbe | indent 10 }}
livenessProbe:
@@ -252,4 +265,12 @@ spec:
- name: custom-nginx-template-volume
configMap:
name: {{ .Release.Name }}-kong-default-custom-server-blocks
{{- if (and (not .Values.ingressController.enabled) (eq .Values.env.database "off")) }}
- name: kong-custom-dbless-config-volume
configMap:
{{- if .Values.dblessConfig.configMap }}
name: {{ .Values.dblessConfig.configMap }}
{{- else }}
name: {{ template "kong.dblessConfig.fullname" . }}
{{- end }}
{{- end }}
+16
View File
@@ -387,3 +387,19 @@ ingressController:
name:
ingressClass: kong
# We pass the dbless (declarative) config over here.
dblessConfig:
# Either Kong's configuration is managed from an existing ConfigMap (with Key: kong.yml)
configMap: ""
# Or the configuration is passed in full-text below
config:
_format_version: "1.1"
services:
# Example configuration
# - name: example.com
# url: http://example.com
# routes:
# - name: example
# paths:
# - "/example"