diff --git a/charts/amazon-cloudwatch-observability/templates/_helpers.tpl b/charts/amazon-cloudwatch-observability/templates/_helpers.tpl index deb950b..00d3c49 100644 --- a/charts/amazon-cloudwatch-observability/templates/_helpers.tpl +++ b/charts/amazon-cloudwatch-observability/templates/_helpers.tpl @@ -5,6 +5,25 @@ Expand the name of the chart. {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} +{{- define "amazon-cloudwatch-observability.common.tolerations" -}} +{{- $tolerations := .context.Values.tolerations }} +{{- if .component }} + {{- $replaceTolerations := get .component "tolerationsReplaced" }} + {{- $componentTolerations := get .component "tolerations" }} + {{- if $componentTolerations }} + {{- if or $replaceTolerations (empty $tolerations) }} + {{- $tolerations = $componentTolerations }} + {{- else }} + {{- $tolerations = concat $tolerations $componentTolerations }} + {{- end }} + {{- end }} +{{- end }} +{{- with $tolerations }} +tolerations: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- end }} + {{/* Helper function to modify cloudwatch-agent config */}} diff --git a/charts/amazon-cloudwatch-observability/templates/linux/cloudwatch-agent-custom-resource.yaml b/charts/amazon-cloudwatch-observability/templates/linux/cloudwatch-agent-custom-resource.yaml index ad93d7e..3ebd78e 100644 --- a/charts/amazon-cloudwatch-observability/templates/linux/cloudwatch-agent-custom-resource.yaml +++ b/charts/amazon-cloudwatch-observability/templates/linux/cloudwatch-agent-custom-resource.yaml @@ -191,9 +191,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - {{- with $.Values.tolerations }} - tolerations: {{- toYaml . | nindent 2}} - {{- end }} + {{- dict "component" $agent "context" . | include "amazon-cloudwatch-observability.common.tolerations" | nindent 2 }} --- {{- end }} {{- end }} \ No newline at end of file diff --git a/charts/amazon-cloudwatch-observability/templates/linux/dcgm-exporter-daemonset.yaml b/charts/amazon-cloudwatch-observability/templates/linux/dcgm-exporter-daemonset.yaml index 0eefeeb..814ae89 100644 --- a/charts/amazon-cloudwatch-observability/templates/linux/dcgm-exporter-daemonset.yaml +++ b/charts/amazon-cloudwatch-observability/templates/linux/dcgm-exporter-daemonset.yaml @@ -71,6 +71,4 @@ spec: tls_server_config: cert_file: /etc/amazon-cloudwatch-observability-dcgm-cert/server.crt key_file: /etc/amazon-cloudwatch-observability-dcgm-cert/server.key - {{- with .Values.tolerations }} - tolerations: {{- toYaml . | nindent 2}} - {{- end }} \ No newline at end of file + {{- dict "component" .Values.dcgmExporter "context" . | include "amazon-cloudwatch-observability.common.tolerations" | nindent 2 }} \ No newline at end of file diff --git a/charts/amazon-cloudwatch-observability/templates/linux/fluent-bit-daemonset.yaml b/charts/amazon-cloudwatch-observability/templates/linux/fluent-bit-daemonset.yaml index 73f6866..af01536 100644 --- a/charts/amazon-cloudwatch-observability/templates/linux/fluent-bit-daemonset.yaml +++ b/charts/amazon-cloudwatch-observability/templates/linux/fluent-bit-daemonset.yaml @@ -123,7 +123,5 @@ spec: - fargate nodeSelector: kubernetes.io/os: linux - {{- with .Values.tolerations }} - tolerations: {{- toYaml . | nindent 6}} - {{- end }} + {{- dict "component" .Values.containerLogs.fluentBit "context" . | include "amazon-cloudwatch-observability.common.tolerations" | nindent 6 }} {{- end }} \ No newline at end of file diff --git a/charts/amazon-cloudwatch-observability/templates/linux/neuron-monitor-daemonset.yaml b/charts/amazon-cloudwatch-observability/templates/linux/neuron-monitor-daemonset.yaml index 75e2056..d134dfd 100644 --- a/charts/amazon-cloudwatch-observability/templates/linux/neuron-monitor-daemonset.yaml +++ b/charts/amazon-cloudwatch-observability/templates/linux/neuron-monitor-daemonset.yaml @@ -93,6 +93,4 @@ spec: } ] } - {{- with .Values.tolerations }} - tolerations: {{- toYaml . | nindent 2}} - {{- end }} \ No newline at end of file + {{- dict "component" .Values.neuronMonitor "context" . | include "amazon-cloudwatch-observability.common.tolerations" | nindent 2 }} \ No newline at end of file diff --git a/charts/amazon-cloudwatch-observability/templates/operator-deployment.yaml b/charts/amazon-cloudwatch-observability/templates/operator-deployment.yaml index a055481..d6c8985 100644 --- a/charts/amazon-cloudwatch-observability/templates/operator-deployment.yaml +++ b/charts/amazon-cloudwatch-observability/templates/operator-deployment.yaml @@ -55,3 +55,4 @@ spec: secretName: {{ template "amazon-cloudwatch-observability.certificateSecretName" . }} nodeSelector: kubernetes.io/os: linux + {{- dict "component" .Values.manager "context" . | include "amazon-cloudwatch-observability.common.tolerations" | nindent 6 }} diff --git a/charts/amazon-cloudwatch-observability/templates/windows/cloudwatch-agent-windows-container-insights-daemonset.yaml b/charts/amazon-cloudwatch-observability/templates/windows/cloudwatch-agent-windows-container-insights-daemonset.yaml index a51cd40..a578d50 100644 --- a/charts/amazon-cloudwatch-observability/templates/windows/cloudwatch-agent-windows-container-insights-daemonset.yaml +++ b/charts/amazon-cloudwatch-observability/templates/windows/cloudwatch-agent-windows-container-insights-daemonset.yaml @@ -45,7 +45,5 @@ spec: value: "True" - name: RUN_AS_HOST_PROCESS_CONTAINER value: "True" - {{- with .Values.tolerations }} - tolerations: {{- toYaml . | nindent 2}} - {{- end }} + {{- dict "component" .Values.agent "context" . | include "amazon-cloudwatch-observability.common.tolerations" | nindent 2 }} {{- end }} \ No newline at end of file diff --git a/charts/amazon-cloudwatch-observability/templates/windows/cloudwatch-agent-windows-daemonset.yaml b/charts/amazon-cloudwatch-observability/templates/windows/cloudwatch-agent-windows-daemonset.yaml index 45426af..fd5d1d7 100644 --- a/charts/amazon-cloudwatch-observability/templates/windows/cloudwatch-agent-windows-daemonset.yaml +++ b/charts/amazon-cloudwatch-observability/templates/windows/cloudwatch-agent-windows-daemonset.yaml @@ -38,7 +38,5 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - {{- with .Values.tolerations }} - tolerations: {{- toYaml . | nindent 2}} - {{- end }} + {{- dict "component" .Values.agent "context" . | include "amazon-cloudwatch-observability.common.tolerations" | nindent 2 }} {{- end }} \ No newline at end of file diff --git a/charts/amazon-cloudwatch-observability/templates/windows/fluent-bit-windows-daemonset.yaml b/charts/amazon-cloudwatch-observability/templates/windows/fluent-bit-windows-daemonset.yaml index 7853649..5ea019f 100644 --- a/charts/amazon-cloudwatch-observability/templates/windows/fluent-bit-windows-daemonset.yaml +++ b/charts/amazon-cloudwatch-observability/templates/windows/fluent-bit-windows-daemonset.yaml @@ -67,7 +67,5 @@ spec: terminationGracePeriodSeconds: 10 dnsPolicy: ClusterFirstWithHostNet serviceAccountName: {{ template "cloudwatch-agent.serviceAccountName" . }} - {{- with .Values.tolerations }} - tolerations: {{- toYaml . | nindent 6}} - {{- end }} + {{- dict "component" Values.containerLogs.fluentBit "context" . | include "amazon-cloudwatch-observability.common.tolerations" | nindent 6 }} {{- end }} \ No newline at end of file diff --git a/charts/amazon-cloudwatch-observability/values.yaml b/charts/amazon-cloudwatch-observability/values.yaml index 46bb7b5..9aa4326 100644 --- a/charts/amazon-cloudwatch-observability/values.yaml +++ b/charts/amazon-cloudwatch-observability/values.yaml @@ -1272,6 +1272,9 @@ manager: podLabels: {} service: name: + # When true, root tolerations aren't added to this one. + tolerationsReplaced: false + tolerations: ## Admission webhooks make sure only requests with correctly formatted rules will get into the Operator. admissionWebhooks: create: true