diff --git a/.drone.yml b/.drone.yml index 0df7575..de6a730 100644 --- a/.drone.yml +++ b/.drone.yml @@ -88,140 +88,6 @@ volumes: path: /var/run/docker.sock --- kind: pipeline -name: windows-1809-pr - -platform: - os: windows - arch: amd64 - version: 1809 - -steps: - - name: hyperkube-windows-1809-pr - image: rancher/dapper:v0.5.7 - commands: - - "docker build -f Dockerfile.windows --build-arg SERVERCORE_VERSION=1809 ." - volumes: - - name: docker_pipe - path: \\\\.\\pipe\\docker_engine - when: - event: - - pull_request - -volumes: - - name: docker_pipe - host: - path: \\\\.\\pipe\\docker_engine - ---- -kind: pipeline -name: windows-1809 - -platform: - os: windows - arch: amd64 - version: 1809 - -steps: - - name: publish-hyperkube-windows-1809 - image: plugins/docker - settings: - username: - from_secret: docker_username - password: - from_secret: docker_password - dockerfile: Dockerfile.windows - repo: rancher/hyperkube - tag: "${DRONE_TAG}-windows-1809" - build_args: - - SERVERCORE_VERSION=1809 - volumes: - - name: docker_pipe - path: \\\\.\\pipe\\docker_engine - when: - instance: - - drone-publish.rancher.io - event: - - tag - -volumes: - - name: docker_pipe - host: - path: \\\\.\\pipe\\docker_engine ---- -kind: pipeline -name: windows-20H2-pr - -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: rancher/drone-images:git-20H2 - - name: hyperkube-windows-20H2-pr - image: rancher/dapper:v0.5.7 - commands: - - "docker build -f Dockerfile.windows.20H2 --build-arg SERVERCORE_VERSION=20H2 ." - volumes: - - name: docker_pipe - path: \\\\.\\pipe\\docker_engine - when: - event: - - pull_request - -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: rancher/drone-images:git-20H2 - - name: publish-hyperkube-windows-20H2 - image: rancher/drone-images: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: - path: \\\\.\\pipe\\docker_engine ---- -kind: pipeline name: manifest steps: @@ -241,5 +107,3 @@ steps: depends_on: - linux-amd64 - linux-arm64 -- windows-1809 -- windows-20H2 diff --git a/Dockerfile.windows b/Dockerfile.windows deleted file mode 100644 index 4de21c0..0000000 --- a/Dockerfile.windows +++ /dev/null @@ -1,67 +0,0 @@ -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.22.11 -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/ -COPY --from=builder /kubernetes/node/bin/kubectl.exe /Windows -COPY --from=builder /kubernetes/node/bin/kubelet.exe /kubernetes/node/bin/kube-proxy.exe /etc/kubernetes/bin/ -COPY windows/entrypoint.ps1 /usr/bin/ diff --git a/Dockerfile.windows.20H2 b/Dockerfile.windows.20H2 deleted file mode 100644 index 4c72571..0000000 --- a/Dockerfile.windows.20H2 +++ /dev/null @@ -1,71 +0,0 @@ -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.22.11 -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 New-Item -ItemType SymbolicLink -Target "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Path "C:\Windows\System32\WindowsPowerShell\v1.0\pwsh.exe" -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 2cd9d28..3ddc842 100644 --- a/manifest.tmpl +++ b/manifest.tmpl @@ -10,15 +10,3 @@ manifests: platform: architecture: arm64 os: linux - - - image: rancher/hyperkube:{{build.tag}}-windows-1809 - platform: - architecture: amd64 - os: windows - version: 1809 - - - image: rancher/hyperkube:{{build.tag}}-windows-20H2 - platform: - architecture: amd64 - os: windows - version: 20H2 diff --git a/windows/entrypoint.ps1 b/windows/entrypoint.ps1 deleted file mode 100644 index 0bb029d..0000000 --- a/windows/entrypoint.ps1 +++ /dev/null @@ -1,115 +0,0 @@ -<# - watch the sentinel `c:\opt\rke-tools\entrypoint.ps1` is ready or not -#> - -$ErrorActionPreference = 'Stop' -$WarningPreference = 'SilentlyContinue' -$VerbosePreference = 'SilentlyContinue' -$DebugPreference = 'SilentlyContinue' -$InformationPreference = 'SilentlyContinue' - -function Log-Info -{ - Write-Host -NoNewline -ForegroundColor Blue "INFO: " - Write-Host -ForegroundColor Gray ("{0,-44}" -f ($args -join " ")) -} - -function Log-Fatal -{ - Write-Host -NoNewline -ForegroundColor DarkRed "FATA: " - Write-Host -ForegroundColor Gray ("{0,-44}" -f ($args -join " ")) - - exit 1 -} - -function Wait-Ready -{ - param( - [parameter(Mandatory = $true)] $Path - ) - - $count = 600 - while ($count -gt 0) - { - Start-Sleep -s 1 - - if (Test-Path $Path -ErrorAction Ignore) - { - Start-Sleep -s 5 - break - } - - Start-Sleep -s 1 - $count -= 1 - } - - if ($count -le 0) - { - Log-Fatal "Timeout, could not found $Path" - } -} - -function Fix-LegacyArgument -{ - param ( - [parameter(Mandatory = $false)] [string[]]$ArgumentList - ) - - $argList = @() - $legacy = $null - for ($i = $ArgumentList.Length; $i -ge 0; $i--) { - $arg = $ArgumentList[$i] - switch -regex ($arg) - { - "^-{2}.*" { - if ($legacy) { - $arg = '{0}:{1}' -f $arg, $legacy - $legacy = $null - } - $argList += $arg - } - default { - $legacy = $arg - } - } - } - - return $argList -} - -function Run-PowerShell -{ - param ( - [parameter(Mandatory = $false)] [string[]]$ArgumentList - ) - - try { - if ($ArgumentList) { - Start-Process -NoNewWindow -Wait -FilePath "powershell" -ArgumentList $ArgumentList - } else { - Start-Process -NoNewWindow -Wait -FilePath "powershell" - } - } catch { - $errMsg = $_.Exception.Message - if ($errMsg -like "*This command cannot be run due to the error: *") { - if ($ArgumentList) { - Start-Process -NoNewWindow -Wait -FilePath "pwsh" -ArgumentList $ArgumentList - } else { - Start-Process -NoNewWindow -Wait -FilePath "pwsh" - } - } else { - throw $_ - } - } -} - -# the bootstrap arguments for kubernetes components are formatted by `component-name --key1=val1 --key2=val2 ...`, -# when passing `--pod-infra-container-image=rancher/kubelet-pause:v0.1.2` via windows docker, -# powershell would recognize it as `--pod-infra-container-image=rancher/kubelet-pause` and `v0.0.2` -$argList = Fix-LegacyArgument -ArgumentList $args[1..$args.Length] - -# waiting for the sentinel ready, which provided by servcie-sidekick -Log-Info "Waiting for servcie-sidekick to prepare the entrypoint.ps1 ..." -Wait-Ready -Path "c:\opt\rke-tools\entrypoint.ps1" -$entryArgs = @("-NoLogo", "-NonInteractive", "-File", "c:\opt\rke-tools\entrypoint.ps1", $args[0]) + $argList -Run-PowerShell -ArgumentList $entryArgs