Skip to content

Commit

Permalink
Support per-component tolerations (+ manager)
Browse files Browse the repository at this point in the history
Should partially fix aws/containers-roadmap#2515
  • Loading branch information
loganmzz committed Jan 6, 2025
1 parent 50245a7 commit 26ec8ef
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 21 deletions.
19 changes: 19 additions & 0 deletions charts/amazon-cloudwatch-observability/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
{{- dict "component" .Values.dcgmExporter "context" . | include "amazon-cloudwatch-observability.common.tolerations" | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,4 @@ spec:
}
]
}
{{- with .Values.tolerations }}
tolerations: {{- toYaml . | nindent 2}}
{{- end }}
{{- dict "component" .Values.neuronMonitor "context" . | include "amazon-cloudwatch-observability.common.tolerations" | nindent 2 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
3 changes: 3 additions & 0 deletions charts/amazon-cloudwatch-observability/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 26ec8ef

Please sign in to comment.