From a264c224b68d6b07015f9191b4ed0dc06b2eae0c Mon Sep 17 00:00:00 2001 From: Nicolas Trangosi Date: Mon, 13 Nov 2023 16:40:05 +0100 Subject: [PATCH] Add support to custom affinity --- docs_src/tutorials/kubernetes.md | 7 ++++--- helm/scaphandre/templates/daemonset.yaml | 4 ++++ helm/scaphandre/templates/servicemonitor.yaml | 4 ++++ helm/scaphandre/values.yaml | 2 ++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/docs_src/tutorials/kubernetes.md b/docs_src/tutorials/kubernetes.md index 6842fb63..4046fa79 100644 --- a/docs_src/tutorials/kubernetes.md +++ b/docs_src/tutorials/kubernetes.md @@ -25,9 +25,10 @@ to be installed from the source code. | `serviceMonitor.relabelings` | Allow to add extra labels to metrics | Add node metrics | #### Other parameters -| Name | Description | Value | -| ------------------------------------------ | ----------------------------------------------------------------------------| ------------------------- | -| `tolerations` | Tolerations for pod assignment. Evaluated as a template. | `- operator: "Exists"` | +| Name | Description | Value | +| ------------------------------------------ | ------------------------------------------------------------------------------------------------| ------------------------- | +| `affinity` | Pod scheduling preference. Can be used for instance when some node does not support scaphandre. | `{}` | +| `tolerations` | Tolerations for pod assignment. Evaluated as a template. | `- operator: "Exists"` | ## Install Prometheus diff --git a/helm/scaphandre/templates/daemonset.yaml b/helm/scaphandre/templates/daemonset.yaml index 64839f6e..f7cc860a 100644 --- a/helm/scaphandre/templates/daemonset.yaml +++ b/helm/scaphandre/templates/daemonset.yaml @@ -56,6 +56,10 @@ spec: runAsUser: {{ .Values.userID }} runAsGroup: {{ .Values.userGroup }} serviceAccountName: {{ template "scaphandre.name" . }} + affinity: + {{- with .Values.affinity }} + {{- toYaml . | nindent 8 }} + {{- end }} {{- with .Values.tolerations }} tolerations: {{- toYaml . | nindent 8 }} diff --git a/helm/scaphandre/templates/servicemonitor.yaml b/helm/scaphandre/templates/servicemonitor.yaml index b36ceea4..5b3132fe 100644 --- a/helm/scaphandre/templates/servicemonitor.yaml +++ b/helm/scaphandre/templates/servicemonitor.yaml @@ -22,6 +22,10 @@ spec: interval: {{ .Values.serviceMonitor.interval }} {{- end }} scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }} + {{- if .Values.serviceMonitor.relabelings }} + relabelings: + {{ toYaml .Values.serviceMonitor.relabelings | nindent 8 }} + {{- end }} namespaceSelector: matchNames: - {{ .Release.Namespace }} diff --git a/helm/scaphandre/values.yaml b/helm/scaphandre/values.yaml index 4d1cb089..309ab501 100644 --- a/helm/scaphandre/values.yaml +++ b/helm/scaphandre/values.yaml @@ -41,6 +41,8 @@ serviceMonitor: - __meta_kubernetes_pod_node_name targetLabel: node +affinity: {} + tolerations: # Tolerate all taints for observability - operator: "Exists" \ No newline at end of file