Skip to content

Commit

Permalink
[NI] fix scenario that kube binary version is different from k8s version
Browse files Browse the repository at this point in the history
  • Loading branch information
fseldow committed Dec 5, 2024
1 parent 04d10b7 commit 81c36e1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion e2e/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func baseTemplateLinux(location string) *datamodel.NodeBootstrappingConfiguratio
UserAssignedClientID: "",
CustomHyperkubeImage: "",
CustomKubeProxyImage: "mcr.microsoft.com/oss/kubernetes/kube-proxy:v1.26.0.1",
CustomKubeBinaryURL: "https://acs-mirror.azureedge.net/kubernetes/v1.26.0/binaries/kubernetes-node-linux-amd64.tar.gz",
CustomKubeBinaryURL: "https://acs-mirror.azureedge.net/kubernetes/v1.29.6/binaries/kubernetes-node-linux-amd64.tar.gz",
MobyVersion: "",
ContainerdVersion: "",
WindowsNodeBinariesURL: "",
Expand Down
2 changes: 0 additions & 2 deletions e2e/scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func Test_AzureLinuxV2_ARM64AirGap(t *testing.T) {
Cluster: ClusterKubenetAirgap,
VHD: config.VHDAzureLinuxV2Gen2Arm64,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.OrchestratorProfile.KubernetesConfig.CustomKubeBinaryURL = "https://acs-mirror.azureedge.net/kubernetes/v1.24.9/binaries/kubernetes-node-linux-arm64.tar.gz"
nbc.AgentPoolProfile.VMSize = "Standard_D2pds_V5"
nbc.IsARM64 = true

Expand Down Expand Up @@ -308,7 +307,6 @@ func Test_MarinerV2_ARM64AirGap(t *testing.T) {
Cluster: ClusterKubenetAirgap,
VHD: config.VHDCBLMarinerV2Gen2Arm64,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.OrchestratorProfile.KubernetesConfig.CustomKubeBinaryURL = "https://acs-mirror.azureedge.net/kubernetes/v1.24.9/binaries/kubernetes-node-linux-arm64.tar.gz"
nbc.AgentPoolProfile.VMSize = "Standard_D2pds_V5"
nbc.IsARM64 = true

Expand Down
21 changes: 20 additions & 1 deletion parts/linux/cloud-init/artifacts/cse_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,26 @@ installKubeletKubectlAndKubeProxy() {
if [[ ! -z ${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER} ]]; then
# network isolated cluster
echo "Detect Bootstrap profile artifact is Cache, will use oras to pull artifact binary"
registry_url="${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}/${K8S_REGISTRY_REPO}/kubernetes-node:v${KUBERNETES_VERSION}-linux-${CPU_ARCH}"
binary_version="v${KUBERNETES_VERSION}" # by default use Kubernetes versions
# however, the kubelet and kubectl binary version may different with kubernetes version due to hotfix or beta
# so that we still need to extract the binary version from kube_binary_url
url_regax='https://acs-mirror.azureedge.net/kubernetes/v[0-9]+\.[0-9]+\..+/binaries/.+'
if [[ -n ${KUBE_BINARY_URL} ]]; then
if [[ ${KUBE_BINARY_URL} =~ $registry_regex ]]; then
version_with_prefix="${KUBE_BINARY_URL#*kubernetes/}"
# Extract the version part
binary_version="${version_with_prefix%%/*}"
echo "Extracted version: $binary_version from KUBE_BINARY_URL: ${KUBE_BINARY_URL}"
fi
fi
registry_url="${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}/${K8S_REGISTRY_REPO}/kubernetes-node:${binary_version}-linux-${CPU_ARCH}"

# if rp already passes registry url, then directly use the registry url that rp passes
# this path should have not catch for now, but keep it for future
if [[ -n "${KUBE_BINARY_URL}" ]] && isRegistryUrl "${KUBE_BINARY_URL}"; then
echo "KUBE_BINARY_URL is a registry url, will use it to pull the kube binary"
registry_url="${KUBE_BINARY_URL}"
fi
K8S_DOWNLOADS_TEMP_DIR_FROM_REGISTRY="/tmp/kubernetes/downloads" # /opt folder will return permission error
logs_to_events "AKS.CSE.installKubeletKubectlAndKubeProxy.extractKubeBinaries" extractKubeBinaries ${KUBERNETES_VERSION} $registry_url false ${K8S_DOWNLOADS_TEMP_DIR_FROM_REGISTRY}
# no egress traffic, default install will fail
Expand Down

0 comments on commit 81c36e1

Please sign in to comment.