[stable/pomerium] Add prometheus operator ServiceMonitor support (#16033)

* Add ServiceMonitor template for Prometheus Operator

Signed-off-by: Travis Groth <tgroth@gmail.com>

* [stable/pomerium] Fix templating

Signed-off-by: Travis Groth <tgroth@gmail.com>
This commit is contained in:
Travis Groth
2019-08-02 05:41:51 -07:00
committed by Kubernetes Prow Robot
parent 02571588be
commit 2c686c30da
7 changed files with 72 additions and 4 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
apiVersion: v1
name: pomerium
version: 1.2.1
version: 1.2.2
appVersion: 0.1.0
home: http://www.pomerium.io/
icon: https://www.pomerium.io/logo.svg
+29
View File
@@ -75,6 +75,9 @@ Parameter | Description
`service.annotations` | Service annotations | `{}`
`service.externalPort` | Pomerium's port | `443`
`service.type` | Service type (ClusterIP, NodePort or LoadBalancer) | `ClusterIP`
`serviceMonitor.enabled` | Create Prometheus Operator ServiceMonitor | `false`
`serviceMonitor.namespace` | Namespace to create the ServiceMonitor resource in | The namespace of the chart
`serviceMonitor.labels` | Additional labels to apply to the ServiceMonitor resource | `release: prometheus`
`ingress.enabled` | Enables Ingress for pomerium | `false`
`ingress.annotations` | Ingress annotations | `{}`
`ingress.hosts` | Ingress accepted hostnames | `nil`
@@ -84,6 +87,32 @@ Parameter | Description
## Metrics Discovery Configuration
This chart provices two ways to surface metrics for discovery. Under normal circumstances, you will only set up one method.
### Prometheus Operator
This chart assumes you have already installed the Prometheus Operator CRDs.
Example chart values:
```yaml
metrics:
enabled: true
port: 9090 # default
serviceMonitor:
enabled: true
labels:
release: prometheus # default
```
Example ServiceMonitor configuration:
```yaml
serviceMonitorSelector:
matchLabels:
release: prometheus # operator chart default
```
### Prometheus kubernetes_sd_configs
@@ -22,7 +22,10 @@ spec:
targetPort: https
protocol: TCP
name: https
- name: metrics
port: {{ .Values.metrics.port }}
protocol: TCP
targetPort: metrics
{{- if hasKey .Values.service "nodePort" }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
@@ -22,7 +22,10 @@ spec:
targetPort: https
protocol: TCP
name: https
- name: metrics
port: {{ .Values.metrics.port }}
protocol: TCP
targetPort: metrics
{{- if hasKey .Values.service "nodePort" }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
+4 -1
View File
@@ -22,7 +22,10 @@ spec:
targetPort: https
protocol: TCP
name: https
- name: metrics
port: {{ .Values.metrics.port }}
protocol: TCP
targetPort: metrics
{{- if hasKey .Values.service "nodePort" }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
@@ -0,0 +1,24 @@
{{ if .Values.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "pomerium.fullname" . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ .Values.serviceMonitor.namespace }}
{{- end }}
labels:
helm.sh/chart: {{ template "pomerium.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/name: {{ template "pomerium.name" . }}
{{- if .Values.serviceMonitor.labels }}
{{ toYaml .Values.serviceMonitor.labels | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
helm.sh/chart: {{ template "pomerium.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
endpoints:
- port: metrics
{{ end }}
+6
View File
@@ -121,3 +121,9 @@ image:
metrics:
enabled: false
port: 9090
serviceMonitor:
enabled: false
namespace: ""
labels:
release: prometheus