From 72a7347cc0feaac332a30a42bae414255964b139 Mon Sep 17 00:00:00 2001 From: Roman Komkov Date: Thu, 30 May 2019 23:17:16 +0200 Subject: [PATCH 1/6] Options to install Prometheus plugin with ServiceMonitor Signed-off-by: Roman Komkov --- stable/kong/Chart.yaml | 2 +- stable/kong/README.md | 55 ++++++++++++++----- stable/kong/ci/dbless.yaml | 1 + stable/kong/ci/ingressController-values.yaml | 1 + stable/kong/templates/cleanup-crds.yaml | 40 ++++++++++++++ stable/kong/templates/crd-kongconsumer.yaml | 5 +- stable/kong/templates/crd-kongcredential.yaml | 5 +- stable/kong/templates/crd-kongingress.yaml | 5 +- stable/kong/templates/crd-kongplugins.yaml | 5 +- stable/kong/templates/prometheus-plugin.yaml | 13 +++++ stable/kong/templates/servicemonitor.yaml | 33 +++++++++++ stable/kong/values.yaml | 11 ++++ 12 files changed, 157 insertions(+), 19 deletions(-) create mode 100644 stable/kong/templates/cleanup-crds.yaml create mode 100644 stable/kong/templates/prometheus-plugin.yaml create mode 100644 stable/kong/templates/servicemonitor.yaml diff --git a/stable/kong/Chart.yaml b/stable/kong/Chart.yaml index 60d12a1a5cf9..67e678f1b978 100644 --- a/stable/kong/Chart.yaml +++ b/stable/kong/Chart.yaml @@ -10,5 +10,5 @@ maintainers: name: kong sources: - https://github.com/Kong/kong -version: 0.11.2 +version: 0.13.0 appVersion: 1.1 diff --git a/stable/kong/README.md b/stable/kong/README.md index 062ca10646d1..e71fc896d2b0 100644 --- a/stable/kong/README.md +++ b/stable/kong/README.md @@ -105,12 +105,12 @@ the value provided by you as opposed to constructing a listen variable from fields like `proxy.http.containerPort` and `proxy.http.enabled`. This allows you to be more prescriptive when defining listen directives. -**Note:** Overriding `env.proxy_listen` and `env.admin_listen` will potentially cause -`admin.containerPort`, `proxy.http.containerPort` and `proxy.tls.containerPort` to become out of sync, +**Note:** Overriding `env.proxy_listen` and `env.admin_listen` will potentially cause +`admin.containerPort`, `proxy.http.containerPort` and `proxy.tls.containerPort` to become out of sync, and therefore must be updated accordingly. -I.E. updatating to `env.proxy_listen: 0.0.0.0:4444, 0.0.0.0:4443 ssl` will need -`proxy.http.containerPort: 4444` and `proxy.tls.containerPort: 4443` to be set in order +I.E. updatating to `env.proxy_listen: 0.0.0.0:4444, 0.0.0.0:4443 ssl` will need +`proxy.http.containerPort: 4444` and `proxy.tls.containerPort: 4443` to be set in order for the service definition to work properly. ### Kong-specific parameters @@ -157,7 +157,7 @@ kong: key: kong name: postgres ``` - + For complete list of Kong configurations please check https://getkong.org/docs/latest/configuration/. @@ -218,12 +218,39 @@ You can can learn about kong ingress custom resource definitions here: - [https://github.com/Kong/kubernetes-ingress-controller/blob/master/docs/custom-resources.md]() -| Parameter | Description | Default | -| --------------- | ----------------------------------------- | ---------------------------------------------------------------------------- | -| enabled | Deploy the ingress controller, rbac and crd | false | -| replicaCount | Number of desired ingress controllers | 1 | -| image.repository | Docker image with the ingress controller | kong-docker-kubernetes-ingress-controller.bintray.io/kong-ingress-controller | -| image.tag | Version of the ingress controller | 0.2.0 | -| readinessProbe | Kong ingress controllers readiness probe | | -| livenessProbe | Kong ingress controllers liveness probe | | -| ingressClass | The ingress-class value for controller | nginx +#### Expose metrics in Prometheus format + +Kong can expose metrics in Prometheus format if prometheus plugin is enabled. +Presence of Kong Ingress Controller allows you to enable this plugin, using +KongPlugin custom resource during the chart installation: + +```bash +helm install stable/kong --set ingressController.enabled=true \ + --set ingressController.metrics.enabled=true --name kong --namespace kong +``` + +Optionaly you can install a ServiceMonitor for Prometheus Operator: + +```bash +helm install stable/kong --set ingressController.enabled=true \ + --set ingressController.metrics.enabled=true \ + --set ingressController.metrics.serviceMonitor.create=true \ + --name kong --namespace kong +``` + + +| Parameter | Description | Default | +| --------------- | ------------------------------------------ | ---------------------------------------------------------------------------- | +| enabled | Deploy the ingress controller, rbac and crd | false | +| replicaCount | Number of desired ingress controllers | 1 | +| image.repository | Docker image with the ingress controller | kong-docker-kubernetes-ingress-controller.bintray.io/kong-ingress-controller | +| image.tag | Version of the ingress controller | 0.4.0 | +| readinessProbe | Kong ingress controllers readiness probe | | +| livenessProbe | Kong ingress controllers liveness probe | | +| ingressClass | The ingress-class value for controller | kong | +| installCRDs | Install Kong ingress controllers custom resource definitions | true | +| cleanUpCRDs | Delete CRDs with the release (useful for CI scenarios) | false | +| metrics.enabled | Enable Kong Prometheus plugin as KongPlugin (requires ingressController to be enabled) | false | +| metrics.serviceMonitor.create | Create ServiceMonitor for Prometheus Operator | false | +| metrics.serviceMonitor.interval | Scrapping interval | 10s | +| metrics.serviceMonitor.namespace | Where to create ServiceMonitor | | diff --git a/stable/kong/ci/dbless.yaml b/stable/kong/ci/dbless.yaml index 6b96a33a9199..acc1143ccdb1 100644 --- a/stable/kong/ci/dbless.yaml +++ b/stable/kong/ci/dbless.yaml @@ -1,6 +1,7 @@ # CI test for testing dbless deployment ingressController: enabled: true + cleanUpCRDs: true env: database: "off" postgresql: diff --git a/stable/kong/ci/ingressController-values.yaml b/stable/kong/ci/ingressController-values.yaml index e36fed4aa25c..4341d46e4a1a 100644 --- a/stable/kong/ci/ingressController-values.yaml +++ b/stable/kong/ci/ingressController-values.yaml @@ -1,3 +1,4 @@ # CI test for Ingress controller basic installation ingressController: enabled: true + cleanUpCRDs: true diff --git a/stable/kong/templates/cleanup-crds.yaml b/stable/kong/templates/cleanup-crds.yaml new file mode 100644 index 000000000000..6ffe246c4a78 --- /dev/null +++ b/stable/kong/templates/cleanup-crds.yaml @@ -0,0 +1,40 @@ +{{- if .Values.ingressController.cleanUpCRDs }} +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ template "kong.fullname" . }}-cleanup-crds + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": pre-delete + "helm.sh/hook-weight": "3" + "helm.sh/hook-delete-policy": hook-succeeded + labels: + app: {{ template "kong.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + template: + metadata: + name: kong-cleanup-crds + spec: + serviceAccountName: {{ include "kong.serviceAccountName" . }} + containers: + - name: kubectl + image: docker.io/bitnami/kubectl:1.14.1 + imagePullPolicy: IfNotPresent + command: + - /bin/sh + - -c + - > + kubectl delete kongconsumers --all; + kubectl delete kongcredentials --all; + kubectl delete kongingresses --all; + kubectl delete kongplugins --all; + sleep 10; + kubectl delete crd kongconsumers.configuration.konghq.com; + kubectl delete crd kongcredentials.configuration.konghq.com; + kubectl delete crd kongingresses.configuration.konghq.com; + kubectl delete crd kongplugins.configuration.konghq.com; + restartPolicy: OnFailure +{{- end }} diff --git a/stable/kong/templates/crd-kongconsumer.yaml b/stable/kong/templates/crd-kongconsumer.yaml index a25eff50b0de..606cfd317f12 100644 --- a/stable/kong/templates/crd-kongconsumer.yaml +++ b/stable/kong/templates/crd-kongconsumer.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.ingressController.enabled .Values.ingressController.installCRDs -}} +{{- if and .Release.IsInstall .Values.ingressController.enabled .Values.ingressController.installCRDs -}} apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: @@ -8,6 +8,9 @@ metadata: chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" + annotations: + "helm.sh/hook": crd-install + "helm.sh/hook-delete-policy": "before-hook-creation" spec: group: configuration.konghq.com version: v1 diff --git a/stable/kong/templates/crd-kongcredential.yaml b/stable/kong/templates/crd-kongcredential.yaml index d4421578776c..29715934c41d 100644 --- a/stable/kong/templates/crd-kongcredential.yaml +++ b/stable/kong/templates/crd-kongcredential.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.ingressController.enabled .Values.ingressController.installCRDs -}} +{{- if and .Release.IsInstall .Values.ingressController.enabled .Values.ingressController.installCRDs -}} apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: @@ -8,6 +8,9 @@ metadata: chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" + annotations: + "helm.sh/hook": crd-install + "helm.sh/hook-delete-policy": "before-hook-creation" spec: group: configuration.konghq.com version: v1 diff --git a/stable/kong/templates/crd-kongingress.yaml b/stable/kong/templates/crd-kongingress.yaml index 17d4ce73d813..bd35f27737f9 100644 --- a/stable/kong/templates/crd-kongingress.yaml +++ b/stable/kong/templates/crd-kongingress.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.ingressController.enabled .Values.ingressController.installCRDs -}} +{{- if and .Release.IsInstall .Values.ingressController.enabled .Values.ingressController.installCRDs -}} apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: @@ -8,6 +8,9 @@ metadata: chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" + annotations: + "helm.sh/hook": crd-install + "helm.sh/hook-delete-policy": "before-hook-creation" spec: group: configuration.konghq.com version: v1 diff --git a/stable/kong/templates/crd-kongplugins.yaml b/stable/kong/templates/crd-kongplugins.yaml index bdd96048c3b2..b479a9d589e3 100644 --- a/stable/kong/templates/crd-kongplugins.yaml +++ b/stable/kong/templates/crd-kongplugins.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.ingressController.enabled .Values.ingressController.installCRDs -}} +{{- if and .Release.IsInstall .Values.ingressController.enabled .Values.ingressController.installCRDs -}} apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: @@ -8,6 +8,9 @@ metadata: chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" + annotations: + "helm.sh/hook": crd-install + "helm.sh/hook-delete-policy": "before-hook-creation" spec: group: configuration.konghq.com version: v1 diff --git a/stable/kong/templates/prometheus-plugin.yaml b/stable/kong/templates/prometheus-plugin.yaml new file mode 100644 index 000000000000..1100fe5522a1 --- /dev/null +++ b/stable/kong/templates/prometheus-plugin.yaml @@ -0,0 +1,13 @@ +{{- if and .Values.ingressController.enabled .Values.ingressController.metrics.enabled }} +apiVersion: configuration.konghq.com/v1 +kind: KongPlugin +metadata: + name: prometheus + labels: + app: {{ template "kong.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" + global: "true" +plugin: prometheus +{{- end }} diff --git a/stable/kong/templates/servicemonitor.yaml b/stable/kong/templates/servicemonitor.yaml new file mode 100644 index 000000000000..a0c0129dd581 --- /dev/null +++ b/stable/kong/templates/servicemonitor.yaml @@ -0,0 +1,33 @@ +{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) .Values.ingressController.enabled .Values.ingressController.metrics.serviceMonitor.create }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template "kong.fullname" . }} + {{- if .Values.ingressController.metrics.serviceMonitor.namespace }} + namespace: {{ .Values.ingressController.metrics.serviceMonitor.namespace }} + {{- end }} + labels: + app: {{ template "kong.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +spec: + endpoints: + - port: kong-admin + {{- if .Values.ingressController.metrics.serviceMonitor.interval }} + interval: {{ .Values.ingressController.metrics.serviceMonitor.interval }} + {{- end }} + {{- if .Values.admin.useTLS }} + scheme: https + tlsConfig: + insecureSkipVerify: true + {{- end }} + jobLabel: {{ .Release.Name }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + app: {{ template "kong.name" . }} + release: {{ .Release.Name }} +{{- end }} diff --git a/stable/kong/values.yaml b/stable/kong/values.yaml index f7d5dbbec6b3..956334452ff8 100644 --- a/stable/kong/values.yaml +++ b/stable/kong/values.yaml @@ -200,6 +200,7 @@ ingressController: timeoutSeconds: 5 installCRDs: true + cleanUpCRDs: false rbac: # Specifies whether RBAC resources should be created @@ -213,3 +214,13 @@ ingressController: name: ingressClass: kong + + metrics: + # Enables Kong Prometheus plugin as KongPlugin object + enabled: false + serviceMonitor: + # Specifies whether ServiceMonitor for Prometheus operator should be created + create: false + # interval: 10s + # Specifies namespace, where ServiceMonitor should be installed + # namespace: monitoring From a40837d983673895a0e6ebf2c479778079fcd9e8 Mon Sep 17 00:00:00 2001 From: Roman Komkov Date: Tue, 6 Aug 2019 21:04:26 +0200 Subject: [PATCH 2/6] Changes after code review Signed-off-by: Roman Komkov --- stable/kong/README.md | 3 +- stable/kong/ci/dbless.yaml | 1 - stable/kong/ci/ingressController-values.yaml | 1 - stable/kong/templates/cleanup-crds.yaml | 40 ------------------- .../config-custom-server-blocks.yaml | 2 +- stable/kong/templates/deployment.yaml | 2 +- stable/kong/templates/prometheus-plugin.yaml | 2 +- stable/kong/templates/servicemonitor.yaml | 10 ++--- stable/kong/values.yaml | 3 +- 9 files changed, 8 insertions(+), 56 deletions(-) delete mode 100644 stable/kong/templates/cleanup-crds.yaml diff --git a/stable/kong/README.md b/stable/kong/README.md index 4a4ab7228333..27be13433bdc 100644 --- a/stable/kong/README.md +++ b/stable/kong/README.md @@ -394,8 +394,7 @@ helm install stable/kong --set ingressController.enabled=true \ | livenessProbe | Kong ingress controllers liveness probe | | | ingressClass | The ingress-class value for controller | kong | | installCRDs | Install Kong ingress controllers custom resource definitions | true | -| cleanUpCRDs | Delete CRDs with the release (useful for CI scenarios) | false | | metrics.enabled | Enable Kong Prometheus plugin as KongPlugin (requires ingressController to be enabled) | false | -| metrics.serviceMonitor.create | Create ServiceMonitor for Prometheus Operator | false | +| metrics.serviceMonitor.enabled | Create ServiceMonitor for Prometheus Operator | false | | metrics.serviceMonitor.interval | Scrapping interval | 10s | | metrics.serviceMonitor.namespace | Where to create ServiceMonitor | | diff --git a/stable/kong/ci/dbless.yaml b/stable/kong/ci/dbless.yaml index acc1143ccdb1..6b96a33a9199 100644 --- a/stable/kong/ci/dbless.yaml +++ b/stable/kong/ci/dbless.yaml @@ -1,7 +1,6 @@ # CI test for testing dbless deployment ingressController: enabled: true - cleanUpCRDs: true env: database: "off" postgresql: diff --git a/stable/kong/ci/ingressController-values.yaml b/stable/kong/ci/ingressController-values.yaml index 4341d46e4a1a..e36fed4aa25c 100644 --- a/stable/kong/ci/ingressController-values.yaml +++ b/stable/kong/ci/ingressController-values.yaml @@ -1,4 +1,3 @@ # CI test for Ingress controller basic installation ingressController: enabled: true - cleanUpCRDs: true diff --git a/stable/kong/templates/cleanup-crds.yaml b/stable/kong/templates/cleanup-crds.yaml deleted file mode 100644 index 6ffe246c4a78..000000000000 --- a/stable/kong/templates/cleanup-crds.yaml +++ /dev/null @@ -1,40 +0,0 @@ -{{- if .Values.ingressController.cleanUpCRDs }} -apiVersion: batch/v1 -kind: Job -metadata: - name: {{ template "kong.fullname" . }}-cleanup-crds - namespace: {{ .Release.Namespace }} - annotations: - "helm.sh/hook": pre-delete - "helm.sh/hook-weight": "3" - "helm.sh/hook-delete-policy": hook-succeeded - labels: - app: {{ template "kong.name" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" - release: "{{ .Release.Name }}" - heritage: "{{ .Release.Service }}" -spec: - template: - metadata: - name: kong-cleanup-crds - spec: - serviceAccountName: {{ include "kong.serviceAccountName" . }} - containers: - - name: kubectl - image: docker.io/bitnami/kubectl:1.14.1 - imagePullPolicy: IfNotPresent - command: - - /bin/sh - - -c - - > - kubectl delete kongconsumers --all; - kubectl delete kongcredentials --all; - kubectl delete kongingresses --all; - kubectl delete kongplugins --all; - sleep 10; - kubectl delete crd kongconsumers.configuration.konghq.com; - kubectl delete crd kongcredentials.configuration.konghq.com; - kubectl delete crd kongingresses.configuration.konghq.com; - kubectl delete crd kongplugins.configuration.konghq.com; - restartPolicy: OnFailure -{{- end }} diff --git a/stable/kong/templates/config-custom-server-blocks.yaml b/stable/kong/templates/config-custom-server-blocks.yaml index ddb21201d21b..466aa72cd5bf 100644 --- a/stable/kong/templates/config-custom-server-blocks.yaml +++ b/stable/kong/templates/config-custom-server-blocks.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ .Release.Name }}-kong-default-custom-server-blocks + name: {{ template "kong.fullname" . }}-default-custom-server-blocks labels: app: {{ template "kong.name" . }} chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" diff --git a/stable/kong/templates/deployment.yaml b/stable/kong/templates/deployment.yaml index 49a52fd49639..7882641c96b6 100644 --- a/stable/kong/templates/deployment.yaml +++ b/stable/kong/templates/deployment.yaml @@ -251,5 +251,5 @@ spec: volumes: - name: custom-nginx-template-volume configMap: - name: {{ .Release.Name }}-kong-default-custom-server-blocks + name: {{ template "kong.fullname" . }}-default-custom-server-blocks diff --git a/stable/kong/templates/prometheus-plugin.yaml b/stable/kong/templates/prometheus-plugin.yaml index 1100fe5522a1..5e3ccd1d854d 100644 --- a/stable/kong/templates/prometheus-plugin.yaml +++ b/stable/kong/templates/prometheus-plugin.yaml @@ -2,7 +2,7 @@ apiVersion: configuration.konghq.com/v1 kind: KongPlugin metadata: - name: prometheus + name: {{ template "kong.fullname" . }}-prometheus labels: app: {{ template "kong.name" . }} chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" diff --git a/stable/kong/templates/servicemonitor.yaml b/stable/kong/templates/servicemonitor.yaml index a0c0129dd581..007d1a1924c5 100644 --- a/stable/kong/templates/servicemonitor.yaml +++ b/stable/kong/templates/servicemonitor.yaml @@ -1,4 +1,4 @@ -{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) .Values.ingressController.enabled .Values.ingressController.metrics.serviceMonitor.create }} +{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) .Values.ingressController.enabled .Values.ingressController.metrics.serviceMonitor.enabled }} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: @@ -13,15 +13,11 @@ metadata: release: {{ .Release.Name }} spec: endpoints: - - port: kong-admin + - targetPort: metrics + scheme: http {{- if .Values.ingressController.metrics.serviceMonitor.interval }} interval: {{ .Values.ingressController.metrics.serviceMonitor.interval }} {{- end }} - {{- if .Values.admin.useTLS }} - scheme: https - tlsConfig: - insecureSkipVerify: true - {{- end }} jobLabel: {{ .Release.Name }} namespaceSelector: matchNames: diff --git a/stable/kong/values.yaml b/stable/kong/values.yaml index eab9947c1204..f7b072e11f19 100644 --- a/stable/kong/values.yaml +++ b/stable/kong/values.yaml @@ -371,7 +371,6 @@ ingressController: timeoutSeconds: 5 installCRDs: true - cleanUpCRDs: false rbac: # Specifies whether RBAC resources should be created @@ -391,7 +390,7 @@ ingressController: enabled: false serviceMonitor: # Specifies whether ServiceMonitor for Prometheus operator should be created - create: false + enabled: false # interval: 10s # Specifies namespace, where ServiceMonitor should be installed # namespace: monitoring From 0e99b73af4bc025c525baf72968ce6d68ead6f84 Mon Sep 17 00:00:00 2001 From: Roman Komkov Date: Fri, 16 Aug 2019 15:15:08 +0200 Subject: [PATCH 3/6] Removed ingressController and plugin dependency. Signed-off-by: Roman Komkov --- stable/kong/README.md | 28 +++----------------- stable/kong/templates/crd-kongconsumer.yaml | 3 --- stable/kong/templates/prometheus-plugin.yaml | 13 --------- stable/kong/templates/servicemonitor.yaml | 10 +++---- stable/kong/values.yaml | 10 +++---- 5 files changed, 13 insertions(+), 51 deletions(-) delete mode 100644 stable/kong/templates/prometheus-plugin.yaml diff --git a/stable/kong/README.md b/stable/kong/README.md index 4186eb347f41..910681acc0d1 100644 --- a/stable/kong/README.md +++ b/stable/kong/README.md @@ -99,6 +99,9 @@ and their default values. | proxy.ingress.path | Ingress path. | `/` | | proxy.ingress.annotations | Ingress annotations. See documentation for your ingress controller for details | `{}` | | env | Additional [Kong configurations](https://getkong.org/docs/latest/configuration/) | | +| serviceMonitor.enabled | Create ServiceMonitor for Prometheus Operator | false | +| serviceMonitor.interval | Scrapping interval | 10s | +| serviceMonitor.namespace | Where to create ServiceMonitor | | | runMigrations | Run Kong migrations job | `true` | | readinessProbe | Kong readiness probe | | | livenessProbe | Kong liveness probe | | @@ -374,27 +377,6 @@ The custom resources are: You can can learn about kong ingress custom resource definitions [here](https://github.com/Kong/kubernetes-ingress-controller/blob/master/docs/custom-resources.md). -#### Expose metrics in Prometheus format - -Kong can expose metrics in Prometheus format if prometheus plugin is enabled. -Presence of Kong Ingress Controller allows you to enable this plugin, using -KongPlugin custom resource during the chart installation: - -```bash -helm install stable/kong --set ingressController.enabled=true \ - --set ingressController.metrics.enabled=true --name kong --namespace kong -``` - -Optionaly you can install a ServiceMonitor for Prometheus Operator: - -```bash -helm install stable/kong --set ingressController.enabled=true \ - --set ingressController.metrics.enabled=true \ - --set ingressController.metrics.serviceMonitor.create=true \ - --name kong --namespace kong -``` - - | Parameter | Description | Default | | --------------- | ------------------------------------------ | ---------------------------------------------------------------------------- | | enabled | Deploy the ingress controller, rbac and crd | false | @@ -405,7 +387,3 @@ helm install stable/kong --set ingressController.enabled=true \ | livenessProbe | Kong ingress controllers liveness probe | | | ingressClass | The ingress-class value for controller | kong | | installCRDs | Install Kong ingress controllers custom resource definitions | true | -| metrics.enabled | Enable Kong Prometheus plugin as KongPlugin (requires ingressController to be enabled) | false | -| metrics.serviceMonitor.enabled | Create ServiceMonitor for Prometheus Operator | false | -| metrics.serviceMonitor.interval | Scrapping interval | 10s | -| metrics.serviceMonitor.namespace | Where to create ServiceMonitor | | diff --git a/stable/kong/templates/crd-kongconsumer.yaml b/stable/kong/templates/crd-kongconsumer.yaml index 606cfd317f12..b228ca343071 100644 --- a/stable/kong/templates/crd-kongconsumer.yaml +++ b/stable/kong/templates/crd-kongconsumer.yaml @@ -8,9 +8,6 @@ metadata: chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" - annotations: - "helm.sh/hook": crd-install - "helm.sh/hook-delete-policy": "before-hook-creation" spec: group: configuration.konghq.com version: v1 diff --git a/stable/kong/templates/prometheus-plugin.yaml b/stable/kong/templates/prometheus-plugin.yaml deleted file mode 100644 index 5e3ccd1d854d..000000000000 --- a/stable/kong/templates/prometheus-plugin.yaml +++ /dev/null @@ -1,13 +0,0 @@ -{{- if and .Values.ingressController.enabled .Values.ingressController.metrics.enabled }} -apiVersion: configuration.konghq.com/v1 -kind: KongPlugin -metadata: - name: {{ template "kong.fullname" . }}-prometheus - labels: - app: {{ template "kong.name" . }} - chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" - release: "{{ .Release.Name }}" - heritage: "{{ .Release.Service }}" - global: "true" -plugin: prometheus -{{- end }} diff --git a/stable/kong/templates/servicemonitor.yaml b/stable/kong/templates/servicemonitor.yaml index 007d1a1924c5..d138d05e73b9 100644 --- a/stable/kong/templates/servicemonitor.yaml +++ b/stable/kong/templates/servicemonitor.yaml @@ -1,10 +1,10 @@ -{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) .Values.ingressController.enabled .Values.ingressController.metrics.serviceMonitor.enabled }} +{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) .Values.serviceMonitor.enabled }} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: {{ template "kong.fullname" . }} - {{- if .Values.ingressController.metrics.serviceMonitor.namespace }} - namespace: {{ .Values.ingressController.metrics.serviceMonitor.namespace }} + {{- if .Values.serviceMonitor.namespace }} + namespace: {{ .Values.serviceMonitor.namespace }} {{- end }} labels: app: {{ template "kong.name" . }} @@ -15,8 +15,8 @@ spec: endpoints: - targetPort: metrics scheme: http - {{- if .Values.ingressController.metrics.serviceMonitor.interval }} - interval: {{ .Values.ingressController.metrics.serviceMonitor.interval }} + {{- if .Values.serviceMonitor.interval }} + interval: {{ .Values.serviceMonitor.interval }} {{- end }} jobLabel: {{ .Release.Name }} namespaceSelector: diff --git a/stable/kong/values.yaml b/stable/kong/values.yaml index 8aba2ea75b35..63115973a956 100644 --- a/stable/kong/values.yaml +++ b/stable/kong/values.yaml @@ -389,11 +389,11 @@ ingressController: ingressClass: kong serviceMonitor: -# Specifies whether ServiceMonitor for Prometheus operator should be created + # Specifies whether ServiceMonitor for Prometheus operator should be created enabled: false -# interval: 10s -# Specifies namespace, where ServiceMonitor should be installed -# namespace: monitoring + # interval: 10s + # Specifies namespace, where ServiceMonitor should be installed + # namespace: monitoring # We pass the dbless (declarative) config over here. dblessConfig: @@ -409,4 +409,4 @@ dblessConfig: # routes: # - name: example # paths: - # - "/example" \ No newline at end of file + # - "/example" From a45e32f90f22b266cfd46ee37fc177357031b577 Mon Sep 17 00:00:00 2001 From: Roman Komkov Date: Fri, 16 Aug 2019 15:41:25 +0200 Subject: [PATCH 4/6] Version bumped Signed-off-by: Roman Komkov --- stable/kong/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stable/kong/Chart.yaml b/stable/kong/Chart.yaml index c0df250d94e9..904bc826ccad 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.15.0 +version: 0.16.0 appVersion: 1.2 From 06afe5e02a42f5d39f1ca059c66f74f9f5829ccb Mon Sep 17 00:00:00 2001 From: Roman Komkov Date: Mon, 19 Aug 2019 23:55:41 +0200 Subject: [PATCH 5/6] Remove helm-hook annotations Signed-off-by: Roman Komkov --- stable/kong/Chart.yaml | 4 ++-- stable/kong/templates/crd-kongconsumer.yaml | 2 +- stable/kong/templates/crd-kongcredential.yaml | 5 +---- stable/kong/templates/crd-kongingress.yaml | 5 +---- stable/kong/templates/crd-kongplugins.yaml | 5 +---- stable/kong/templates/deployment.yaml | 2 +- 6 files changed, 7 insertions(+), 16 deletions(-) diff --git a/stable/kong/Chart.yaml b/stable/kong/Chart.yaml index 2f04ffd6b836..904bc826ccad 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.17.0 -appVersion: 1.2 \ No newline at end of file +version: 0.16.0 +appVersion: 1.2 diff --git a/stable/kong/templates/crd-kongconsumer.yaml b/stable/kong/templates/crd-kongconsumer.yaml index b228ca343071..a25eff50b0de 100644 --- a/stable/kong/templates/crd-kongconsumer.yaml +++ b/stable/kong/templates/crd-kongconsumer.yaml @@ -1,4 +1,4 @@ -{{- if and .Release.IsInstall .Values.ingressController.enabled .Values.ingressController.installCRDs -}} +{{- if and .Values.ingressController.enabled .Values.ingressController.installCRDs -}} apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: diff --git a/stable/kong/templates/crd-kongcredential.yaml b/stable/kong/templates/crd-kongcredential.yaml index 29715934c41d..d4421578776c 100644 --- a/stable/kong/templates/crd-kongcredential.yaml +++ b/stable/kong/templates/crd-kongcredential.yaml @@ -1,4 +1,4 @@ -{{- if and .Release.IsInstall .Values.ingressController.enabled .Values.ingressController.installCRDs -}} +{{- if and .Values.ingressController.enabled .Values.ingressController.installCRDs -}} apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: @@ -8,9 +8,6 @@ metadata: chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" - annotations: - "helm.sh/hook": crd-install - "helm.sh/hook-delete-policy": "before-hook-creation" spec: group: configuration.konghq.com version: v1 diff --git a/stable/kong/templates/crd-kongingress.yaml b/stable/kong/templates/crd-kongingress.yaml index bd35f27737f9..17d4ce73d813 100644 --- a/stable/kong/templates/crd-kongingress.yaml +++ b/stable/kong/templates/crd-kongingress.yaml @@ -1,4 +1,4 @@ -{{- if and .Release.IsInstall .Values.ingressController.enabled .Values.ingressController.installCRDs -}} +{{- if and .Values.ingressController.enabled .Values.ingressController.installCRDs -}} apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: @@ -8,9 +8,6 @@ metadata: chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" - annotations: - "helm.sh/hook": crd-install - "helm.sh/hook-delete-policy": "before-hook-creation" spec: group: configuration.konghq.com version: v1 diff --git a/stable/kong/templates/crd-kongplugins.yaml b/stable/kong/templates/crd-kongplugins.yaml index b479a9d589e3..bdd96048c3b2 100644 --- a/stable/kong/templates/crd-kongplugins.yaml +++ b/stable/kong/templates/crd-kongplugins.yaml @@ -1,4 +1,4 @@ -{{- if and .Release.IsInstall .Values.ingressController.enabled .Values.ingressController.installCRDs -}} +{{- if and .Values.ingressController.enabled .Values.ingressController.installCRDs -}} apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: @@ -8,9 +8,6 @@ metadata: chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" - annotations: - "helm.sh/hook": crd-install - "helm.sh/hook-delete-policy": "before-hook-creation" spec: group: configuration.konghq.com version: v1 diff --git a/stable/kong/templates/deployment.yaml b/stable/kong/templates/deployment.yaml index 8f7930738f84..8667f1923828 100644 --- a/stable/kong/templates/deployment.yaml +++ b/stable/kong/templates/deployment.yaml @@ -273,4 +273,4 @@ spec: {{- else }} name: {{ template "kong.dblessConfig.fullname" . }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} From 477c8d5de901813ee74160e722b49782269a7d2d Mon Sep 17 00:00:00 2001 From: Roman Komkov Date: Tue, 20 Aug 2019 00:06:06 +0200 Subject: [PATCH 6/6] Remove trailing whitespace Signed-off-by: Roman Komkov --- stable/kong/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stable/kong/values.yaml b/stable/kong/values.yaml index 643aee181743..90d06ed59722 100644 --- a/stable/kong/values.yaml +++ b/stable/kong/values.yaml @@ -412,7 +412,7 @@ dblessConfig: # - name: example # paths: # - "/example" - + serviceMonitor: # Specifies whether ServiceMonitor for Prometheus operator should be created enabled: false