From 87c18d402bfd508b6ad1ebf51053b0fd0506c56d Mon Sep 17 00:00:00 2001 From: Jared Tan Date: Mon, 21 Aug 2023 21:42:08 +0800 Subject: [PATCH] fix otel col compatible for kubernetes before 1.21 --- charts/opentelemetry-collector/templates/_helpers.tpl | 6 ++++-- charts/opentelemetry-collector/templates/deployment.yaml | 2 +- charts/opentelemetry-collector/templates/service.yaml | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/charts/opentelemetry-collector/templates/_helpers.tpl b/charts/opentelemetry-collector/templates/_helpers.tpl index 7e9fe3c64..dba876993 100644 --- a/charts/opentelemetry-collector/templates/_helpers.tpl +++ b/charts/opentelemetry-collector/templates/_helpers.tpl @@ -151,11 +151,13 @@ Compute Service creation on mode Compute InternalTrafficPolicy on Service creation */}} {{- define "opentelemetry-collector.serviceInternalTrafficPolicy" }} +{{- if (semverCompare ">= 1.21-0" .Capabilities.KubeVersion.Version) -}} {{- if and (eq .Values.mode "daemonset") (eq .Values.service.enabled true) }} - {{- print (.Values.service.internalTrafficPolicy | default "Local") -}} + {{- printf "internalTrafficPolicy: %s" (.Values.service.internalTrafficPolicy | default "Local") }} {{- else }} - {{- print (.Values.service.internalTrafficPolicy | default "Cluster") -}} + {{- printf "internalTrafficPolicy: %s" (.Values.service.internalTrafficPolicy | default "Cluster") }} {{- end }} {{- end -}} +{{- end -}} diff --git a/charts/opentelemetry-collector/templates/deployment.yaml b/charts/opentelemetry-collector/templates/deployment.yaml index fe0ad1955..c66ce9c2c 100644 --- a/charts/opentelemetry-collector/templates/deployment.yaml +++ b/charts/opentelemetry-collector/templates/deployment.yaml @@ -42,7 +42,7 @@ spec: dnsPolicy: {{ . }} {{- end }} {{- with .Values.dnsConfig }} - dnsConfig: + dnsConfig: {{- toYaml . | nindent 8 }} {{- end }} {{- $podValues := deepCopy .Values }} diff --git a/charts/opentelemetry-collector/templates/service.yaml b/charts/opentelemetry-collector/templates/service.yaml index 73fe9113a..62f696f76 100644 --- a/charts/opentelemetry-collector/templates/service.yaml +++ b/charts/opentelemetry-collector/templates/service.yaml @@ -34,7 +34,7 @@ spec: selector: {{- include "opentelemetry-collector.selectorLabels" . | nindent 4 }} {{- include "opentelemetry-collector.component" . | nindent 4 }} - internalTrafficPolicy: {{ include "opentelemetry-collector.serviceInternalTrafficPolicy" . }} + {{ include "opentelemetry-collector.serviceInternalTrafficPolicy" . | nindent 2 }} {{- if and (eq .Values.service.type "LoadBalancer") (.Values.service.externalTrafficPolicy) }} externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }} {{- end }}