diff --git a/stable/kong/Chart.yaml b/stable/kong/Chart.yaml index e655d8497c..c0df250d94 100644 --- a/stable/kong/Chart.yaml +++ b/stable/kong/Chart.yaml @@ -12,5 +12,5 @@ maintainers: name: kong sources: - https://github.com/Kong/kong -version: 0.14.3 +version: 0.15.0 appVersion: 1.2 diff --git a/stable/kong/README.md b/stable/kong/README.md index 1df9b71625..e717ea8ade 100644 --- a/stable/kong/README.md +++ b/stable/kong/README.md @@ -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 diff --git a/stable/kong/ci/dbless-no-kic-internal-declarative-config-values.yaml b/stable/kong/ci/dbless-no-kic-internal-declarative-config-values.yaml new file mode 100644 index 0000000000..3aebe1f7e7 --- /dev/null +++ b/stable/kong/ci/dbless-no-kic-internal-declarative-config-values.yaml @@ -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" diff --git a/stable/kong/ci/dbless-without-kic.yaml b/stable/kong/ci/dbless-no-kic-values.yaml similarity index 100% rename from stable/kong/ci/dbless-without-kic.yaml rename to stable/kong/ci/dbless-no-kic-values.yaml diff --git a/stable/kong/ci/dbless.yaml b/stable/kong/ci/dbless-values.yaml similarity index 100% rename from stable/kong/ci/dbless.yaml rename to stable/kong/ci/dbless-values.yaml diff --git a/stable/kong/templates/_helpers.tpl b/stable/kong/templates/_helpers.tpl index 401878ae15..0a39678cc9 100644 --- a/stable/kong/templates/_helpers.tpl +++ b/stable/kong/templates/_helpers.tpl @@ -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 */}} diff --git a/stable/kong/templates/config-dbless.yaml b/stable/kong/templates/config-dbless.yaml new file mode 100644 index 0000000000..186c0fa805 --- /dev/null +++ b/stable/kong/templates/config-dbless.yaml @@ -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 }} diff --git a/stable/kong/templates/deployment.yaml b/stable/kong/templates/deployment.yaml index cbc55bee88..c6552aec22 100644 --- a/stable/kong/templates/deployment.yaml +++ b/stable/kong/templates/deployment.yaml @@ -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 }} diff --git a/stable/kong/values.yaml b/stable/kong/values.yaml index 768ca3e8f3..96598f8d81 100644 --- a/stable/kong/values.yaml +++ b/stable/kong/values.yaml @@ -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"