Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/kong] add nginx custom template feature via config map #15079

Merged
merged 6 commits into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stable/kong/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ maintainers:
name: kong
sources:
- https://github.com/Kong/kong
version: 0.13.0
version: 0.14.0
appVersion: 1.2
29 changes: 29 additions & 0 deletions stable/kong/templates/config-custom-server-blocks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: kong-default-custom-server-blocks
labels:
app: {{ template "kong.name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
data:
servers.conf: |
# Prometheus metrics server
server {
server_name kong_prometheus_exporter;
listen 0.0.0.0:9542; # can be any other port as well
access_log off;
location /metrics {
default_type text/plain;
content_by_lua_block {
local prometheus = require "kong.plugins.prometheus.exporter"
prometheus:collect()
}
}
location /nginx_status {
internal;
access_log off;
stub_status;
}
}
13 changes: 13 additions & 0 deletions stable/kong/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ spec:
{{- include "kong.license" . | nindent 8 }}
{{- end }}
{{- include "kong.env" . | indent 8 }}
- name: KONG_NGINX_HTTP_INCLUDE
value: /kong/servers.conf
{{- if .Values.postgresql.enabled }}
- name: KONG_PG_HOST
value: {{ template "kong.postgresql.fullname" . }}
Expand Down Expand Up @@ -174,6 +176,9 @@ spec:
{{- end}}
protocol: TCP
{{- end }}
- name: metrics
containerPort: 9542
protocol: TCP
{{- if .Values.enterprise.enabled }}
{{- if .Values.manager.http.enabled }}
- name: manager
Expand Down Expand Up @@ -224,6 +229,9 @@ spec:
protocol: TCP
{{- end }}
{{- end }}
volumeMounts:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this container, please expose 9542 and call that port metrics so that Prometheus can automatically scrape this endpoint.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hba

done removing server block from controller and adding metrics port to Kong pods.

Shall the podAnnotations: default to prometheus annotation then ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exposing the port should be enough for some installations while some other installations might need the annotation.
Since pod annotations are already configurable, the user can add those if required.

This is something we can add those too later but I'm being cautious and doing this change incrementally.

Copy link
Contributor Author

@Mattzr Mattzr Jul 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok good point. Since all pods would have the prometheus metrics I thought having the prometheus annotations too would make sense.

Right ok - let me know if there's anything else missing then.

- name: custom-nginx-template-volume
mountPath: /kong
readinessProbe:
{{ toYaml .Values.readinessProbe | indent 10 }}
livenessProbe:
Expand All @@ -240,3 +248,8 @@ spec:
{{- end }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
volumes:
- name: custom-nginx-template-volume
configMap:
name: kong-default-custom-server-blocks