-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build calico windows upgrade image (#1278)
* Add building of calico windows upgrade image
- Loading branch information
Showing
4 changed files
with
276 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright (c) 2021 Tigera, Inc. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
ARG WINDOWS_VERSION | ||
FROM --platform=linux/amd64 alpine:latest as base | ||
|
||
# We can't RUN commands in the Windows image build. | ||
# Create dirs we need that we copy over in the final stage. | ||
RUN mkdir /CalicoUpgrade /CalicoBin | ||
|
||
ADD build/* /CalicoBin/ | ||
|
||
FROM mcr.microsoft.com/windows/nanoserver:${WINDOWS_VERSION} | ||
|
||
COPY --from=base /CalicoUpgrade /CalicoUpgrade | ||
COPY --from=base /CalicoBin /CalicoBin | ||
|
||
# nanoserver defaults to ContainerUser however we need admin to run icacls | ||
USER ContainerAdministrator | ||
|
||
ENTRYPOINT cmd.exe \ | ||
/C \ | ||
copy /y c:\\CalicoBin\\calico-windows-upgrade.zip c:\\CalicoUpgrade & \ | ||
tar -x -f c:\\CalicoUpgrade\calico-windows-upgrade.zip -C c:\\CalicoUpgrade & \ | ||
del c:\\CalicoUpgrade\calico-windows-upgrade.zip & \ | ||
icacls.exe c:\\CalicoUpgrade & \ | ||
icacls.exe c:\\CalicoUpgrade /inheritance:r & \ | ||
icacls.exe c:\\CalicoUpgrade /grant:r SYSTEM:(OI)(CI)(F) & \ | ||
icacls.exe c:\\CalicoUpgrade /grant:r BUILTIN\Administrators:(OI)(CI)(F) & \ | ||
icacls.exe c:\\CalicoUpgrade /grant:r BUILTIN\Users:(OI)(CI)(RX) & \ | ||
icacls.exe c:\\CalicoUpgrade & \ | ||
ping -t localhost > NUL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright (c) 2021 Tigera, Inc. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http:#www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
$rootDir = "c:\CalicoWindows" | ||
$installZipFile = "c:\calico-windows.zip" | ||
|
||
$date = Get-Date -UFormat "%Y-%m-%d" | ||
$logFile = "c:\calico-upgrade.$date.log" | ||
|
||
function Log { | ||
param ([String]$value) | ||
$stamp = Get-Date -UFormat "%Y-%m-%d %R:%S" | ||
Add-content -Path $logFile -Value "$stamp [INFO] $value" | ||
} | ||
|
||
Log "Starting calico upgrade" | ||
$zipFile = $Get-ChildItem -path . -filter calico-windows-upgrade*.zip | Select -expandproperty Name | ||
Expand-Archive -Path $zipFile -DestinationPath $PSScriptRoot | ||
Remove-Item -Path $zipFile | ||
|
||
Log "Files in c:\CalicoUpgrade:" | ||
$files = ls c:\CalicoUpgrade | Out-String | ||
Log $files | ||
|
||
Log "Copying installation zip file" | ||
cp $PSScriptRoot\*.zip $installZipFile | ||
|
||
Log "Starting installation script..." | ||
& $PSScriptRoot\install-calico-windows.ps1 *>> $logFile | ||
|
||
Log "Cleaning up" | ||
Remove-Item -Path $PSScriptRoot\*.ps1 | ||
Remove-Item -Path $PSScriptRoot\*.zip | ||
$oldCalicoNode = "$rootDir\calico-node.exe.to-be-replaced" | ||
if (Test-Path $oldCalicoNode) | ||
{ | ||
Remove-Item -Path $oldCalicoNode | ||
} | ||
|
||
Log "Finished upgrade" |