diff --git a/scripts/common/yaml.sh b/scripts/common/yaml.sh index 6823afb3a4..3476d54b06 100644 --- a/scripts/common/yaml.sh +++ b/scripts/common/yaml.sh @@ -29,9 +29,15 @@ function insert_patches_strategic_merge() { local kustomization_file="$1" local patch_file="$2" + # we care about the current kubernetes version here, not the target version - this function can be called from pre-init addons + local kubeletVersion= + kubeletVersion="$(kubelet_version)" + semverParse "$kubeletVersion" + local kubeletMinor="$minor" + # Kubernetes 1.27 uses kustomize v5 which dropped support for old, legacy style patches # See: https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.27.md#changelog-since-v1270 - if [ "$KUBERNETES_TARGET_VERSION_MINOR" -ge "27" ]; then + if [ "$kubeletMinor" -ge "27" ]; then if [[ $kustomization_file =~ "prometheus" ]] || [[ $kustomization_file =~ "rook" ]]; then # TODO: multi-doc patches is not currently supported in kustomize v5 # continue using the deprecated 'patchesStrategicMerge' field until this is fixed