Skip to content

Commit

Permalink
[stable/wordpress] Add Prometheus ServiceMonitor (helm#15288)
Browse files Browse the repository at this point in the history
* Prometheus ServiceMonitor added

Signed-off-by: Matteo Dell'Aquila <[email protected]>

*  app label uniformed, matchLabels fixed

Signed-off-by: Matteo Dell'Aquila <[email protected]>
  • Loading branch information
moebius87 authored and Thomas Tischner committed Aug 13, 2019
1 parent a71b7bd commit 3a9b702
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stable/wordpress/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: wordpress
version: 5.12.6
version: 5.13.0
appVersion: 5.2.2
description: Web publishing platform for building blogs and websites.
icon: https://bitnami.com/assets/stacks/wordpress/img/wordpress-stack-220x234.png
Expand Down
9 changes: 9 additions & 0 deletions stable/wordpress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ The following table lists the configurable parameters of the WordPress chart and
| `service.type` | Kubernetes Service type | `LoadBalancer` |
| `service.port` | Service HTTP port | `80` |
| `service.httpsPort` | Service HTTPS port | `443` |
| `service.metricsPort` | Service Metrics port | `9117` |
| `service.externalTrafficPolicy` | Enable client source IP preservation | `Cluster` |
| `service.nodePorts.http` | Kubernetes http node port | `""` |
| `service.nodePorts.https` | Kubernetes https node port | `""` |
| `service.nodePorts.metrics` | Kubernetes metrics node port | `""` |
| `service.extraPorts` | Extra ports to expose in the service (normally used with the `sidecar` value) | `nil` |
| `healthcheckHttps` | Use https for liveliness and readiness | `false` |
| `livenessProbeHeaders` | Headers to use for livenessProbe | `nil` |
Expand Down Expand Up @@ -123,6 +125,13 @@ The following table lists the configurable parameters of the WordPress chart and
| `metrics.image.pullSecrets` | Specify docker-registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) |
| `metrics.podAnnotations` | Additional annotations for Metrics exporter pod | `{prometheus.io/scrape: "true", prometheus.io/port: "9117"}` |
| `metrics.resources` | Exporter resource requests/limit | `{}` |
| `metrics.serviceMonitor.enabled` | Create ServiceMonitor Resource for scraping metrics using PrometheusOperator | `false` |
| `metrics.serviceMonitor.namespace` | Namespace where servicemonitor resource should be created | `nil` |
| `metrics.serviceMonitor.interval` | Specify the interval at which metrics should be scraped | `30s` |
| `metrics.serviceMonitor.scrapeTimeout`| Specify the timeout after which the scrape is ended | `nil` |
| `metrics.serviceMonitor.relabellings`| Specify Metric Relabellings to add to the scrape endpoint | `nil` |
| `metrics.serviceMonitor.honorLabels` | honorLabels chooses the metric's labels on collisions with target labels. | `false` |
| `metrics.serviceMonitor.additionalLabels`| Used to pass Labels that are required by the Installed Prometheus Operator | `{}` |
| `sidecars` | Attach additional containers to the pod | `nil` |
| `updateStrategy` | Set up update strategy | `RollingUpdate` |

Expand Down
36 changes: 36 additions & 0 deletions stable/wordpress/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "wordpress.fullname" . }}
{{- if .Values.metrics.serviceMonitor.namespace }}
namespace: {{ .Values.metrics.serviceMonitor.namespace }}
{{- end }}
labels:
app: "{{ template "wordpress.fullname" . }}"
chart: {{ template "wordpress.chart" . }}
heritage: "{{ .Release.Service }}"
release: "{{ .Release.Name }}"
{{- if .Values.metrics.serviceMonitor.additionalLabels }}
{{ toYaml .Values.metrics.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
spec:
endpoints:
- port: metrics
interval: {{ .Values.metrics.serviceMonitor.interval }}
{{- if .Values.metrics.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
{{- end }}
honorLabels: {{ .Values.metrics.serviceMonitor.honorLabels }}
{{- if .Values.metrics.serviceMonitor.relabellings }}
metricRelabelings:
{{ toYaml .Values.metrics.serviceMonitor.relabellings | indent 6 }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels:
app: "{{ template "wordpress.fullname" . }}"
release: "{{ .Release.Name }}"
{{- end }}
10 changes: 10 additions & 0 deletions stable/wordpress/templates/svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ spec:
{{- else if eq .Values.service.type "ClusterIP" }}
nodePort: null
{{- end }}
{{- if .Values.metrics.enabled }}
- name: metrics
port: {{ .Values.service.metricsPort }}
targetPort: metrics
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePorts.metrics)))}}
nodePort: {{ .Values.service.nodePorts.metrics }}
{{- else if eq .Values.service.type "ClusterIP" }}
nodePort: null
{{- end }}
{{- end }}
{{- if .Values.service.extraPorts }}
{{ toYaml .Values.service.extraPorts | indent 4 }}
{{- end }}
Expand Down
24 changes: 24 additions & 0 deletions stable/wordpress/values-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,17 @@ service:
port: 80
# HTTPS Port
httpsPort: 443
# metrics Port
metricsPort: 9117
##
## nodePorts:
## http: <to set explicitly, choose port between 30000-32767>
## https: <to set explicitly, choose port between 30000-32767>
## metrics: <to set explicitly, choose port between 30000-32767>
nodePorts:
http: ""
https: ""
metrics: ""
## Enable client source IP preservation
## ref http://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip
##
Expand Down Expand Up @@ -345,6 +349,26 @@ metrics:
##
# resources: {}

## Prometheus Service Monitor
## ref: https://github.com/coreos/prometheus-operator
## https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint
serviceMonitor:
## If the operator is installed in your cluster, set to true to create a Service Monitor Entry
enabled: false
## Specify the namespace in which the serviceMonitor resource will be created
# namespace: ""
## Specify the interval at which metrics should be scraped
interval: 30s
## Specify the timeout after which the scrape is ended
# scrapeTimeout: 30s
## Specify Metric Relabellings to add to the scrape endpoint
# relabellings:
## Specify honorLabels parameter to add the scrape endpoint
honorLabels: false
## Used to pass Labels that are used by the Prometheus installed in your cluster to select Service Monitors to work with
## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
additionalLabels: {}

sidecars:
## Add sidecars to the pod.
## e.g.
Expand Down
24 changes: 24 additions & 0 deletions stable/wordpress/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,17 @@ service:
port: 80
# HTTPS Port
httpsPort: 443
# metrics Port
metricsPort: 9117
##
## nodePorts:
## http: <to set explicitly, choose port between 30000-32767>
## https: <to set explicitly, choose port between 30000-32767>
## metrics: <to set explicitly, choose port between 30000-32767>
nodePorts:
http: ""
https: ""
metrics: ""
## Enable client source IP preservation
## ref http://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#preserving-the-client-source-ip
##
Expand Down Expand Up @@ -340,6 +344,26 @@ metrics:
##
# resources: {}

## Prometheus Service Monitor
## ref: https://github.com/coreos/prometheus-operator
## https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#endpoint
serviceMonitor:
## If the operator is installed in your cluster, set to true to create a Service Monitor Entry
enabled: false
## Specify the namespace in which the serviceMonitor resource will be created
# namespace: ""
## Specify the interval at which metrics should be scraped
interval: 30s
## Specify the timeout after which the scrape is ended
# scrapeTimeout: 30s
## Specify Metric Relabellings to add to the scrape endpoint
# relabellings:
## Specify honorLabels parameter to add the scrape endpoint
honorLabels: false
## Used to pass Labels that are used by the Prometheus installed in your cluster to select Service Monitors to work with
## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
additionalLabels: {}

sidecars:
## Add sidecars to the pod.
## e.g.
Expand Down

0 comments on commit 3a9b702

Please sign in to comment.