From 1bc19703d5b2b053b803e77409509cb84575544e Mon Sep 17 00:00:00 2001 From: WrenIX Date: Mon, 20 Nov 2023 11:25:00 +0100 Subject: [PATCH] fix: cleanup and liniting metrics components Signed-off-by: WrenIX --- charts/nextcloud/Chart.yaml | 2 +- .../deployment.yaml} | 21 +++++++++++-------- .../service.yaml} | 17 ++++++++------- .../servicemonitor.yaml} | 17 ++++++++------- 4 files changed, 31 insertions(+), 26 deletions(-) rename charts/nextcloud/templates/{metrics-deployment.yaml => metrics/deployment.yaml} (86%) rename charts/nextcloud/templates/{metrics-service.yaml => metrics/service.yaml} (66%) rename charts/nextcloud/templates/{metrics-servicemonitor.yaml => metrics/servicemonitor.yaml} (66%) diff --git a/charts/nextcloud/Chart.yaml b/charts/nextcloud/Chart.yaml index 18a63900..d051bca0 100644 --- a/charts/nextcloud/Chart.yaml +++ b/charts/nextcloud/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: nextcloud -version: 4.5.3 +version: 4.5.4 appVersion: 27.1.3 description: A file sharing server that puts the control and security of your own data back into your hands. keywords: diff --git a/charts/nextcloud/templates/metrics-deployment.yaml b/charts/nextcloud/templates/metrics/deployment.yaml similarity index 86% rename from charts/nextcloud/templates/metrics-deployment.yaml rename to charts/nextcloud/templates/metrics/deployment.yaml index ea30e918..74198b6d 100644 --- a/charts/nextcloud/templates/metrics-deployment.yaml +++ b/charts/nextcloud/templates/metrics/deployment.yaml @@ -1,4 +1,5 @@ {{- if .Values.metrics.enabled }} +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -18,20 +19,21 @@ spec: app.kubernetes.io/component: metrics template: metadata: - annotations: {{- toYaml .Values.metrics.podAnnotations | nindent 8 }} + 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 }} + {{- with .Values.metrics.podLabels }} + {{- toYaml . | indent 8 }} + {{- end }} spec: - {{- if .Values.metrics.image.pullSecrets }} + {{- with .Values.metrics.image.pullSecrets }} imagePullSecrets: - {{- range .Values.metrics.image.pullSecrets }} + {{- range . }} - name: {{ . }} - {{- end}} + {{- end}} {{- end }} containers: - name: metrics-exporter @@ -66,8 +68,9 @@ spec: ports: - name: metrics containerPort: 9205 - {{- if .Values.metrics.resources }} - resources: {{- toYaml .Values.metrics.resources | nindent 10 }} + {{- with .Values.metrics.resources }} + resources: + {{- toYaml . | nindent 10 }} {{- end }} securityContext: runAsUser: 1000 diff --git a/charts/nextcloud/templates/metrics-service.yaml b/charts/nextcloud/templates/metrics/service.yaml similarity index 66% rename from charts/nextcloud/templates/metrics-service.yaml rename to charts/nextcloud/templates/metrics/service.yaml index 1d287451..b2f01040 100644 --- a/charts/nextcloud/templates/metrics-service.yaml +++ b/charts/nextcloud/templates/metrics/service.yaml @@ -1,4 +1,5 @@ {{- if .Values.metrics.enabled }} +--- apiVersion: v1 kind: Service metadata: @@ -9,18 +10,18 @@ metadata: app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/component: metrics - {{- 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 }} + {{- with .Values.metrics.service.labels }} + {{- toYaml .Values.metrics.service.labels | nindent 4 }} + {{- end }} + {{- with .Values.metrics.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} {{- end }} spec: type: {{ .Values.metrics.service.type }} - {{ if eq .Values.metrics.service.type "LoadBalancer" -}} {{ if .Values.metrics.service.loadBalancerIP }} + {{- if and (eq .Values.metrics.service.type "LoadBalancer") .Values.metrics.service.loadBalancerIP }} loadBalancerIP: {{ .Values.metrics.service.loadBalancerIP }} - {{ end -}} - {{- end -}} + {{- end }} ports: - name: metrics port: 9205 diff --git a/charts/nextcloud/templates/metrics-servicemonitor.yaml b/charts/nextcloud/templates/metrics/servicemonitor.yaml similarity index 66% rename from charts/nextcloud/templates/metrics-servicemonitor.yaml rename to charts/nextcloud/templates/metrics/servicemonitor.yaml index e007784c..4994bb9d 100644 --- a/charts/nextcloud/templates/metrics-servicemonitor.yaml +++ b/charts/nextcloud/templates/metrics/servicemonitor.yaml @@ -1,10 +1,11 @@ {{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }} +--- apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: {{ template "nextcloud.fullname" . }} - {{- if .Values.metrics.serviceMonitor.namespace }} - namespace: {{ .Values.metrics.serviceMonitor.namespace | quote }} + {{- with .Values.metrics.serviceMonitor.namespace }} + namespace: {{ . | quote }} {{- else }} namespace: {{ .Release.Namespace | quote }} {{- end }} @@ -14,8 +15,8 @@ metadata: app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/component: metrics - {{- if .Values.metrics.serviceMonitor.labels -}} - {{ toYaml .Values.metrics.serviceMonitor.labels | nindent 4 }} + {{- with .Values.metrics.serviceMonitor.labels }} + {{- toYaml .Values.metrics.serviceMonitor.labels | nindent 4 }} {{- end }} spec: jobLabel: {{ .Values.metrics.serviceMonitor.jobLabel | quote }} @@ -30,10 +31,10 @@ spec: endpoints: - port: metrics path: "/" - {{- if .Values.metrics.serviceMonitor.interval }} - interval: {{ .Values.metrics.serviceMonitor.interval }} + {{- with .Values.metrics.serviceMonitor.interval }} + interval: {{ . }} {{- end }} - {{- if .Values.metrics.serviceMonitor.scrapeTimeout }} - scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }} + {{- with .Values.metrics.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ . }} {{- end }} {{- end }}