From e6f2435aed58b2256b5d501a4224ee93eaa0ddfb Mon Sep 17 00:00:00 2001 From: Andrii Chubatiuk Date: Mon, 26 Aug 2024 16:00:25 +0300 Subject: [PATCH] vmanomaly: added extra volumes, extra volumesMounts, PDB and PodMonitor (#1320) * vmanomaly: added PDB and PodMonitor * added extravolumes and extravolumemounts * bump version --- charts/victoria-metrics-anomaly/CHANGELOG.md | 1 + charts/victoria-metrics-anomaly/Chart.yaml | 4 +- charts/victoria-metrics-anomaly/README.md | 8 ++-- .../templates/configmap.yaml | 7 +-- .../templates/controller.yaml | 6 +++ .../templates/pdb.yaml | 18 ++++++++ .../templates/pod-monitor.yaml | 44 +++++++++++++++++++ charts/victoria-metrics-anomaly/values.yaml | 23 +++++----- .../victoria-metrics-anomaly/e2e/simple.yaml | 2 - .../victoria-metrics-anomaly/lint/simple.yaml | 4 ++ 10 files changed, 92 insertions(+), 25 deletions(-) create mode 100644 charts/victoria-metrics-anomaly/templates/pdb.yaml create mode 100644 charts/victoria-metrics-anomaly/templates/pod-monitor.yaml diff --git a/charts/victoria-metrics-anomaly/CHANGELOG.md b/charts/victoria-metrics-anomaly/CHANGELOG.md index b0ffb5695..cb8a6dab3 100644 --- a/charts/victoria-metrics-anomaly/CHANGELOG.md +++ b/charts/victoria-metrics-anomaly/CHANGELOG.md @@ -8,6 +8,7 @@ - Fixed image pull secrets. See [this issue](https://github.com/VictoriaMetrics/helm-charts/issues/1285) - Renamed `.Values.persistentVolume.storageClass` to `.Values.persistentVolume.storageClassName` - Removed necessity to set `.Values.persistentVolume.existingClaim` when it should be created by chart. See [this issue](https://github.com/VictoriaMetrics/helm-charts/issues/189) +- Added PDB, PodMonitor, extra volumes and extra volumeMounts ## 1.4.1 diff --git a/charts/victoria-metrics-anomaly/Chart.yaml b/charts/victoria-metrics-anomaly/Chart.yaml index 9c552f98f..bc9095c32 100644 --- a/charts/victoria-metrics-anomaly/Chart.yaml +++ b/charts/victoria-metrics-anomaly/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 type: application name: victoria-metrics-anomaly description: Victoria Metrics Anomaly Detection - a service that continuously scans Victoria Metrics time series and detects unexpected changes within data patterns in real-time. -version: 1.4.1 -appVersion: v1.15.4 +version: 1.4.2 +appVersion: v1.15.6 sources: - https://github.com/VictoriaMetrics/helm-charts icon: https://avatars.githubusercontent.com/u/43720803?s=200&v=4 diff --git a/charts/victoria-metrics-anomaly/README.md b/charts/victoria-metrics-anomaly/README.md index fbe6a7b35..0eb551442 100644 --- a/charts/victoria-metrics-anomaly/README.md +++ b/charts/victoria-metrics-anomaly/README.md @@ -160,7 +160,10 @@ Change the values according to the need of the environment in ``victoria-metrics | persistentVolume.size | string | `"1Gi"` | Size of the volume. Should be calculated based on the metrics you send and retention policy you set. | | persistentVolume.storageClassName | string | `""` | StorageClass to use for persistent volume. Requires server.persistentVolume.enabled: true. If defined, PVC created automatically | | podAnnotations | object | `{}` | Annotations to be added to pod | -| podDisruptionBudget | object | `{"enabled":false,"labels":{}}` | See `kubectl explain poddisruptionbudget.spec` for more. Ref: https://kubernetes.io/docs/tasks/run-application/configure-pdb/ | +| podDisruptionBudget | object | `{"enabled":false,"labels":{},"maxUnavailable":1,"minAvailable":1}` | See `kubectl explain poddisruptionbudget.spec` for more. Ref: https://kubernetes.io/docs/tasks/run-application/configure-pdb/ | +| podMonitor.annotations | object | `{}` | | +| podMonitor.enabled | bool | `false` | | +| podMonitor.extraLabels | object | `{}` | | | podSecurityContext.enabled | bool | `true` | | | resources | object | `{}` | | | securityContext.enabled | bool | `true` | | @@ -170,7 +173,4 @@ Change the values according to the need of the environment in ``victoria-metrics | serviceAccount.annotations | object | `{}` | | | serviceAccount.create | bool | `true` | | | serviceAccount.name | string | `nil` | | -| serviceMonitor.annotations | object | `{}` | | -| serviceMonitor.enabled | bool | `false` | | -| serviceMonitor.extraLabels | object | `{}` | | | tolerations | list | `[]` | Tolerations configurations. Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ | \ No newline at end of file diff --git a/charts/victoria-metrics-anomaly/templates/configmap.yaml b/charts/victoria-metrics-anomaly/templates/configmap.yaml index c6a6fc5e1..20ca49adb 100644 --- a/charts/victoria-metrics-anomaly/templates/configmap.yaml +++ b/charts/victoria-metrics-anomaly/templates/configmap.yaml @@ -5,9 +5,4 @@ metadata: namespace: {{ .Release.Namespace }} labels: {{- include "chart.labels" . | nindent 4 }} data: - config.yml: | - {{ with .Values.config }} - {{- . | toYaml | nindent 4}} - {{ end -}} - - + config.yml: |{{ toYaml (.Values.config | default dict) | nindent 4 }} diff --git a/charts/victoria-metrics-anomaly/templates/controller.yaml b/charts/victoria-metrics-anomaly/templates/controller.yaml index a646b1ae1..69f38c5c7 100644 --- a/charts/victoria-metrics-anomaly/templates/controller.yaml +++ b/charts/victoria-metrics-anomaly/templates/controller.yaml @@ -78,6 +78,9 @@ spec: - name: models-dump mountPath: /tmp/vmanomaly-model-dumps {{- end }} + {{- with .Values.extraVolumeMounts }} + {{- toYaml . | nindent 12 }} + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{ toYaml . | nindent 8 }} {{- end }} @@ -99,6 +102,9 @@ spec: {{- else }} emptyDir: {{ toYaml .Values.emptyDir | nindent 12 }} {{- end }} + {{- with .Values.extraVolumes }} + {{- toYaml . | nindent 8 }} + {{- end }} {{- if and .Values.persistentVolume.enabled (not .Values.persistentVolume.existingClaim) }} volumeClaimTemplates: - apiVersion: v1 diff --git a/charts/victoria-metrics-anomaly/templates/pdb.yaml b/charts/victoria-metrics-anomaly/templates/pdb.yaml new file mode 100644 index 000000000..b45807e40 --- /dev/null +++ b/charts/victoria-metrics-anomaly/templates/pdb.yaml @@ -0,0 +1,18 @@ +{{- if .Values.podDisruptionBudget.enabled }} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ template "chart.fullname" . }} + namespace: {{ .Release.Namespace }} + {{- $ctx := merge (deepCopy .) (dict "extraLabels" .Values.podDisruptionBudget.extraLabels) }} + labels: {{ include "chart.labels" $ctx | nindent 4 }} +spec: + {{- with .Values.podDisruptionBudget.minAvailable }} + minAvailable: {{ . }} + {{- end }} + {{- with .Values.podDisruptionBudget.maxUnavailable }} + maxUnavailable: {{ . }} + {{- end }} + selector: + matchLabels: {{ include "chart.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/victoria-metrics-anomaly/templates/pod-monitor.yaml b/charts/victoria-metrics-anomaly/templates/pod-monitor.yaml new file mode 100644 index 000000000..a5a177770 --- /dev/null +++ b/charts/victoria-metrics-anomaly/templates/pod-monitor.yaml @@ -0,0 +1,44 @@ +{{- if .Values.podMonitor.enabled -}} +{{- $podMonitor := .Values.podMonitor -}} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + {{- with $podMonitor.annotations }} + annotations: {{ toYaml . | nindent 4 }} + {{- end }} + {{- $ctx := merge (deepCopy .) (dict "extraLabels" $podMonitor.extraLabels) }} + labels: {{ include "chart.labels" $ctx | nindent 4 }} + name: {{ template "chart.fullname" . }} + {{- with $podMonitor.namespace }} + namespace: {{ . }} + {{- end }} +spec: + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: {{ include "chart.selectorLabels" . | nindent 6 }} + podMetricsEndpoints: + - port: metrics + {{- with $podMonitor.basicAuth }} + basicAuth: {{ toYaml . | nindent 8 }} + {{- end }} + {{- with $podMonitor.scheme }} + scheme: {{ . }} + {{- end }} + {{- with $podMonitor.interval }} + interval: {{ . }} + {{- end }} + {{- with $podMonitor.scrapeTimeout }} + scrapeTimeout: {{ . }} + {{- end }} + {{- with $podMonitor.tlsConfig }} + tlsConfig: {{ toYaml . | nindent 8 }} + {{- end }} + {{- with $podMonitor.relabelings }} + relabelings: {{ toYaml . | nindent 8 }} + {{- end }} + {{- with $podMonitor.metricRelabelings }} + metricRelabelings: {{ toYaml . | nindent 8 }} + {{- end }} + {{- end }} diff --git a/charts/victoria-metrics-anomaly/values.yaml b/charts/victoria-metrics-anomaly/values.yaml index ed4b61843..9d3ff26d6 100644 --- a/charts/victoria-metrics-anomaly/values.yaml +++ b/charts/victoria-metrics-anomaly/values.yaml @@ -36,8 +36,8 @@ serviceAccount: # -- See `kubectl explain poddisruptionbudget.spec` for more. Ref: https://kubernetes.io/docs/tasks/run-application/configure-pdb/ podDisruptionBudget: enabled: false - # minAvailable: 1 - # maxUnavailable: 1 + minAvailable: 1 + maxUnavailable: 1 labels: {} extraArgs: @@ -56,26 +56,27 @@ extraHostPathMounts: [] # mountPath: /etc/kubernetes/certs # subPath: "" # hostPath: /etc/kubernetes/certs -# readOnly: true + # readOnly: true # -- Extra Volumes for the pod extraVolumes: [] + # - name: example # configMap: -# name: example + # name: example # -- Extra Volume Mounts for the container extraVolumeMounts: [] # - name: example -# mountPath: /example + # mountPath: /example extraContainers: [] # - name: config-reloader -# image: reloader-image + # image: reloader-image podSecurityContext: enabled: true -# fsGroup: 2000 + # fsGroup: 2000 ## Ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ securityContext: @@ -94,7 +95,7 @@ resources: {} # memory: 128Mi # requests: # cpu: 100m -# memory: 128Mi + # memory: 128Mi # -- Annotations to be added to the deployment annotations: {} @@ -109,13 +110,13 @@ nodeSelector: {} tolerations: [] # - key: "key" # operator: "Equal|Exists" -# value: "value" -# effect: "NoSchedule|PreferNoSchedule" + # value: "value" + # effect: "NoSchedule|PreferNoSchedule" # -- Affinity configurations affinity: {} -serviceMonitor: +podMonitor: enabled: false extraLabels: {} annotations: {} diff --git a/hack/helm/victoria-metrics-anomaly/e2e/simple.yaml b/hack/helm/victoria-metrics-anomaly/e2e/simple.yaml index 55eb8eb7f..0bc9b2d1e 100644 --- a/hack/helm/victoria-metrics-anomaly/e2e/simple.yaml +++ b/hack/helm/victoria-metrics-anomaly/e2e/simple.yaml @@ -14,7 +14,6 @@ config: expr: 'sum(rate(vm_slow_row_inserts_total[5m])) / sum(rate(vm_rows_inserted_total[5m]))' writer: datasource_url: http://cluster-victoria-metrics-cluster-vminsert.default.svc.cluster.local:8480/insert/ - monitoring: pull: enabled: true @@ -23,7 +22,6 @@ config: url: "http://cluster-victoria-metrics-cluster-vminsert.default.svc.cluster.local:8480/insert/" extra_labels: job: "vmanomaly" - license: secret: name: "vmanomaly-license" diff --git a/hack/helm/victoria-metrics-anomaly/lint/simple.yaml b/hack/helm/victoria-metrics-anomaly/lint/simple.yaml index d14223565..7c71c0f18 100644 --- a/hack/helm/victoria-metrics-anomaly/lint/simple.yaml +++ b/hack/helm/victoria-metrics-anomaly/lint/simple.yaml @@ -1,3 +1,7 @@ +podMonitor: + enabled: true +podDisruptionBudget: + enabled: true eula: true config: schedulers: