From 6d78f2b6668132e39b49fdf4ab5a8d0d65de2a56 Mon Sep 17 00:00:00 2001 From: Peter Hornyack Date: Tue, 12 Feb 2019 16:38:49 -0800 Subject: [PATCH] Default to Windows Server version 1809 for Windows nodes. Removes all references to 1803, including moving "win1803" directory to just "windows". A single Windows directory suffices for now, if necessary in the future we can shard it into directories for each Windows version. We've been running tests with Windows 1809 nodes for a couple days in our fork without major problems: https://testgrid.k8s.io/google-windows#windows-prototype&width=20. Testing on Azure is already using 1809: https://testgrid.k8s.io/sig-windows#Conformance%20acs-engine%20on%20Azure&width=20. --- cluster/gce/config-default.sh | 4 +-- cluster/gce/config-test.sh | 4 +-- cluster/gce/util.sh | 6 ++-- cluster/gce/{win1803 => windows}/OWNERS | 0 .../README-GCE-Windows-kube-up.md | 2 +- cluster/gce/{win1803 => windows}/common.psm1 | 0 .../gce/{win1803 => windows}/configure.ps1 | 0 .../{win1803 => windows}/k8s-node-setup.psm1 | 33 ++++++++++++------- .../gce/{win1803 => windows}/node-helper.sh | 8 ++--- .../gce/{win1803 => windows}/smoke-test.sh | 0 .../{win1803 => windows}/user-profile.psm1 | 0 11 files changed, 32 insertions(+), 25 deletions(-) rename cluster/gce/{win1803 => windows}/OWNERS (100%) rename cluster/gce/{win1803 => windows}/README-GCE-Windows-kube-up.md (99%) rename cluster/gce/{win1803 => windows}/common.psm1 (100%) rename cluster/gce/{win1803 => windows}/configure.ps1 (100%) rename cluster/gce/{win1803 => windows}/k8s-node-setup.psm1 (97%) rename cluster/gce/{win1803 => windows}/node-helper.sh (84%) rename cluster/gce/{win1803 => windows}/smoke-test.sh (100%) rename cluster/gce/{win1803 => windows}/user-profile.psm1 (100%) diff --git a/cluster/gce/config-default.sh b/cluster/gce/config-default.sh index 4a3f171d080..34753dc7a5a 100755 --- a/cluster/gce/config-default.sh +++ b/cluster/gce/config-default.sh @@ -65,7 +65,7 @@ MIG_WAIT_UNTIL_STABLE_TIMEOUT=${MIG_WAIT_UNTIL_STABLE_TIMEOUT:-1800} MASTER_OS_DISTRIBUTION=${KUBE_MASTER_OS_DISTRIBUTION:-${KUBE_OS_DISTRIBUTION:-gci}} NODE_OS_DISTRIBUTION=${KUBE_NODE_OS_DISTRIBUTION:-${KUBE_OS_DISTRIBUTION:-gci}} -WINDOWS_NODE_OS_DISTRIBUTION=${WINDOWS_NODE_OS_DISTRIBUTION:-win1803} +WINDOWS_NODE_OS_DISTRIBUTION=${WINDOWS_NODE_OS_DISTRIBUTION:-win1809} if [[ "${MASTER_OS_DISTRIBUTION}" == "cos" ]]; then MASTER_OS_DISTRIBUTION="gci" @@ -478,4 +478,4 @@ fi # Taint Windows nodes by default to prevent Linux workloads from being # scheduled onto them. -WINDOWS_NODE_TAINTS="${WINDOWS_NODE_TAINTS:-node.kubernetes.io/os=windows:NoSchedule}" +WINDOWS_NODE_TAINTS="${WINDOWS_NODE_TAINTS:-node.kubernetes.io/os=win1809:NoSchedule}" diff --git a/cluster/gce/config-test.sh b/cluster/gce/config-test.sh index 4bac9cedfe6..cce1b431edb 100755 --- a/cluster/gce/config-test.sh +++ b/cluster/gce/config-test.sh @@ -68,7 +68,7 @@ MIG_WAIT_UNTIL_STABLE_TIMEOUT=${MIG_WAIT_UNTIL_STABLE_TIMEOUT:-1800} MASTER_OS_DISTRIBUTION=${KUBE_MASTER_OS_DISTRIBUTION:-${KUBE_OS_DISTRIBUTION:-gci}} NODE_OS_DISTRIBUTION=${KUBE_NODE_OS_DISTRIBUTION:-${KUBE_OS_DISTRIBUTION:-gci}} -WINDOWS_NODE_OS_DISTRIBUTION=${WINDOWS_NODE_OS_DISTRIBUTION:-win1803} +WINDOWS_NODE_OS_DISTRIBUTION=${WINDOWS_NODE_OS_DISTRIBUTION:-win1809} if [[ "${MASTER_OS_DISTRIBUTION}" == "cos" ]]; then MASTER_OS_DISTRIBUTION="gci" @@ -498,4 +498,4 @@ fi # Taint Windows nodes by default to prevent Linux workloads from being # scheduled onto them. -WINDOWS_NODE_TAINTS="${WINDOWS_NODE_TAINTS:-node.kubernetes.io/os=windows:NoSchedule}" +WINDOWS_NODE_TAINTS="${WINDOWS_NODE_TAINTS:-node.kubernetes.io/os=win1809:NoSchedule}" diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index 7603ef93f1a..99ea09119fc 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -32,7 +32,7 @@ else exit 1 fi -source "${KUBE_ROOT}/cluster/gce/${WINDOWS_NODE_OS_DISTRIBUTION}/node-helper.sh" +source "${KUBE_ROOT}/cluster/gce/windows/node-helper.sh" if [[ "${MASTER_OS_DISTRIBUTION}" == "trusty" || "${MASTER_OS_DISTRIBUTION}" == "gci" || "${MASTER_OS_DISTRIBUTION}" == "ubuntu" ]]; then source "${KUBE_ROOT}/cluster/gce/${MASTER_OS_DISTRIBUTION}/master-helper.sh" @@ -87,9 +87,7 @@ function set-linux-node-image() { # WINDOWS_NODE_IMAGE_PROJECT function set-windows-node-image() { WINDOWS_NODE_IMAGE_PROJECT="windows-cloud" - if [[ "${WINDOWS_NODE_OS_DISTRIBUTION}" == "win1803" ]]; then - WINDOWS_NODE_IMAGE_FAMILY="windows-1803-core-for-containers" - elif [[ "${WINDOWS_NODE_OS_DISTRIBUTION}" == "win2019" ]]; then + if [[ "${WINDOWS_NODE_OS_DISTRIBUTION}" == "win2019" ]]; then WINDOWS_NODE_IMAGE_FAMILY="windows-2019-core-for-containers" elif [[ "${WINDOWS_NODE_OS_DISTRIBUTION}" == "win1809" ]]; then WINDOWS_NODE_IMAGE_FAMILY="windows-1809-core-for-containers" diff --git a/cluster/gce/win1803/OWNERS b/cluster/gce/windows/OWNERS similarity index 100% rename from cluster/gce/win1803/OWNERS rename to cluster/gce/windows/OWNERS diff --git a/cluster/gce/win1803/README-GCE-Windows-kube-up.md b/cluster/gce/windows/README-GCE-Windows-kube-up.md similarity index 99% rename from cluster/gce/win1803/README-GCE-Windows-kube-up.md rename to cluster/gce/windows/README-GCE-Windows-kube-up.md index a01703a0aed..a32642c1e17 100644 --- a/cluster/gce/win1803/README-GCE-Windows-kube-up.md +++ b/cluster/gce/windows/README-GCE-Windows-kube-up.md @@ -99,7 +99,7 @@ Invoke this script to run a smoke test that verifies that the cluster has been brought up correctly: ``` -cluster/gce/win1803/smoke-test.sh +cluster/gce/windows/smoke-test.sh ``` ## Running tests against the cluster diff --git a/cluster/gce/win1803/common.psm1 b/cluster/gce/windows/common.psm1 similarity index 100% rename from cluster/gce/win1803/common.psm1 rename to cluster/gce/windows/common.psm1 diff --git a/cluster/gce/win1803/configure.ps1 b/cluster/gce/windows/configure.ps1 similarity index 100% rename from cluster/gce/win1803/configure.ps1 rename to cluster/gce/windows/configure.ps1 diff --git a/cluster/gce/win1803/k8s-node-setup.psm1 b/cluster/gce/windows/k8s-node-setup.psm1 similarity index 97% rename from cluster/gce/win1803/k8s-node-setup.psm1 rename to cluster/gce/windows/k8s-node-setup.psm1 index a23fe3d57f4..47779a22eee 100644 --- a/cluster/gce/win1803/k8s-node-setup.psm1 +++ b/cluster/gce/windows/k8s-node-setup.psm1 @@ -27,10 +27,10 @@ [Net.ServicePointManager]::SecurityProtocol = ` [Net.SecurityProtocolType]::Tls12 Invoke-WebRequest ` - https://github.com/kubernetes/kubernetes/raw/windows-up/cluster/gce/win1803/k8s-node-setup.psm1 ` + https://github.com/kubernetes/kubernetes/raw/master/cluster/gce/windows/k8s-node-setup.psm1 ` -OutFile C:\k8s-node-setup.psm1 Invoke-WebRequest ` - https://github.com/kubernetes/kubernetes/raw/windows-up/cluster/gce/win1803/configure.ps1 ` + https://github.com/kubernetes/kubernetes/raw/master/cluster/gce/windows/configure.ps1 ` -OutFile C:\configure.ps1 Import-Module -Force C:\k8s-node-setup.psm1 # -Force to override existing # Execute functions manually or run configure.ps1. @@ -111,8 +111,8 @@ function WaitFor_GceMetadataServerRouteToBeRemoved { # Adds a route to the GCE metadata server to every network interface. function Add_GceMetadataServerRoute { - # Before setting up HNS the 1803 VM has a "vEthernet (nat)" interface and a - # "Ethernet" interface, and the route to the metadata server exists on the + # Before setting up HNS the Windows VM has a "vEthernet (nat)" interface and + # a "Ethernet" interface, and the route to the metadata server exists on the # Ethernet interface. After adding the HNS network a "vEthernet (Ethernet)" # interface is added, and it seems to subsume the routes of the "Ethernet" # interface (trying to add routes on the Ethernet interface at this point just @@ -259,17 +259,14 @@ function Download-HelperScripts { } # Takes the Windows version string from the cluster bash scripts (e.g. -# 'win1803') and returns the correct label to use for containers on this +# 'win1809') and returns the correct label to use for containers on this # version of Windows. Returns $null if $WinVersion is unknown. function Get_ContainerVersionLabel { param ( [parameter(Mandatory=$true)] [string]$WinVersion ) # -match does regular expression matching. - if ($WinVersion -match '1803') { - return '1803' - } - elseif ($WinVersion -match '1809') { + if ($WinVersion -match '1809') { return '1809' } elseif ($WinVersion -match '2019') { @@ -281,8 +278,16 @@ function Get_ContainerVersionLabel { # Builds the pause image with name $INFRA_CONTAINER. function Create-PauseImage { - $version_label = Get_ContainerVersionLabel ` - $(Get-InstanceMetadataValue 'win-version') + $win_version = $(Get-InstanceMetadataValue 'win-version') + if ($win_version -match '2019') { + # TODO(pjh): update this function to properly support 2019 vs. 1809 vs. + # future Windows versions. For example, Windows Server 2019 does not + # support the nanoserver container + # (https://blogs.technet.microsoft.com/virtualization/2018/11/13/windows-server-2019-now-available/). + Log_NotImplemented "Need to update Create-PauseImage for WS2019" + } + + $version_label = Get_ContainerVersionLabel $win_version $pause_dir = "${env:K8S_DIR}\pauseimage" $dockerfile = "$pause_dir\Dockerfile" mkdir -Force $pause_dir @@ -290,7 +295,7 @@ function Create-PauseImage { New-Item -Force -ItemType file $dockerfile | Out-Null Set-Content ` $dockerfile ` - ("FROM microsoft/nanoserver:${version_label}`n`n" + + ("FROM mcr.microsoft.com/windows/nanoserver:${version_label}`n`n" + "CMD cmd /c ping -t localhost > nul") } @@ -300,6 +305,10 @@ function Create-PauseImage { return } docker build -t ${INFRA_CONTAINER} $pause_dir + if ($LastExitCode -ne 0) { + Log-Output -Fatal ` + "docker build -t ${INFRA_CONTAINER} $pause_dir failed" + } } # Downloads the Kubernetes binaries from kube-env's NODE_BINARY_TAR_URL and diff --git a/cluster/gce/win1803/node-helper.sh b/cluster/gce/windows/node-helper.sh similarity index 84% rename from cluster/gce/win1803/node-helper.sh rename to cluster/gce/windows/node-helper.sh index 4ea1b749bfe..e63f487f0ab 100755 --- a/cluster/gce/win1803/node-helper.sh +++ b/cluster/gce/windows/node-helper.sh @@ -24,10 +24,10 @@ function get-windows-node-instance-metadata-from-file { # To get startup script output run "gcloud compute instances # get-serial-port-output " from the location where you're running # kube-up. - metadata+="windows-startup-script-ps1=${KUBE_ROOT}/cluster/gce/${WINDOWS_NODE_OS_DISTRIBUTION}/configure.ps1," - metadata+="common-psm1=${KUBE_ROOT}/cluster/gce/${WINDOWS_NODE_OS_DISTRIBUTION}/common.psm1," - metadata+="k8s-node-setup-psm1=${KUBE_ROOT}/cluster/gce/${WINDOWS_NODE_OS_DISTRIBUTION}/k8s-node-setup.psm1," - metadata+="user-profile-psm1=${KUBE_ROOT}/cluster/gce/${WINDOWS_NODE_OS_DISTRIBUTION}/user-profile.psm1," + metadata+="windows-startup-script-ps1=${KUBE_ROOT}/cluster/gce/windows/configure.ps1," + metadata+="common-psm1=${KUBE_ROOT}/cluster/gce/windows/common.psm1," + metadata+="k8s-node-setup-psm1=${KUBE_ROOT}/cluster/gce/windows/k8s-node-setup.psm1," + metadata+="user-profile-psm1=${KUBE_ROOT}/cluster/gce/windows/user-profile.psm1," metadata+="${NODE_EXTRA_METADATA}" echo "${metadata}" } diff --git a/cluster/gce/win1803/smoke-test.sh b/cluster/gce/windows/smoke-test.sh similarity index 100% rename from cluster/gce/win1803/smoke-test.sh rename to cluster/gce/windows/smoke-test.sh diff --git a/cluster/gce/win1803/user-profile.psm1 b/cluster/gce/windows/user-profile.psm1 similarity index 100% rename from cluster/gce/win1803/user-profile.psm1 rename to cluster/gce/windows/user-profile.psm1