Skip to content

Commit

Permalink
[stable/nextcloud] Add prometheus metrics exporter (helm#22876)
Browse files Browse the repository at this point in the history
* [stable/nextcloud] Add prometheus metrics exporter

Signed-off-by: Tom Koch <[email protected]>

* [stable/nextcloud] Add new line at end of values.yaml

Signed-off-by: Tom Koch <[email protected]>

* [stable/nextcloud] Use specific metrics img-tag, add service for metrics

Signed-off-by: Tom Koch <[email protected]>

* [stable/nextcloud] Add docu for metrics, add annotations to metrics service

Signed-off-by: Tom Koch <[email protected]>
Signed-off-by: cw-niinuma <[email protected]>
Signed-off-by: twinuma <[email protected]>
  • Loading branch information
tomaaron authored and Twinuma committed Jul 1, 2020
1 parent e3527b7 commit c427792
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stable/nextcloud/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: nextcloud
version: 1.11.0
version: 1.12.0
appVersion: 17.0.0
description: A file sharing server that puts the control and security of your own data back into your hands.
keywords:
Expand Down
13 changes: 13 additions & 0 deletions stable/nextcloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ The following table lists the configurable parameters of the nextcloud chart and
| `hpa.maxPods` | Max. pods for the Nextcloud HorizontalPodAutoscaler | `10` |
| `deploymentAnnotations` | Annotations to be added at 'deployment' level | not set |
| `podAnnotations` | Annotations to be added at 'pod' level | not set |
| `metrics.enabled` | Start Prometheus metrics exporter | `false` |
| `metrics.https` | Defines if https is used to connect to nextcloud | `false` (uses http) |
| `metrics.timeout` | When the scrape times out | `5s` |
| `metrics.image.repository` | Nextcloud metrics exporter image name | `xperimental/nextcloud-exporter` |
| `metrics.image.tag` | Nextcloud metrics exporter image tag | `v0.3.0` |
| `metrics.image.pullPolicy` | Nextcloud metrics exporter image pull policy | `IfNotPresent` |
| `metrics.podAnnotations` | Additional annotations for metrics exporter | not set |
| `metrics.podLabels` | Additional labels for metrics exporter | not set |
| `metrics.service.type` | Metrics: Kubernetes Service type | `ClusterIP` |
| `metrics.service.loadBalancerIP` | Metrics: LoadBalancerIp for service type LoadBalancer | `nil` |
| `metrics.service.nodePort` | Metrics: NodePort for service type NodePort | `nil` |
| `metrics.service.annotations` | Additional annotations for service metrics exporter | `{prometheus.io/scrape: "true", prometheus.io/port: "9205"}` |
| `metrics.service.labels` | Additional labels for service metrics exporter | `{}` |

> **Note**:
>
Expand Down
54 changes: 54 additions & 0 deletions stable/nextcloud/templates/metrics-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{- if .Values.metrics.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "nextcloud.fullname" . }}-metrics
labels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
helm.sh/chart: {{ include "nextcloud.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: metrics
spec:
replicas: {{ .Values.metrics.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
annotations: {{- toYaml .Values.metrics.podAnnotations | nindent 8 }}
labels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: metrics
{{- if .Values.metrics.podLabels }}
{{ toYaml .Values.metrics.podLabels | indent 8 }}
{{- end }}
spec:
containers:
- name: metrics-exporter
image: "{{ .Values.metrics.image.repository }}:{{ .Values.metrics.image.tag }}"
imagePullPolicy: {{ .Values.metrics.image.pullPolicy }}
env:
- name: NEXTCLOUD_USERNAME
valueFrom:
secretKeyRef:
name: {{ template "nextcloud.fullname" . }}
key: nextcloud-username
- name: NEXTCLOUD_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "nextcloud.fullname" . }}
key: nextcloud-password
- name: NEXTCLOUD_SERVER
value: http{{ if .Values.metrics.https }}s{{ end }}://{{ .Values.nextcloud.host }}
- name: NEXTCLOUD_TIMEOUT
value: {{ .Values.metrics.timeout }}
ports:
- name: metrics
containerPort: 9205
{{- if .Values.metrics.resources }}
resources: {{- toYaml .Values.metrics.resources | nindent 10 }}
{{- end }}
{{- end }}
31 changes: 31 additions & 0 deletions stable/nextcloud/templates/metrics-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- if .Values.metrics.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "nextcloud.fullname" . }}-metrics
labels:
labels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
helm.sh/chart: {{ include "nextcloud.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Values.metrics.service.labels -}}
{{ toYaml .Values.metrics.service.labels | nindent 4 }}
{{- end -}}
{{- if .Values.metrics.service.annotations }}
annotations: {{ toYaml .Values.metrics.service.annotations | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.metrics.service.type }}
{{ if eq .Values.metrics.service.type "LoadBalancer" -}} {{ if .Values.metrics.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.metrics.service.loadBalancerIP }}
{{ end -}}
{{- end -}}
ports:
- name: metrics
port: 9205
targetPort: metrics
selector:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
36 changes: 36 additions & 0 deletions stable/nextcloud/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,39 @@ nodeSelector: {}
tolerations: []

affinity: {}


## Prometheus Exporter / Metrics
##
metrics:
enabled: false

replicaCount: 1
# The metrics exporter needs to know how you serve Nextcloud either http or https
https: false
timeout: 5s

image:
repository: xperimental/nextcloud-exporter
tag: v0.3.0
pullPolicy: IfNotPresent

## Metrics exporter resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
##
# resources: {}

## Metrics exporter pod Annotation and Labels
# podAnnotations: {}

# podLabels: {}

service:
type: ClusterIP
## Use serviceLoadBalancerIP to request a specific static IP,
## otherwise leave blank
# loadBalancerIP:
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9205"
labels: {}

0 comments on commit c427792

Please sign in to comment.