mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Add cni plugin auto Arch and OS selection
This commit is contained in:
		@@ -53,11 +53,11 @@ LIMITED_SWAP=${LIMITED_SWAP:-""}
 | 
				
			|||||||
# required for cni installation
 | 
					# required for cni installation
 | 
				
			||||||
CNI_CONFIG_DIR=${CNI_CONFIG_DIR:-/etc/cni/net.d}
 | 
					CNI_CONFIG_DIR=${CNI_CONFIG_DIR:-/etc/cni/net.d}
 | 
				
			||||||
CNI_PLUGINS_VERSION=${CNI_PLUGINS_VERSION:-"v1.3.0"}
 | 
					CNI_PLUGINS_VERSION=${CNI_PLUGINS_VERSION:-"v1.3.0"}
 | 
				
			||||||
CNI_TARGETARCH=${CNI_TARGETARCH:-amd64}
 | 
					# The arch of the CNI binary, if not set, will be fetched based on the value of `uname -m`
 | 
				
			||||||
CNI_PLUGINS_TARBALL="${CNI_PLUGINS_VERSION}/cni-plugins-linux-${CNI_TARGETARCH}-${CNI_PLUGINS_VERSION}.tgz"
 | 
					CNI_TARGETARCH=${CNI_TARGETARCH:-""}
 | 
				
			||||||
CNI_PLUGINS_URL="https://github.com/containernetworking/plugins/releases/download/${CNI_PLUGINS_TARBALL}"
 | 
					CNI_PLUGINS_URL="https://github.com/containernetworking/plugins/releases/download"
 | 
				
			||||||
CNI_PLUGINS_AMD64_SHA256SUM=${CNI_PLUGINS_AMD64_SHA256SUM:-"754a71ed60a4bd08726c3af705a7d55ee3df03122b12e389fdba4bea35d7dd7e"}
 | 
					CNI_PLUGINS_AMD64_SHA256SUM=${CNI_PLUGINS_AMD64_SHA256SUM:-"754a71ed60a4bd08726c3af705a7d55ee3df03122b12e389fdba4bea35d7dd7e"}
 | 
				
			||||||
CNI_PLUGINS_ARM64_SHA256SUM=${CNI_PLUGINS_ARM64_SHA256SUM:-"86c4c866a01a8073ad14f6feec74de1fd63669786850c7be47521433f9570902"}
 | 
					CNI_PLUGINS_ARM64_SHA256SUM=${CNI_PLUGINS_ARM64_SHA256SUM:-"de7a666fd6ad83a228086bd55756db62ef335a193d1b143d910b69f079e30598"}
 | 
				
			||||||
CNI_PLUGINS_PPC64LE_SHA256SUM=${CNI_PLUGINS_PPC64LE_SHA256SUM:-"8ceff026f4eccf33c261b4153af6911e10784ac169d08c1d86cf6887b9f4e99b"}
 | 
					CNI_PLUGINS_PPC64LE_SHA256SUM=${CNI_PLUGINS_PPC64LE_SHA256SUM:-"8ceff026f4eccf33c261b4153af6911e10784ac169d08c1d86cf6887b9f4e99b"}
 | 
				
			||||||
CNI_PLUGINS_S390X_SHA256SUM=${CNI_PLUGINS_S390X_SHA256SUM:-"2f1f65ac33e961bcdc633e14c376656455824e22cc45d3ca7e31eb2750a7ebc4"}
 | 
					CNI_PLUGINS_S390X_SHA256SUM=${CNI_PLUGINS_S390X_SHA256SUM:-"2f1f65ac33e961bcdc633e14c376656455824e22cc45d3ca7e31eb2750a7ebc4"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -263,20 +263,8 @@ function test_apiserver_off {
 | 
				
			|||||||
    fi
 | 
					    fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function detect_binary {
 | 
					function detect_arch {
 | 
				
			||||||
    # Detect the OS name/arch so that we can find our binary
 | 
					    local host_arch
 | 
				
			||||||
    case "$(uname -s)" in
 | 
					 | 
				
			||||||
      Darwin)
 | 
					 | 
				
			||||||
        host_os=darwin
 | 
					 | 
				
			||||||
        ;;
 | 
					 | 
				
			||||||
      Linux)
 | 
					 | 
				
			||||||
        host_os=linux
 | 
					 | 
				
			||||||
        ;;
 | 
					 | 
				
			||||||
      *)
 | 
					 | 
				
			||||||
        echo "Unsupported host OS.  Must be Linux or Mac OS X." >&2
 | 
					 | 
				
			||||||
        exit 1
 | 
					 | 
				
			||||||
        ;;
 | 
					 | 
				
			||||||
    esac
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case "$(uname -m)" in
 | 
					    case "$(uname -m)" in
 | 
				
			||||||
      x86_64*)
 | 
					      x86_64*)
 | 
				
			||||||
@@ -312,6 +300,38 @@ function detect_binary {
 | 
				
			|||||||
        ;;
 | 
					        ;;
 | 
				
			||||||
    esac
 | 
					    esac
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if [[ -z "${host_arch}" ]]; then
 | 
				
			||||||
 | 
					    return
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					  echo -n "${host_arch}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function detect_os {
 | 
				
			||||||
 | 
					    local host_os
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    case "$(uname -s)" in
 | 
				
			||||||
 | 
					      Darwin)
 | 
				
			||||||
 | 
					        host_os=darwin
 | 
				
			||||||
 | 
					        ;;
 | 
				
			||||||
 | 
					      Linux)
 | 
				
			||||||
 | 
					        host_os=linux
 | 
				
			||||||
 | 
					        ;;
 | 
				
			||||||
 | 
					      *)
 | 
				
			||||||
 | 
					        echo "Unsupported host OS.  Must be Linux or Mac OS X." >&2
 | 
				
			||||||
 | 
					        exit 1
 | 
				
			||||||
 | 
					        ;;
 | 
				
			||||||
 | 
					    esac
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if [[ -z "${host_os}" ]]; then
 | 
				
			||||||
 | 
					    return
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					  echo -n "${host_os}"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function detect_binary {
 | 
				
			||||||
 | 
					    host_arch=$(detect_arch)
 | 
				
			||||||
 | 
					    host_os=$(detect_os)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    GO_OUT="${KUBE_ROOT}/_output/local/bin/${host_os}/${host_arch}"
 | 
					    GO_OUT="${KUBE_ROOT}/_output/local/bin/${host_os}/${host_arch}"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1146,15 +1166,24 @@ function tolerate_cgroups_v2 {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function install_cni {
 | 
					function install_cni {
 | 
				
			||||||
  cni_plugin_sha=CNI_PLUGINS_${CNI_TARGETARCH^^}_SHA256SUM
 | 
					  if [[ -n "${CNI_TARGETARCH}" ]]; then
 | 
				
			||||||
 | 
					    host_arch="${CNI_TARGETARCH}"
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    host_arch=$(detect_arch)
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  cni_plugin_sha=CNI_PLUGINS_${host_arch^^}_SHA256SUM
 | 
				
			||||||
 | 
					  cni_plugin_tarball="${CNI_PLUGINS_VERSION}/cni-plugins-linux-${host_arch}-${CNI_PLUGINS_VERSION}.tgz"
 | 
				
			||||||
 | 
					  cni_plugins_url="${CNI_PLUGINS_URL}/${cni_plugin_tarball}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  echo "Installing CNI plugin binaries ..." \
 | 
					  echo "Installing CNI plugin binaries ..." \
 | 
				
			||||||
    && curl -sSL --retry 5 --output "${TMP_DIR}"/cni."${CNI_TARGETARCH}".tgz "${CNI_PLUGINS_URL}" \
 | 
					    && curl -sSL --retry 5 --output "${TMP_DIR}"/cni."${host_arch}".tgz "${cni_plugins_url}" \
 | 
				
			||||||
    && echo "${!cni_plugin_sha} ${TMP_DIR}/cni.${CNI_TARGETARCH}.tgz" | tee "${TMP_DIR}"/cni.sha256 \
 | 
					    && echo "${!cni_plugin_sha} ${TMP_DIR}/cni.${host_arch}.tgz" | tee "${TMP_DIR}"/cni.sha256 \
 | 
				
			||||||
    && sha256sum --ignore-missing -c "${TMP_DIR}"/cni.sha256 \
 | 
					    && sha256sum --ignore-missing -c "${TMP_DIR}"/cni.sha256 \
 | 
				
			||||||
    && rm -f "${TMP_DIR}"/cni.sha256 \
 | 
					    && rm -f "${TMP_DIR}"/cni.sha256 \
 | 
				
			||||||
    && sudo mkdir -p /opt/cni/bin \
 | 
					    && sudo mkdir -p /opt/cni/bin \
 | 
				
			||||||
    && sudo tar -C /opt/cni/bin -xzvf "${TMP_DIR}"/cni."${CNI_TARGETARCH}".tgz \
 | 
					    && sudo tar -C /opt/cni/bin -xzvf "${TMP_DIR}"/cni."${host_arch}".tgz \
 | 
				
			||||||
    && rm -rf "${TMP_DIR}"/cni."${CNI_TARGETARCH}".tgz \
 | 
					    && rm -rf "${TMP_DIR}"/cni."${host_arch}".tgz \
 | 
				
			||||||
    && sudo find /opt/cni/bin -type f -not \( \
 | 
					    && sudo find /opt/cni/bin -type f -not \( \
 | 
				
			||||||
         -iname host-local \
 | 
					         -iname host-local \
 | 
				
			||||||
         -o -iname bridge \
 | 
					         -o -iname bridge \
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user