Skip to content

Commit e613539

Browse files
authored
feat: windows cse ensure oras and reserve some exit code for network isolated cluster (#7995)
1 parent 5e632f6 commit e613539

File tree

24 files changed

+697
-71
lines changed

24 files changed

+697
-71
lines changed

parts/windows/kuberneteswindowssetup.ps1

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,13 @@ $global:WindowsCiliumNetworkingPath = Join-Path -Path $global:cacheDir -ChildPat
221221
$global:WindowsCiliumInstallPath = Join-Path -Path $global:WindowsCiliumNetworkingPath -ChildPath 'install'
222222

223223
# Network isolated cluster
224-
$global:BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER="{{GetBootstrapProfileContainerRegistryServer}}"
225-
$global:MCR_REPOSITORY_BASE="{{GetMCRRepositoryBase}}"
224+
$global:BootstrapProfileContainerRegistryServer="{{GetBootstrapProfileContainerRegistryServer}}"
225+
$global:MCRRepositoryBase="{{GetMCRRepositoryBase}}"
226+
227+
$global:OrasCacheDir="c:\aks-tools\oras\" # refer to components.json
228+
$global:OrasPath="c:\aks-tools\oras\oras.exe"
229+
$global:OrasOutput="c:\aks-tools\oras\oras_verbose.out"
230+
$global:OrasRegistryConfigFile="c:\aks-tools\oras\config.yaml" # oras registry auth config file, not used, but have to define to avoid error "Error: failed to get user home directory: $HOME is not defined"
226231

227232
# Extract cse helper script from ZIP
228233
[io.file]::WriteAllBytes("scripts.zip", [System.Convert]::FromBase64String($zippedFiles))
@@ -291,6 +296,12 @@ if (Test-Path -Path 'c:\AzureData\windows\windowsciliumnetworkingfunc.ps1') {
291296
Write-Log "Windows Cilium Networking function script not found, skipping dot-source"
292297
}
293298

299+
if (Test-Path -Path 'c:\AzureData\windows\networkisolatedclusterfunc.ps1') {
300+
. c:\AzureData\windows\networkisolatedclusterfunc.ps1
301+
} else {
302+
Write-Log "Network Isolated Cluster function script not found, skipping dot-source"
303+
}
304+
294305
# ====== BASE PREP: BASE IMAGE PREPARATION ======
295306
# All operations that prepare the base VHD image
296307
function BasePrep {
@@ -333,6 +344,18 @@ function BasePrep {
333344

334345
Write-KubeClusterConfig -MasterIP $MasterIP -KubeDnsServiceIp $KubeDnsServiceIp
335346

347+
# oras initialization, including install and login, must be in front of Install-CredentialProvider, Get-KubePackage and Install-Containerd-Based-On-Kubernetes-Version
348+
if ((Test-Path variable:global:BootstrapProfileContainerRegistryServer) -and
349+
-not [string]::IsNullOrWhiteSpace($global:BootstrapProfileContainerRegistryServer)) {
350+
# variable exists and is not empty/whitespace
351+
if (Get-Command -Name Initialize-Oras -ErrorAction SilentlyContinue) {
352+
Logs-To-Event -TaskName "AKS.WindowsCSE.InitializeOras" -TaskMessage "Ensure oras is initialized for network isolated cluster"
353+
Initialize-Oras
354+
} else {
355+
Write-Log "Initialize-Oras is not a recognized function, will skip oras initialization for network isolated cluster"
356+
}
357+
}
358+
336359
# to ensure we don't introduce any incompatibility between base CSE + CSE package versions
337360
if (Get-Command -Name Install-SecureTLSBootstrapClient -ErrorAction SilentlyContinue) {
338361
Install-SecureTLSBootstrapClient -KubeDir $global:KubeDir -CustomSecureTLSBootstrapClientDownloadUrl $global:CustomSecureTLSBootstrappingClientDownloadURL

parts/windows/windowscsehelper.ps1

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,16 @@ $global:WINDOWS_CSE_ERROR_WINDOWS_CILIUM_NETWORKING_INSTALL_FAILED=72
7979
$global:WINDOWS_CSE_ERROR_EXTRACT_ZIP=73
8080
$global:WINDOWS_CSE_ERROR_LOAD_METADATA=74
8181
$global:WINDOWS_CSE_ERROR_PARSE_METADATA=75
82+
$global:WINDOWS_CSE_ERROR_ORAS_NOT_FOUND=76 # exit code for not finding oras in the expected path, which is a prerequisite for pulling packages from registry for network isolated cluster
83+
$global:WINDOWS_CSE_ERROR_ORAS_IMDS_TIMEOUT=77 # exit code for timeout waiting for IMDS response
84+
$global:WINDOWS_CSE_ERROR_ORAS_PULL_NETWORK_TIMEOUT=78 # exit code for error pulling oras when login
85+
$global:WINDOWS_CSE_ERROR_ORAS_PULL_UNAUTHORIZED=79 # exit code for error pulling artifact with oras from registry with authorization issue
86+
$global:WINDOWS_CSE_ERROR_ORAS_PULL_WINDOWSZIP_FAIL=80 # exit code for error pulling kubelet kubectl artifact with oras from registry
87+
$global:WINDOWS_CSE_ERROR_ORAS_PULL_CREDENTIAL_PROVIDER=81 # exit code for error pulling credential provider artifact with oras from registry
88+
$global:WINDOWS_CSE_ERROR_ORAS_PULL_POD_INFRA_CONTAINER=82 # exit code for error pulling pause image with oras from registry
8289
# WINDOWS_CSE_ERROR_MAX_CODE is only used in unit tests to verify whether new error code name is added in $global:ErrorCodeNames
8390
# Please use the current value of WINDOWS_CSE_ERROR_MAX_CODE as the value of the new error code and increment it by 1
84-
$global:WINDOWS_CSE_ERROR_MAX_CODE=76
91+
$global:WINDOWS_CSE_ERROR_MAX_CODE=83
8592

8693
# Please add new error code for downloading new packages in RP code too
8794
$global:ErrorCodeNames = @(
@@ -160,7 +167,14 @@ $global:ErrorCodeNames = @(
160167
"WINDOWS_CSE_ERROR_WINDOWS_CILIUM_NETWORKING_INSTALL_FAILED",
161168
"WINDOWS_CSE_ERROR_EXTRACT_ZIP",
162169
"WINDOWS_CSE_ERROR_LOAD_METADATA",
163-
"WINDOWS_CSE_ERROR_PARSE_METADATA"
170+
"WINDOWS_CSE_ERROR_PARSE_METADATA",
171+
"WINDOWS_CSE_ERROR_ORAS_NOT_FOUND",
172+
"WINDOWS_CSE_ERROR_ORAS_IMDS_TIMEOUT",
173+
"WINDOWS_CSE_ERROR_ORAS_PULL_NETWORK_TIMEOUT",
174+
"WINDOWS_CSE_ERROR_ORAS_PULL_UNAUTHORIZED",
175+
"WINDOWS_CSE_ERROR_ORAS_PULL_WINDOWSZIP_FAIL",
176+
"WINDOWS_CSE_ERROR_ORAS_PULL_CREDENTIAL_PROVIDER",
177+
"WINDOWS_CSE_ERROR_ORAS_PULL_POD_INFRA_CONTAINER"
164178
)
165179

166180
# The package domain to be used
@@ -635,3 +649,4 @@ function Resolve-Error ($ErrorRecord=$Error[0])
635649
$Exception |Format-List * -Force
636650
}
637651
}
652+

pkg/agent/testdata/AKSWindows2019+CustomCloud+ootcredentialprovider/CustomData

Lines changed: 26 additions & 3 deletions
Large diffs are not rendered by default.

pkg/agent/testdata/AKSWindows2019+CustomCloud/CustomData

Lines changed: 26 additions & 3 deletions
Large diffs are not rendered by default.

pkg/agent/testdata/AKSWindows2019+CustomVnet/CustomData

Lines changed: 26 additions & 3 deletions
Large diffs are not rendered by default.

pkg/agent/testdata/AKSWindows2019+EnablePrivateClusterHostsConfigAgent/CustomData

Lines changed: 26 additions & 3 deletions
Large diffs are not rendered by default.

pkg/agent/testdata/AKSWindows2019+K8S116/CustomData

Lines changed: 26 additions & 3 deletions
Large diffs are not rendered by default.

pkg/agent/testdata/AKSWindows2019+K8S117/CustomData

Lines changed: 26 additions & 3 deletions
Large diffs are not rendered by default.

pkg/agent/testdata/AKSWindows2019+K8S118/CustomData

Lines changed: 26 additions & 3 deletions
Large diffs are not rendered by default.

pkg/agent/testdata/AKSWindows2019+K8S119+CSI/CustomData

Lines changed: 26 additions & 3 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)