From 75c25267833f3ed515ceb21cd2e4c856862d608c Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 20 Aug 2019 00:55:31 +0200 Subject: [PATCH] [stable/kong] Options to install Prometheus plugin with ServiceMonitor (#14346) * Options to install Prometheus plugin with ServiceMonitor Signed-off-by: Roman Komkov * Changes after code review Signed-off-by: Roman Komkov * Removed ingressController and plugin dependency. Signed-off-by: Roman Komkov * Version bumped Signed-off-by: Roman Komkov * Remove helm-hook annotations Signed-off-by: Roman Komkov * Remove trailing whitespace Signed-off-by: Roman Komkov --- stable/kong/Chart.yaml | 2 +- stable/kong/README.md | 15 ++++++---- .../config-custom-server-blocks.yaml | 2 +- stable/kong/templates/deployment.yaml | 2 +- stable/kong/templates/servicemonitor.yaml | 29 +++++++++++++++++++ stable/kong/values.yaml | 8 +++++ 6 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 stable/kong/templates/servicemonitor.yaml diff --git a/stable/kong/Chart.yaml b/stable/kong/Chart.yaml index 5939ed4f65..904bc826cc 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.2 +version: 0.16.0 appVersion: 1.2 diff --git a/stable/kong/README.md b/stable/kong/README.md index 498b6d3daf..05aa3668e9 100644 --- a/stable/kong/README.md +++ b/stable/kong/README.md @@ -110,6 +110,9 @@ and their default values. | podDisruptionBudget.enabled | Enable PodDisruptionBudget for Kong | `false` | | podDisruptionBudget.maxUnavailable | Represents the minimum number of Pods that can be unavailable (integer or percentage) | `50%` | | podDisruptionBudget.minAvailable | Represents the number of Pods that must be available (integer or percentage) | | +| serviceMonitor.enabled | Create ServiceMonitor for Prometheus Operator | false | +| serviceMonitor.interval | Scrapping interval | 10s | +| serviceMonitor.namespace | Where to create ServiceMonitor | | ### Admin/Proxy listener override @@ -118,12 +121,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 @@ -171,7 +174,7 @@ kong: key: kong name: postgres ``` - + For complete list of Kong configurations please check https://getkong.org/docs/latest/configuration/. @@ -377,6 +380,7 @@ 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). + | Parameter | Description | Default | | ---------------------------------- | ------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | | enabled | Deploy the ingress controller, rbac and crd | false | @@ -389,3 +393,4 @@ You can can learn about kong ingress custom resource definitions [here](https:// | podDisruptionBudget.enabled | Enable PodDisruptionBudget for ingress controller | `false` | | podDisruptionBudget.maxUnavailable | Represents the minimum number of Pods that can be unavailable (integer or percentage) | `50%` | | podDisruptionBudget.minAvailable | Represents the number of Pods that must be available (integer or percentage) | | + diff --git a/stable/kong/templates/config-custom-server-blocks.yaml b/stable/kong/templates/config-custom-server-blocks.yaml index ddb21201d2..466aa72cd5 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 ae0de9877b..3523813aca 100644 --- a/stable/kong/templates/deployment.yaml +++ b/stable/kong/templates/deployment.yaml @@ -264,7 +264,7 @@ spec: volumes: - name: custom-nginx-template-volume configMap: - name: {{ .Release.Name }}-kong-default-custom-server-blocks + name: {{ template "kong.fullname" . }}-default-custom-server-blocks {{- if (and (not .Values.ingressController.enabled) (eq .Values.env.database "off")) }} - name: kong-custom-dbless-config-volume configMap: diff --git a/stable/kong/templates/servicemonitor.yaml b/stable/kong/templates/servicemonitor.yaml new file mode 100644 index 0000000000..d138d05e73 --- /dev/null +++ b/stable/kong/templates/servicemonitor.yaml @@ -0,0 +1,29 @@ +{{- 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.serviceMonitor.namespace }} + namespace: {{ .Values.serviceMonitor.namespace }} + {{- end }} + labels: + app: {{ template "kong.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + heritage: {{ .Release.Service }} + release: {{ .Release.Name }} +spec: + endpoints: + - targetPort: metrics + scheme: http + {{- if .Values.serviceMonitor.interval }} + interval: {{ .Values.serviceMonitor.interval }} + {{- 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 1bd7ca90dd..90d06ed597 100644 --- a/stable/kong/values.yaml +++ b/stable/kong/values.yaml @@ -396,6 +396,7 @@ ingressController: podDisruptionBudget: enabled: false maxUnavailable: "50%" + # We pass the dbless (declarative) config over here. dblessConfig: # Either Kong's configuration is managed from an existing ConfigMap (with Key: kong.yml) @@ -411,3 +412,10 @@ dblessConfig: # - name: example # paths: # - "/example" + +serviceMonitor: + # Specifies whether ServiceMonitor for Prometheus operator should be created + enabled: false + # interval: 10s + # Specifies namespace, where ServiceMonitor should be installed + # namespace: monitoring