diff --git a/addons/rook/template/base/install.sh b/addons/rook/template/base/install.sh index b77f441b94..2b13a7a020 100644 --- a/addons/rook/template/base/install.sh +++ b/addons/rook/template/base/install.sh @@ -156,6 +156,20 @@ function rook_operator_crds_deploy() { # replace the CRDs if they already exist otherwise create them # replace or create rather than apply to avoid the error "metadata.annotations: Too long" if ! kubectl replace -f "$dst/crds.yaml" 2>/dev/null ; then + + if kubectl get ns rook-ceph >/dev/null 2>&1 ; then + # Rook 1.12 introduced a new CRD "cephcosidrivers.ceph.rook.io" which will cause + # `kubectl create` to fail on upgrades. The following logic will extract the new CRD yaml and create it. + semverParse "$ROOK_VERSION" + local rook_major_version="$major" + local rook_minor_version="$minor" + if [ "$rook_major_version" = "1" ] && [ "$rook_minor_version" -ge "12" ]; then + get_yaml_from_multidoc_yaml "$dst/crds.yaml" "cephcosidrivers.ceph.rook.io" | kubectl create -f - + fi + + return + fi + kubectl create -f "$dst/crds.yaml" fi } diff --git a/hack/testdata/manifest/clean b/hack/testdata/manifest/clean index 686e348e46..77454e8344 100644 --- a/hack/testdata/manifest/clean +++ b/hack/testdata/manifest/clean @@ -11,7 +11,7 @@ KURL_BIN_UTILS_FILE= # STEP_VERSIONS array is generated by the server and injected at runtime based on supported k8s versions STEP_VERSIONS=(0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 1.16.4 1.17.13 1.18.20 1.19.16 1.20.15 1.21.14 1.22.17 1.23.17 1.24.16 1.25.12 1.26.7 1.27.4) # ROOK_STEP_VERSIONS array is generated by the server and injected at runtime based on supported rook versions -ROOK_STEP_VERSIONS=(1.0.4-14.2.21 0.0.0 0.0.0 0.0.0 1.4.9 1.5.12 1.6.11 1.7.11 1.8.10 1.9.12 1.10.11 1.11.8) +ROOK_STEP_VERSIONS=(1.0.4-14.2.21 0.0.0 0.0.0 0.0.0 1.4.9 1.5.12 1.6.11 1.7.11 1.8.10 1.9.12 1.10.11 1.11.8 1.12.0) # CONTAINERD_STEP_VERSIONS array is generated by the server and injected at runtime based on supported containerd versions CONTAINERD_STEP_VERSIONS=(1.2.13 1.3.9 1.4.13 1.5.11 1.6.21) INSTALLER_YAML= diff --git a/scripts/Manifest b/scripts/Manifest index 686e348e46..77454e8344 100644 --- a/scripts/Manifest +++ b/scripts/Manifest @@ -11,7 +11,7 @@ KURL_BIN_UTILS_FILE= # STEP_VERSIONS array is generated by the server and injected at runtime based on supported k8s versions STEP_VERSIONS=(0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 1.16.4 1.17.13 1.18.20 1.19.16 1.20.15 1.21.14 1.22.17 1.23.17 1.24.16 1.25.12 1.26.7 1.27.4) # ROOK_STEP_VERSIONS array is generated by the server and injected at runtime based on supported rook versions -ROOK_STEP_VERSIONS=(1.0.4-14.2.21 0.0.0 0.0.0 0.0.0 1.4.9 1.5.12 1.6.11 1.7.11 1.8.10 1.9.12 1.10.11 1.11.8) +ROOK_STEP_VERSIONS=(1.0.4-14.2.21 0.0.0 0.0.0 0.0.0 1.4.9 1.5.12 1.6.11 1.7.11 1.8.10 1.9.12 1.10.11 1.11.8 1.12.0) # CONTAINERD_STEP_VERSIONS array is generated by the server and injected at runtime based on supported containerd versions CONTAINERD_STEP_VERSIONS=(1.2.13 1.3.9 1.4.13 1.5.11 1.6.21) INSTALLER_YAML= diff --git a/scripts/common/yaml.sh b/scripts/common/yaml.sh index fc7199ab1d..ad4ceb0b4c 100644 --- a/scripts/common/yaml.sh +++ b/scripts/common/yaml.sh @@ -242,3 +242,21 @@ function yaml_escape_string_quotes() { function yaml_newline_to_literal() { sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g' } + +# get_yaml_from_multidoc_yaml reads a single file multi-doc yaml and finds a particular embedded yaml doc +# based on the `name:` field and outputs the doc to stdout. +function get_yaml_from_multidoc_yaml() { + local multidoc_yaml="$1" + local resource_name="$2" + + # use awk to split the multidoc file using `---`separator + awk -v RS='---\n' -v ORS='---\n' -v RESOURCE_NAME="$resource_name" ' + $0 ~ ("name: " RESOURCE_NAME) { + found = 1 + print $0 + } + END { + exit !found + } + ' "$multidoc_yaml" +}