From 9639c78205d6fb941025666de8c914a1df0a5008 Mon Sep 17 00:00:00 2001 From: saksham Date: Thu, 27 Feb 2025 17:37:21 +0530 Subject: [PATCH 1/2] LOGAN-22004 --- charts/logan/Chart.yaml | 2 +- charts/logan/templates/_helpers.tpl | 61 +++++++++++++++++++ charts/logan/templates/discovery-cronjob.yaml | 3 + charts/logan/templates/fluentd-daemonset.yaml | 3 + .../logan/templates/fluentd-deployment.yaml | 3 + charts/logan/values.yaml | 8 +++ charts/mgmt-agent/Chart.yaml | 2 +- charts/mgmt-agent/templates/_helpers.tpl | 61 +++++++++++++++++++ .../mgmt-agent/templates/metric_server.yaml | 3 + .../templates/mgmt-agent-daemonset.yaml | 3 + .../templates/mgmt-agent-statefulset.yaml | 3 + charts/mgmt-agent/values.yaml | 7 +++ charts/oci-onm/Chart.yaml | 4 +- charts/oci-onm/values.yaml | 6 ++ 14 files changed, 165 insertions(+), 4 deletions(-) diff --git a/charts/logan/Chart.yaml b/charts/logan/Chart.yaml index d8e0fd0..378679d 100644 --- a/charts/logan/Chart.yaml +++ b/charts/logan/Chart.yaml @@ -5,7 +5,7 @@ apiVersion: v2 name: oci-onm-logan description: Charts for sending Kubernetes platform logs, compute logs, and Kubernetes Objects information to OCI Logging Analytics. type: application -version: 3.5.3 +version: 3.5.4 appVersion: "3.0.0" dependencies: diff --git a/charts/logan/templates/_helpers.tpl b/charts/logan/templates/_helpers.tpl index 1518d17..c58542d 100644 --- a/charts/logan/templates/_helpers.tpl +++ b/charts/logan/templates/_helpers.tpl @@ -51,3 +51,64 @@ {{- "UNDEFINED" -}} {{- end -}} {{- end -}} + +{{- define "logan.tolerations" -}} + {{- if kindIs "slice" .Values.tolerations -}} + {{- include "common.tplvalues.render" ( dict "value" .Values.tolerations "context" .) -}} + {{- else -}} + {{- $tolerations := include "common.tplvalues.render" ( dict "value" .Values.tolerations "context" .) -}} + {{- if $tolerations -}} + {{- $noOuter := trimPrefix "[" (trimSuffix "]" $tolerations) -}} + {{- $contents := regexSplit "map\\[" $noOuter -1 | rest -}} + {{- range $content := $contents -}} + {{- $trimmedContent := trimSuffix "]" (trimSuffix " " $content) -}} + {{- $key := regexFind "key:([^ ]+)" $trimmedContent | trimPrefix "key:" -}} + {{- $effect := regexFind "effect:([^ ]+)" $trimmedContent | trimPrefix "effect:" -}} + {{- $operator := regexFind "operator:([^ ]+)" $trimmedContent | trimPrefix "operator:" -}} + {{- $value := regexFind "value:([^ ]+)" $trimmedContent | trimPrefix "value:" -}} + {{- $tolerationSeconds := regexFind "tolerationSeconds:([^ ]+)" $trimmedContent | trimPrefix "tolerationSeconds:" -}} + {{- $firstPrinted := false -}} + {{- if $key }} + {{- if not $firstPrinted }} +- key: {{ $key | quote }} + {{- $firstPrinted = true -}} + {{- else }} + key: {{ $key | quote }} + {{- end }} + {{- end }} + {{- if $effect }} + {{- if not $firstPrinted }} +- effect: {{ $effect | quote }} + {{- $firstPrinted = true -}} + {{- else }} + effect: {{ $effect | quote }} + {{- end }} + {{- end }} + {{- if $operator }} + {{- if not $firstPrinted }} +- operator: {{ $operator | quote }} + {{- $firstPrinted = true -}} + {{- else }} + operator: {{ $operator | quote }} + {{- end }} + {{- end }} + {{- if $value }} + {{- if not $firstPrinted }} +- value: {{ $value | quote }} + {{- $firstPrinted = true -}} + {{- else }} + value: {{ $value | quote }} + {{- end }} + {{- end }} + {{- if $tolerationSeconds }} + {{- if not $firstPrinted }} +- tolerationSeconds: {{ $tolerationSeconds }} + {{- $firstPrinted = true -}} + {{- else }} + tolerationSeconds: {{ $tolerationSeconds }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/logan/templates/discovery-cronjob.yaml b/charts/logan/templates/discovery-cronjob.yaml index 85969fc..74e374d 100644 --- a/charts/logan/templates/discovery-cronjob.yaml +++ b/charts/logan/templates/discovery-cronjob.yaml @@ -22,6 +22,9 @@ spec: spec: restartPolicy: {{ .Values.k8sDiscovery.objects.restartPolicy }} serviceAccountName: {{ $serviceAccount }} + {{- if include "logan.tolerations" . }} + tolerations: {{- include "logan.tolerations" . | trimAll "\n" | nindent 12 }} + {{- end }} {{- if .Values.image.imagePullSecrets }} imagePullSecrets: - name: {{ .Values.image.imagePullSecrets }} diff --git a/charts/logan/templates/fluentd-daemonset.yaml b/charts/logan/templates/fluentd-daemonset.yaml index 3338789..a046179 100644 --- a/charts/logan/templates/fluentd-daemonset.yaml +++ b/charts/logan/templates/fluentd-daemonset.yaml @@ -35,6 +35,9 @@ spec: effect: NoSchedule - key: node-role.kubernetes.io/control-plane effect: NoSchedule + {{- if include "logan.tolerations" . }} + {{- include "logan.tolerations" . | trimAll "\n" | nindent 6 }} + {{- end }} {{- if $imagePullSecrets }} imagePullSecrets: - name: {{ .Values.image.imagePullSecrets }} diff --git a/charts/logan/templates/fluentd-deployment.yaml b/charts/logan/templates/fluentd-deployment.yaml index 251a6eb..a8d4bf6 100644 --- a/charts/logan/templates/fluentd-deployment.yaml +++ b/charts/logan/templates/fluentd-deployment.yaml @@ -31,6 +31,9 @@ spec: version: v1 spec: serviceAccountName: {{ include "logan.serviceAccount" . }} + {{- if include "logan.tolerations" . }} + tolerations: {{- include "logan.tolerations" . | trimAll "\n" | nindent 8 }} + {{- end }} {{- if $imagePullSecrets }} imagePullSecrets: - name: {{ .Values.image.imagePullSecrets }} diff --git a/charts/logan/values.yaml b/charts/logan/values.yaml index aab5796..a92b5e2 100644 --- a/charts/logan/values.yaml +++ b/charts/logan/values.yaml @@ -7,6 +7,8 @@ global: namespace: oci-onm # -- Resource names prefix used, where allowed. resourceNamePrefix: oci-onm + # Add custom Tolerations for resources + tolerations: oci-onm-common: # -- Automatically create, a readonly cluster role, cluster role binding and @@ -27,6 +29,9 @@ oci-onm-common: # -- Kubernetes ServiceAccount name serviceAccount: "{{ .Values.global.resourceNamePrefix }}" + # Add custom Tolerations for resources + tolerations: "{{ .Values.global.tolerations }}" + # -- Container runtime for Kubernetes Cluster. Requires fluentd configuration changes accordingly # Allowed values: docker, cri(for OKE 1.20 and above) runtime: cri @@ -77,6 +82,9 @@ kubernetesClusterName: # e.g. ocid1.loganalyticsentity.oc1.phx.amaaaaaabulluiqabqeq4delvhdlmd7aqcjrdla57n2szsxyz7pfdvnhwuua ociLAClusterEntityID: +# Add custom Tolerations for resources +tolerations: "{{ .Values.global.tolerations }}" + # -- Kubernetes Security Context privileged flag # Default: 'false'. This is not a required for OKE clusters. # In Kubernetes environments where SELinux mode is enforced, set this flag to 'true' to allow fluentd pods to access log files. diff --git a/charts/mgmt-agent/Chart.yaml b/charts/mgmt-agent/Chart.yaml index cf5ab74..c8d77f7 100644 --- a/charts/mgmt-agent/Chart.yaml +++ b/charts/mgmt-agent/Chart.yaml @@ -18,7 +18,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 3.0.4 +version: 3.0.5 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/mgmt-agent/templates/_helpers.tpl b/charts/mgmt-agent/templates/_helpers.tpl index 1bb7162..db3c681 100644 --- a/charts/mgmt-agent/templates/_helpers.tpl +++ b/charts/mgmt-agent/templates/_helpers.tpl @@ -41,3 +41,64 @@ {{- "UNDEFINED" -}} {{- end -}} {{- end -}} + +{{- define "mgmt-agent.tolerations" -}} + {{- if kindIs "slice" .Values.tolerations -}} + {{- include "common.tplvalues.render" ( dict "value" .Values.tolerations "context" .) -}} + {{- else -}} + {{- $tolerations := include "common.tplvalues.render" ( dict "value" .Values.tolerations "context" .) -}} + {{- if $tolerations -}} + {{- $noOuter := trimPrefix "[" (trimSuffix "]" $tolerations) -}} + {{- $contents := regexSplit "map\\[" $noOuter -1 | rest -}} + {{- range $content := $contents -}} + {{- $trimmedContent := trimSuffix "]" (trimSuffix " " $content) -}} + {{- $key := regexFind "key:([^ ]+)" $trimmedContent | trimPrefix "key:" -}} + {{- $effect := regexFind "effect:([^ ]+)" $trimmedContent | trimPrefix "effect:" -}} + {{- $operator := regexFind "operator:([^ ]+)" $trimmedContent | trimPrefix "operator:" -}} + {{- $value := regexFind "value:([^ ]+)" $trimmedContent | trimPrefix "value:" -}} + {{- $tolerationSeconds := regexFind "tolerationSeconds:([^ ]+)" $trimmedContent | trimPrefix "tolerationSeconds:" -}} + {{- $firstPrinted := false -}} + {{- if $key }} + {{- if not $firstPrinted }} +- key: {{ $key | quote }} + {{- $firstPrinted = true -}} + {{- else }} + key: {{ $key | quote }} + {{- end }} + {{- end }} + {{- if $effect }} + {{- if not $firstPrinted }} +- effect: {{ $effect | quote }} + {{- $firstPrinted = true -}} + {{- else }} + effect: {{ $effect | quote }} + {{- end }} + {{- end }} + {{- if $operator }} + {{- if not $firstPrinted }} +- operator: {{ $operator | quote }} + {{- $firstPrinted = true -}} + {{- else }} + operator: {{ $operator | quote }} + {{- end }} + {{- end }} + {{- if $value }} + {{- if not $firstPrinted }} +- value: {{ $value | quote }} + {{- $firstPrinted = true -}} + {{- else }} + value: {{ $value | quote }} + {{- end }} + {{- end }} + {{- if $tolerationSeconds }} + {{- if not $firstPrinted }} +- tolerationSeconds: {{ $tolerationSeconds }} + {{- $firstPrinted = true -}} + {{- else }} + tolerationSeconds: {{ $tolerationSeconds }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/mgmt-agent/templates/metric_server.yaml b/charts/mgmt-agent/templates/metric_server.yaml index e8c11fb..e7d3cc6 100644 --- a/charts/mgmt-agent/templates/metric_server.yaml +++ b/charts/mgmt-agent/templates/metric_server.yaml @@ -135,6 +135,9 @@ spec: labels: k8s-app: metrics-server spec: + {{- if include "mgmt-agent.tolerations" . }} + tolerations: {{- include "mgmt-agent.tolerations" . | trimAll "\n" | nindent 8 }} + {{- end }} containers: - args: - --cert-dir=/tmp diff --git a/charts/mgmt-agent/templates/mgmt-agent-daemonset.yaml b/charts/mgmt-agent/templates/mgmt-agent-daemonset.yaml index b0f6b79..e901126 100644 --- a/charts/mgmt-agent/templates/mgmt-agent-daemonset.yaml +++ b/charts/mgmt-agent/templates/mgmt-agent-daemonset.yaml @@ -22,6 +22,9 @@ spec: labels: app: {{ include "mgmt-agent.resourceNamePrefix" . }}-mgmt-agent spec: + {{- if include "mgmt-agent.tolerations" . }} + tolerations: {{- include "mgmt-agent.tolerations" . | trimAll "\n" | nindent 8 }} + {{- end }} securityContext: runAsUser: {{ default 0 .Values.deployment.security.runAsUser }} runAsGroup: {{ default 0 .Values.deployment.security.runAsGroup }} diff --git a/charts/mgmt-agent/templates/mgmt-agent-statefulset.yaml b/charts/mgmt-agent/templates/mgmt-agent-statefulset.yaml index 5cf8da1..d6d41d6 100644 --- a/charts/mgmt-agent/templates/mgmt-agent-statefulset.yaml +++ b/charts/mgmt-agent/templates/mgmt-agent-statefulset.yaml @@ -23,6 +23,9 @@ spec: labels: app: {{ include "mgmt-agent.resourceNamePrefix" . }}-mgmt-agent spec: + {{- if include "mgmt-agent.tolerations" . }} + tolerations: {{- include "mgmt-agent.tolerations" . | trimAll "\n" | nindent 8 }} + {{- end }} securityContext: runAsUser: {{ default 0 .Values.deployment.security.runAsUser }} runAsGroup: {{ default 0 .Values.deployment.security.runAsGroup }} diff --git a/charts/mgmt-agent/values.yaml b/charts/mgmt-agent/values.yaml index 0ac47f8..2a750a7 100644 --- a/charts/mgmt-agent/values.yaml +++ b/charts/mgmt-agent/values.yaml @@ -6,6 +6,8 @@ global: namespace: oci-onm # -- Prefix to be attached to resources created through this chart. Not all resources may have this prefix. resourceNamePrefix: oci-onm + # Add custom Tolerations for resources + tolerations: oci-onm-common: # -- By default, a cluster role, cluster role binding and serviceaccount will be created for the monitoring pods to be able to (readonly) access various objects within the cluster, to support collection of various telemetry data. You may set this to false and provide your own serviceaccount (in the parent chart(s)) which has the necessary cluster role(s) binded to it. Refer, README for the cluster role definition and other details. @@ -18,6 +20,8 @@ oci-onm-common: resourceNamePrefix: "{{ .Values.global.resourceNamePrefix }}" # -- Name of the Kubernetes ServiceAccount serviceAccount: "{{ .Values.global.resourceNamePrefix }}" + # Add custom Tolerations for resources + tolerations: "{{ .Values.global.tolerations }}" mgmtagent: # Provide either installKeyFileContent or installKey as an install key. If both provided then installKeyFileContent will take higher precedence. @@ -49,6 +53,9 @@ serviceAccount: "{{ .Values.global.resourceNamePrefix }}" # -- By default, metric server will be deployed and used by Management Agent to collect metrics. You can set this to false if you already have metric server installed on your cluster deployMetricServer: true +# Add custom Tolerations for resources +tolerations: "{{ .Values.global.tolerations }}" + # Kubernetes Cluster details to monitor kubernetesCluster: # -- OCI Compartment Id to push Kubernetes Monitoring metrics. If not specified default is same as Agent compartment diff --git a/charts/oci-onm/Chart.yaml b/charts/oci-onm/Chart.yaml index 1b81fc9..dc228fa 100644 --- a/charts/oci-onm/Chart.yaml +++ b/charts/oci-onm/Chart.yaml @@ -32,10 +32,10 @@ dependencies: repository: "file://../common" condition: oci-onm-common.enabled - name: oci-onm-logan - version: "3.5.3" + version: "3.5.4" repository: "file://../logan" condition: oci-onm-logan.enabled - name: oci-onm-mgmt-agent - version: "3.0.4" + version: "3.0.5" repository: "file://../mgmt-agent" condition: oci-onm-mgmt-agent.enabled diff --git a/charts/oci-onm/values.yaml b/charts/oci-onm/values.yaml index a1cbc8b..4a91b01 100644 --- a/charts/oci-onm/values.yaml +++ b/charts/oci-onm/values.yaml @@ -22,6 +22,8 @@ oci-onm-common: resourceNamePrefix: "{{ .Values.global.resourceNamePrefix }}" # -- Name of the Kubernetes ServiceAccount serviceAccount: "{{ .Values.global.resourceNamePrefix }}" + # Add custom Tolerations for resources + tolerations: "{{ .Values.global.tolerations }}" oci-onm-logan: oci-onm-common: @@ -42,12 +44,16 @@ oci-onm-logan: # Format: .oci. # Example: us-ashburn-1.oci.oraclecloud.com ociDomain: + # Add custom Tolerations for resources + tolerations: "{{ .Values.global.tolerations }}" oci-onm-mgmt-agent: oci-onm-common: enabled: false namespace: "{{ .Values.global.namespace }}" serviceAccount: "{{ .Values.global.resourceNamePrefix }}" + # Add custom Tolerations for resources + tolerations: "{{ .Values.global.tolerations }}" kubernetesCluster: name: "{{ .Values.global.kubernetesClusterName }}" mgmtagent: From 4258d0c47b5820ca52787731b5b844614772ba85 Mon Sep 17 00:00:00 2001 From: saksham Date: Mon, 17 Mar 2025 13:21:32 +0530 Subject: [PATCH 2/2] removing , copying logic from values.global --- charts/logan/templates/_helpers.tpl | 61 ------------------- charts/logan/templates/discovery-cronjob.yaml | 5 +- charts/logan/templates/fluentd-daemonset.yaml | 4 +- .../logan/templates/fluentd-deployment.yaml | 5 +- charts/logan/values.yaml | 7 +-- charts/mgmt-agent/templates/_helpers.tpl | 61 ------------------- .../mgmt-agent/templates/metric_server.yaml | 5 +- .../templates/mgmt-agent-daemonset.yaml | 5 +- .../templates/mgmt-agent-statefulset.yaml | 5 +- charts/mgmt-agent/values.yaml | 6 +- charts/oci-onm/values.yaml | 6 +- 11 files changed, 21 insertions(+), 149 deletions(-) diff --git a/charts/logan/templates/_helpers.tpl b/charts/logan/templates/_helpers.tpl index c58542d..8dc9a14 100644 --- a/charts/logan/templates/_helpers.tpl +++ b/charts/logan/templates/_helpers.tpl @@ -50,65 +50,4 @@ {{- else -}} {{- "UNDEFINED" -}} {{- end -}} -{{- end -}} - -{{- define "logan.tolerations" -}} - {{- if kindIs "slice" .Values.tolerations -}} - {{- include "common.tplvalues.render" ( dict "value" .Values.tolerations "context" .) -}} - {{- else -}} - {{- $tolerations := include "common.tplvalues.render" ( dict "value" .Values.tolerations "context" .) -}} - {{- if $tolerations -}} - {{- $noOuter := trimPrefix "[" (trimSuffix "]" $tolerations) -}} - {{- $contents := regexSplit "map\\[" $noOuter -1 | rest -}} - {{- range $content := $contents -}} - {{- $trimmedContent := trimSuffix "]" (trimSuffix " " $content) -}} - {{- $key := regexFind "key:([^ ]+)" $trimmedContent | trimPrefix "key:" -}} - {{- $effect := regexFind "effect:([^ ]+)" $trimmedContent | trimPrefix "effect:" -}} - {{- $operator := regexFind "operator:([^ ]+)" $trimmedContent | trimPrefix "operator:" -}} - {{- $value := regexFind "value:([^ ]+)" $trimmedContent | trimPrefix "value:" -}} - {{- $tolerationSeconds := regexFind "tolerationSeconds:([^ ]+)" $trimmedContent | trimPrefix "tolerationSeconds:" -}} - {{- $firstPrinted := false -}} - {{- if $key }} - {{- if not $firstPrinted }} -- key: {{ $key | quote }} - {{- $firstPrinted = true -}} - {{- else }} - key: {{ $key | quote }} - {{- end }} - {{- end }} - {{- if $effect }} - {{- if not $firstPrinted }} -- effect: {{ $effect | quote }} - {{- $firstPrinted = true -}} - {{- else }} - effect: {{ $effect | quote }} - {{- end }} - {{- end }} - {{- if $operator }} - {{- if not $firstPrinted }} -- operator: {{ $operator | quote }} - {{- $firstPrinted = true -}} - {{- else }} - operator: {{ $operator | quote }} - {{- end }} - {{- end }} - {{- if $value }} - {{- if not $firstPrinted }} -- value: {{ $value | quote }} - {{- $firstPrinted = true -}} - {{- else }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- if $tolerationSeconds }} - {{- if not $firstPrinted }} -- tolerationSeconds: {{ $tolerationSeconds }} - {{- $firstPrinted = true -}} - {{- else }} - tolerationSeconds: {{ $tolerationSeconds }} - {{- end }} - {{- end }} - {{- end }} - {{- end }} - {{- end -}} {{- end -}} \ No newline at end of file diff --git a/charts/logan/templates/discovery-cronjob.yaml b/charts/logan/templates/discovery-cronjob.yaml index 74e374d..f47084b 100644 --- a/charts/logan/templates/discovery-cronjob.yaml +++ b/charts/logan/templates/discovery-cronjob.yaml @@ -22,8 +22,9 @@ spec: spec: restartPolicy: {{ .Values.k8sDiscovery.objects.restartPolicy }} serviceAccountName: {{ $serviceAccount }} - {{- if include "logan.tolerations" . }} - tolerations: {{- include "logan.tolerations" . | trimAll "\n" | nindent 12 }} + {{- if .Values.tolerations }} + tolerations: + {{- toYaml .Values.tolerations | nindent 12 }} {{- end }} {{- if .Values.image.imagePullSecrets }} imagePullSecrets: diff --git a/charts/logan/templates/fluentd-daemonset.yaml b/charts/logan/templates/fluentd-daemonset.yaml index a046179..172c5d7 100644 --- a/charts/logan/templates/fluentd-daemonset.yaml +++ b/charts/logan/templates/fluentd-daemonset.yaml @@ -35,8 +35,8 @@ spec: effect: NoSchedule - key: node-role.kubernetes.io/control-plane effect: NoSchedule - {{- if include "logan.tolerations" . }} - {{- include "logan.tolerations" . | trimAll "\n" | nindent 6 }} + {{- if .Values.tolerations }} + {{- toYaml .Values.tolerations | nindent 6 }} {{- end }} {{- if $imagePullSecrets }} imagePullSecrets: diff --git a/charts/logan/templates/fluentd-deployment.yaml b/charts/logan/templates/fluentd-deployment.yaml index a8d4bf6..9c8b174 100644 --- a/charts/logan/templates/fluentd-deployment.yaml +++ b/charts/logan/templates/fluentd-deployment.yaml @@ -31,8 +31,9 @@ spec: version: v1 spec: serviceAccountName: {{ include "logan.serviceAccount" . }} - {{- if include "logan.tolerations" . }} - tolerations: {{- include "logan.tolerations" . | trimAll "\n" | nindent 8 }} + {{- if .Values.tolerations }} + tolerations: + {{- toYaml .Values.tolerations | nindent 8 }} {{- end }} {{- if $imagePullSecrets }} imagePullSecrets: diff --git a/charts/logan/values.yaml b/charts/logan/values.yaml index a92b5e2..d49f8dd 100644 --- a/charts/logan/values.yaml +++ b/charts/logan/values.yaml @@ -7,8 +7,6 @@ global: namespace: oci-onm # -- Resource names prefix used, where allowed. resourceNamePrefix: oci-onm - # Add custom Tolerations for resources - tolerations: oci-onm-common: # -- Automatically create, a readonly cluster role, cluster role binding and @@ -29,9 +27,6 @@ oci-onm-common: # -- Kubernetes ServiceAccount name serviceAccount: "{{ .Values.global.resourceNamePrefix }}" - # Add custom Tolerations for resources - tolerations: "{{ .Values.global.tolerations }}" - # -- Container runtime for Kubernetes Cluster. Requires fluentd configuration changes accordingly # Allowed values: docker, cri(for OKE 1.20 and above) runtime: cri @@ -83,7 +78,7 @@ kubernetesClusterName: ociLAClusterEntityID: # Add custom Tolerations for resources -tolerations: "{{ .Values.global.tolerations }}" +tolerations: # -- Kubernetes Security Context privileged flag # Default: 'false'. This is not a required for OKE clusters. diff --git a/charts/mgmt-agent/templates/_helpers.tpl b/charts/mgmt-agent/templates/_helpers.tpl index db3c681..a483b0c 100644 --- a/charts/mgmt-agent/templates/_helpers.tpl +++ b/charts/mgmt-agent/templates/_helpers.tpl @@ -40,65 +40,4 @@ {{- else -}} {{- "UNDEFINED" -}} {{- end -}} -{{- end -}} - -{{- define "mgmt-agent.tolerations" -}} - {{- if kindIs "slice" .Values.tolerations -}} - {{- include "common.tplvalues.render" ( dict "value" .Values.tolerations "context" .) -}} - {{- else -}} - {{- $tolerations := include "common.tplvalues.render" ( dict "value" .Values.tolerations "context" .) -}} - {{- if $tolerations -}} - {{- $noOuter := trimPrefix "[" (trimSuffix "]" $tolerations) -}} - {{- $contents := regexSplit "map\\[" $noOuter -1 | rest -}} - {{- range $content := $contents -}} - {{- $trimmedContent := trimSuffix "]" (trimSuffix " " $content) -}} - {{- $key := regexFind "key:([^ ]+)" $trimmedContent | trimPrefix "key:" -}} - {{- $effect := regexFind "effect:([^ ]+)" $trimmedContent | trimPrefix "effect:" -}} - {{- $operator := regexFind "operator:([^ ]+)" $trimmedContent | trimPrefix "operator:" -}} - {{- $value := regexFind "value:([^ ]+)" $trimmedContent | trimPrefix "value:" -}} - {{- $tolerationSeconds := regexFind "tolerationSeconds:([^ ]+)" $trimmedContent | trimPrefix "tolerationSeconds:" -}} - {{- $firstPrinted := false -}} - {{- if $key }} - {{- if not $firstPrinted }} -- key: {{ $key | quote }} - {{- $firstPrinted = true -}} - {{- else }} - key: {{ $key | quote }} - {{- end }} - {{- end }} - {{- if $effect }} - {{- if not $firstPrinted }} -- effect: {{ $effect | quote }} - {{- $firstPrinted = true -}} - {{- else }} - effect: {{ $effect | quote }} - {{- end }} - {{- end }} - {{- if $operator }} - {{- if not $firstPrinted }} -- operator: {{ $operator | quote }} - {{- $firstPrinted = true -}} - {{- else }} - operator: {{ $operator | quote }} - {{- end }} - {{- end }} - {{- if $value }} - {{- if not $firstPrinted }} -- value: {{ $value | quote }} - {{- $firstPrinted = true -}} - {{- else }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- if $tolerationSeconds }} - {{- if not $firstPrinted }} -- tolerationSeconds: {{ $tolerationSeconds }} - {{- $firstPrinted = true -}} - {{- else }} - tolerationSeconds: {{ $tolerationSeconds }} - {{- end }} - {{- end }} - {{- end }} - {{- end }} - {{- end -}} {{- end -}} \ No newline at end of file diff --git a/charts/mgmt-agent/templates/metric_server.yaml b/charts/mgmt-agent/templates/metric_server.yaml index e7d3cc6..bee0620 100644 --- a/charts/mgmt-agent/templates/metric_server.yaml +++ b/charts/mgmt-agent/templates/metric_server.yaml @@ -135,8 +135,9 @@ spec: labels: k8s-app: metrics-server spec: - {{- if include "mgmt-agent.tolerations" . }} - tolerations: {{- include "mgmt-agent.tolerations" . | trimAll "\n" | nindent 8 }} + {{- if .Values.tolerations }} + tolerations: + {{- toYaml .Values.tolerations | nindent 8 }} {{- end }} containers: - args: diff --git a/charts/mgmt-agent/templates/mgmt-agent-daemonset.yaml b/charts/mgmt-agent/templates/mgmt-agent-daemonset.yaml index e901126..83afbdf 100644 --- a/charts/mgmt-agent/templates/mgmt-agent-daemonset.yaml +++ b/charts/mgmt-agent/templates/mgmt-agent-daemonset.yaml @@ -22,8 +22,9 @@ spec: labels: app: {{ include "mgmt-agent.resourceNamePrefix" . }}-mgmt-agent spec: - {{- if include "mgmt-agent.tolerations" . }} - tolerations: {{- include "mgmt-agent.tolerations" . | trimAll "\n" | nindent 8 }} + {{- if .Values.tolerations }} + tolerations: + {{- toYaml .Values.tolerations | nindent 8 }} {{- end }} securityContext: runAsUser: {{ default 0 .Values.deployment.security.runAsUser }} diff --git a/charts/mgmt-agent/templates/mgmt-agent-statefulset.yaml b/charts/mgmt-agent/templates/mgmt-agent-statefulset.yaml index d6d41d6..20bcb90 100644 --- a/charts/mgmt-agent/templates/mgmt-agent-statefulset.yaml +++ b/charts/mgmt-agent/templates/mgmt-agent-statefulset.yaml @@ -23,8 +23,9 @@ spec: labels: app: {{ include "mgmt-agent.resourceNamePrefix" . }}-mgmt-agent spec: - {{- if include "mgmt-agent.tolerations" . }} - tolerations: {{- include "mgmt-agent.tolerations" . | trimAll "\n" | nindent 8 }} + {{- if .Values.tolerations }} + tolerations: + {{- toYaml .Values.tolerations | nindent 8 }} {{- end }} securityContext: runAsUser: {{ default 0 .Values.deployment.security.runAsUser }} diff --git a/charts/mgmt-agent/values.yaml b/charts/mgmt-agent/values.yaml index 2a750a7..7436db2 100644 --- a/charts/mgmt-agent/values.yaml +++ b/charts/mgmt-agent/values.yaml @@ -6,8 +6,6 @@ global: namespace: oci-onm # -- Prefix to be attached to resources created through this chart. Not all resources may have this prefix. resourceNamePrefix: oci-onm - # Add custom Tolerations for resources - tolerations: oci-onm-common: # -- By default, a cluster role, cluster role binding and serviceaccount will be created for the monitoring pods to be able to (readonly) access various objects within the cluster, to support collection of various telemetry data. You may set this to false and provide your own serviceaccount (in the parent chart(s)) which has the necessary cluster role(s) binded to it. Refer, README for the cluster role definition and other details. @@ -20,8 +18,6 @@ oci-onm-common: resourceNamePrefix: "{{ .Values.global.resourceNamePrefix }}" # -- Name of the Kubernetes ServiceAccount serviceAccount: "{{ .Values.global.resourceNamePrefix }}" - # Add custom Tolerations for resources - tolerations: "{{ .Values.global.tolerations }}" mgmtagent: # Provide either installKeyFileContent or installKey as an install key. If both provided then installKeyFileContent will take higher precedence. @@ -54,7 +50,7 @@ serviceAccount: "{{ .Values.global.resourceNamePrefix }}" deployMetricServer: true # Add custom Tolerations for resources -tolerations: "{{ .Values.global.tolerations }}" +tolerations: # Kubernetes Cluster details to monitor kubernetesCluster: diff --git a/charts/oci-onm/values.yaml b/charts/oci-onm/values.yaml index 4a91b01..6ee2a2d 100644 --- a/charts/oci-onm/values.yaml +++ b/charts/oci-onm/values.yaml @@ -22,8 +22,6 @@ oci-onm-common: resourceNamePrefix: "{{ .Values.global.resourceNamePrefix }}" # -- Name of the Kubernetes ServiceAccount serviceAccount: "{{ .Values.global.resourceNamePrefix }}" - # Add custom Tolerations for resources - tolerations: "{{ .Values.global.tolerations }}" oci-onm-logan: oci-onm-common: @@ -45,7 +43,7 @@ oci-onm-logan: # Example: us-ashburn-1.oci.oraclecloud.com ociDomain: # Add custom Tolerations for resources - tolerations: "{{ .Values.global.tolerations }}" + tolerations: oci-onm-mgmt-agent: oci-onm-common: @@ -53,7 +51,7 @@ oci-onm-mgmt-agent: namespace: "{{ .Values.global.namespace }}" serviceAccount: "{{ .Values.global.resourceNamePrefix }}" # Add custom Tolerations for resources - tolerations: "{{ .Values.global.tolerations }}" + tolerations: kubernetesCluster: name: "{{ .Values.global.kubernetesClusterName }}" mgmtagent: