From 09d5b6216eb87a4c3bd027e12284ab8eea058d2e Mon Sep 17 00:00:00 2001 From: Luther Monson Date: Tue, 19 Jan 2021 17:35:57 -0700 Subject: [PATCH] Adding Windows 20H2 Builds --- .drone.yml | 47 +++++++++++++++++++++++++-- Dockerfile.windows.20H2 | 70 +++++++++++++++++++++++++++++++++++++++++ manifest.tmpl | 6 ++++ 3 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 Dockerfile.windows.20H2 diff --git a/.drone.yml b/.drone.yml index 242c192..8cdf1c0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -209,6 +209,48 @@ steps: event: - tag +volumes: + - name: docker_pipe + host: + path: \\\\.\\pipe\\docker_engine + +--- +kind: pipeline +name: windows-20H2 + +platform: + os: windows + arch: amd64 + version: 20H2 + +# remove this and use upstream images when https://github.com/drone/drone-git/pull/25 is merged +clone: + disable: true + +steps: + - name: clone + image: luthermonson/drone-git:windows-20H2-amd64 + - name: publish-hyperkube-windows-20H2 + image: luthermonson/drone-docker:20H2 + settings: + username: + from_secret: docker_username + password: + from_secret: docker_password + dockerfile: Dockerfile.windows.20H2 + repo: rancher/hyperkube + tag: "${DRONE_TAG}-windows-20H2" + build_args: + - SERVERCORE_VERSION=20H2 + volumes: + - name: docker_pipe + path: \\\\.\\pipe\\docker_engine + when: + instance: + - drone-publish.rancher.io + event: + - tag + volumes: - name: docker_pipe host: @@ -219,7 +261,7 @@ name: manifest steps: - name: push-manifest - image: ibuildthecloud/manifest:v1.2.3-patch1 + image: plugins/manifest settings: username: from_secret: docker_username @@ -237,4 +279,5 @@ depends_on: - windows-1809 - windows-1903 - windows-1909 -- windows-2004 \ No newline at end of file +- windows-2004 +- windows-20H2 \ No newline at end of file diff --git a/Dockerfile.windows.20H2 b/Dockerfile.windows.20H2 new file mode 100644 index 0000000..d4b0d97 --- /dev/null +++ b/Dockerfile.windows.20H2 @@ -0,0 +1,70 @@ +ARG SERVERCORE_VERSION + +FROM mcr.microsoft.com/windows/servercore:${SERVERCORE_VERSION} as builder +SHELL ["powershell", "-NoLogo", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] +RUN if (-not (Get-Command Expand-7Zip -ErrorAction Ignore)) { \ + Install-PackageProvider -Name NuGet -Force -Verbose; \ + Install-Module -Name 7Zip4Powershell -Repository PSGallery -Force -Verbose; \ + if(-not $?) { \ + Write-Error "Failed to install package"; \ + Exit 1; \ + } \ + } +ENV K8S_VERSION v1.19.7 +RUN $URL = ('https://dl.k8s.io/{0}/kubernetes-node-windows-amd64.tar.gz' -f $env:K8S_VERSION); \ + \ + function Expand-GZip ($inFile, $outFile) { \ + $input = New-Object System.IO.FileStream $inFile, ([IO.FileMode]::Open), ([IO.FileAccess]::Read), ([IO.FileShare]::Read); \ + $output = New-Object System.IO.FileStream $outFile, ([IO.FileMode]::Create), ([IO.FileAccess]::Write), ([IO.FileShare]::None); \ + $gzipStream = New-Object System.IO.Compression.GzipStream $input, ([IO.Compression.CompressionMode]::Decompress); \ + try { \ + if (!$input -or !$output -or !$gzipStream) { \ + Write-Error "Failed to Unzip the archive"; \ + Exit 1; \ + } \ + $buffer = New-Object byte[](1024); \ + while ($true) { \ + $read = $gzipstream.Read($buffer, 0, 1024); \ + if ($read -le 0 ) { \ + break; \ + } \ + $output.Write($buffer, 0, $read); \ + } \ + } finally { \ + $gzipStream.Close(); \ + $output.Close(); \ + $input.Close(); \ + } \ + }; \ + \ + Write-Host ('Downloading Kubernetes from {0} ...' -f $URL); \ + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ + Invoke-WebRequest -UseBasicParsing -OutFile c:\kubernetes.tar.gz -Uri $URL; \ + \ + Write-Host 'Expanding ...'; \ + Expand-GZip c:\kubernetes.tar.gz c:\kubernetes.tar; \ + Expand-7Zip c:\kubernetes.tar c:\; \ + \ + Write-Host 'Complete.' + +# FROM mcr.microsoft.com/powershell:nanoserver-${SERVERCORE_VERSION} +# USER ContainerAdministrator +# SHELL ["pwsh.exe", "-NoLogo", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] +RUN $URL = 'https://github.com/rancher/azure-cli/releases/download/v0.0.2/dist.azure-cli.zip'; \ + \ + Write-Host ('Downloading azure-cli from {0} ...' -f $URL); \ + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ + Invoke-WebRequest -UseBasicParsing -OutFile c:\azure-cli.zip -Uri $URL; \ + \ + Write-Host 'Expanding ...'; \ + Expand-Archive -Force -Path c:\azure-cli.zip -DestinationPath c:\azure-cli; \ + Remove-Item -Force -Path c:\azure-cli.zip; \ + \ + Write-Host 'Complete.' +# COPY --from=builder /Windows/System32/netapi32.dll /Windows/System32/ +RUN Move-Item -Path /kubernetes/node/bin/kubectl.exe -Destination /Windows +RUN New-Item -Force -ItemType Directory -Path /etc; \ + New-Item -Force -ItemType Directory -Path /etc/kubernetes; \ + New-Item -Force -ItemType Directory -Path /etc/kubernetes/bin; \ + Move-Item -Path /kubernetes/node/bin/*.exe -Destination /etc/kubernetes/bin/ +COPY windows/entrypoint.ps1 /usr/bin/ diff --git a/manifest.tmpl b/manifest.tmpl index 89722af..2dcd1aa 100644 --- a/manifest.tmpl +++ b/manifest.tmpl @@ -34,3 +34,9 @@ manifests: architecture: amd64 os: windows version: 2004 + - + image: rancher/hyperkube:{{build.tag}}-windows-20H2 + platform: + architecture: amd64 + os: windows + version: 20H2