diff --git a/cluster/gce/windows/common.psm1 b/cluster/gce/windows/common.psm1 index 8b5b4a14ec7..0fd691ab225 100644 --- a/cluster/gce/windows/common.psm1 +++ b/cluster/gce/windows/common.psm1 @@ -123,9 +123,10 @@ function Validate-SHA1 { } # Attempts to download the file from URLs, trying each URL until it succeeds. -# It will loop through the URLs list forever until it has a success. -# If successful, it will write the file to OutFile. You can optionally provide a SHA1 Hash -# argument, in which case it will attempt to validate the downloaded file against the hash. +# It will loop through the URLs list forever until it has a success. If +# successful, it will write the file to OutFile. You can optionally provide a +# SHA1 Hash argument, in which case it will attempt to validate the downloaded +# file against the hash. function MustDownload-File { param ( [parameter(Mandatory=$false)] [string]$Hash, diff --git a/cluster/gce/windows/k8s-node-setup.psm1 b/cluster/gce/windows/k8s-node-setup.psm1 index b866f71cfc9..bb555e3a1e7 100644 --- a/cluster/gce/windows/k8s-node-setup.psm1 +++ b/cluster/gce/windows/k8s-node-setup.psm1 @@ -811,14 +811,32 @@ Import-Module -Name $modulePath'.replace('K8S_DIR', ${env:K8S_DIR}) # CLUSTER_IP_RANGE # SERVICE_CLUSTER_IP_RANGE function Configure-CniNetworking { + $CNI_RELEASE_VERSION = 'v0.8.0' if ((ShouldWrite-File ${env:CNI_DIR}\win-bridge.exe) -or (ShouldWrite-File ${env:CNI_DIR}\host-local.exe)) { - MustDownload-File -OutFile ${env:CNI_DIR}\windows-cni-plugins.zip ` - -URLs "https://github.com/yujuhong/gce-k8s-windows-testing/raw/master/windows-cni-plugins.zip" - rm ${env:CNI_DIR}\*.exe - Expand-Archive ${env:CNI_DIR}\windows-cni-plugins.zip ${env:CNI_DIR} - mv ${env:CNI_DIR}\bin\*.exe ${env:CNI_DIR}\ - rmdir ${env:CNI_DIR}\bin + $tmp_dir = 'C:\cni_tmp' + New-Item $tmp_dir -ItemType 'directory' -Force | Out-Null + + $release_url = ('https://github.com/containernetworking/plugins/releases/' + + 'download/' + $CNI_RELEASE_VERSION + '/') + $sha_url = ($release_url + + "cni-plugins-windows-amd64-$CNI_RELEASE_VERSION.tgz.sha1") + $tgz_url = ($release_url + + "cni-plugins-windows-amd64-$CNI_RELEASE_VERSION.tgz") + MustDownload-File -URLs $sha_url -OutFile $tmp_dir\cni-plugins.sha1 + $sha1_val = ($(Get-Content $tmp_dir\cni-plugins.sha1) -split ' ',2)[0] + MustDownload-File ` + -URLs $tgz_url ` + -OutFile $tmp_dir\cni-plugins.tgz ` + -Hash $sha1_val + + Push-Location $tmp_dir + # tar can only extract in the current directory. + tar -xvf $tmp_dir\cni-plugins.tgz + Move-Item -Force host-local.exe ${env:CNI_DIR}\ + Move-Item -Force win-bridge.exe ${env:CNI_DIR}\ + Pop-Location + Remove-Item -Force -Recurse $tmp_dir } if (-not ((Test-Path ${env:CNI_DIR}\win-bridge.exe) -and ` (Test-Path ${env:CNI_DIR}\host-local.exe))) {