Skip to content

Commit

Permalink
[v3.22] Pick windows fixes (#5908)
Browse files Browse the repository at this point in the history
* windows: move install script tool to calico directory and add install script to release artifacts (#5788)

* windows: move generation of install script to calico directory

In commit 346127c, we added a tool to
generate the install script and placed that in the node directory.

This change moves the install script tool and template to the calico
directory. Make targets in node will copy over the rendered script.

* Upload windows install script to release

* Move install-calico-windows.ps1 back to liquid template

* Fix install script template template

* Update release build and doc for install script changes

* Remove unneeded clean target

* Update install script and remove variant specific logic

* Fix Get-IsDSRSupported command not found

While this is only used in EKS we'll probably end up putting more and
more of this script's functions in calico.psm1
  • Loading branch information
lmm authored Apr 14, 2022
1 parent 3c50e3a commit 95b839a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 603 deletions.
23 changes: 16 additions & 7 deletions calico/scripts/install-calico-windows.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Copyright (c) 2020-2021 Tigera, Inc. All rights reserved.
---
layout: null
---
# Copyright (c) 2020-2022 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.
Expand All @@ -11,17 +14,22 @@
# 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.

<#
.DESCRIPTION
This script installs and starts Calico services on a Windows node.
This script installs and starts {{site.prodname}} services on a Windows node.
Note: EKS requires downloading kubectl.exe to c:\k before running this script: https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html
#>

Param(
[parameter(Mandatory = $false)] $ReleaseBaseURL="https://github.com/projectcalico/calico/releases/download/v3.22.1/",
[parameter(Mandatory = $false)] $ReleaseFile="calico-windows-v3.22.1.zip",
# Note: we don't publish a release artifact for the "master" branch. To test
# against master, build calico-windows.zip from projectcalico/node.
{%- if site.url contains "projectcalico" %}
[parameter(Mandatory = $false)] $ReleaseBaseURL="https://github.com/projectcalico/calico/releases/download/{{site.data.versions.first.components["calico/node"].version}}/",
{%- else %}
[parameter(Mandatory = $false)] $ReleaseBaseURL="{{site.url}}/files/windows/",
{%- endif %}
[parameter(Mandatory = $false)] $ReleaseFile="calico-windows-{{site.data.versions.first.components["calico/node"].version}}.zip",
[parameter(Mandatory = $false)] $KubeVersion="",
[parameter(Mandatory = $false)] $DownloadOnly="no",
[parameter(Mandatory = $false)] $Datastore="kubernetes",
Expand Down Expand Up @@ -136,7 +144,7 @@ function GetBackendType()
if ($Datastore -EQ "kubernetes") {
$encap=c:\k\kubectl.exe --kubeconfig="$RootDir\calico-kube-config" get felixconfigurations.crd.projectcalico.org default -o jsonpath='{.spec.ipipEnabled}' -n $CalicoNamespace
if ($encap -EQ "true") {
throw "Calico on Linux has IPIP enabled. IPIP is not supported on Windows nodes."
throw "{{site.prodname}} on Linux has IPIP enabled. IPIP is not supported on Windows nodes."
}

$encap=c:\k\kubectl.exe --kubeconfig="$RootDir\calico-kube-config" get felixconfigurations.crd.projectcalico.org default -o jsonpath='{.spec.vxlanEnabled}' -n $CalicoNamespace
Expand Down Expand Up @@ -331,6 +339,7 @@ Exit
Remove-Item $RootDir -Force -Recurse -ErrorAction SilentlyContinue
Write-Host "Unzip Calico for Windows release..."
Expand-Archive -Force $CalicoZip c:\
ipmo $RootDir\libs\calico\calico.psm1

Write-Host "Setup Calico for Windows..."
SetConfigParameters -OldString '<your datastore type>' -NewString $Datastore
Expand Down Expand Up @@ -415,7 +424,7 @@ if ($platform -EQ "bare-metal") {
}

if ($DownloadOnly -EQ "yes") {
Write-Host "Downloaded Calico for Windows. Update c:\CalicoWindows\config.ps1 and run c:\CalicoWindows\install-calico.ps1"
Write-Host "Downloaded Calico for Windows installation zip file."
Exit
}

Expand Down
36 changes: 5 additions & 31 deletions node/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ NODE_CONTAINER_BIN_DIR=./dist/bin/
NODE_CONTAINER_BINARY = $(NODE_CONTAINER_BIN_DIR)/calico-node-$(ARCH)
WINDOWS_BINARY = $(NODE_CONTAINER_BIN_DIR)/calico-node.exe

WINDOWS_GEN_INSTALL_SCRIPT_BIN := hack/bin/gen-install-calico-windows-script

# Base URL of the Calico for Windows installation zip archive.
# This can be overridden for dev releases.
WINDOWS_ARCHIVE_BASE_URL ?= https://docs.projectcalico.org

# This is either "Calico" or "Calico Enterprise"
WINDOWS_INSTALL_SCRIPT_PRODUCT ?= Calico
WINDOWS_INSTALL_SCRIPT := dist/install-calico-windows.ps1

# Variables for the Windows packaging.
Expand Down Expand Up @@ -177,7 +169,6 @@ clean: clean-windows-upgrade
rm -f $(WINDOWS_ARCHIVE_ROOT)/libs/hns/hns.psm1
rm -f $(WINDOWS_ARCHIVE_ROOT)/libs/hns/License.txt
rm -f $(WINDOWS_ARCHIVE_ROOT)/cni/*.exe
rm -f $(WINDOWS_GEN_INSTALL_SCRIPT_BIN)
rm -f $(WINDOWS_INSTALL_SCRIPT)
rm -f $(WINDOWS_UPGRADE_INSTALL_FILE)
rm -f $(WINDOWS_UPGRADE_BUILD)/*.zip
Expand Down Expand Up @@ -549,8 +540,6 @@ release-build: .release-$(VERSION).created
$(MAKE) retag-build-images-with-registries RELEASE=true IMAGETAG=$(VERSION)
# Generate the `latest` node images.
$(MAKE) retag-build-images-with-registries RELEASE=true IMAGETAG=latest
# Generate the install-calico-windows.ps1 script
$(MAKE) install-calico-windows-script
# Generate the Windows zip archives.
$(MAKE) release-windows-archive
$(MAKE) release-windows-upgrade-archive
Expand All @@ -577,11 +566,6 @@ release-publish: release-prereqs .release-$(VERSION).published
# Push Windows upgrade images.
$(MAKE) cd-windows-upgrade RELEASE=$(RELEASE) CONFIRM=$(CONFIRM)

# TODO: Update release tool to upload this to the correct location.
# Update the release with the install-calico-windows.ps1 file too.
# ghr -u projectcalico -r node \
# -n $(VERSION) \
# $(VERSION) $(WINDOWS_INSTALL_SCRIPT)
touch $@

# WARNING: Only run this target if this release is the latest stable release. Do NOT
Expand Down Expand Up @@ -661,21 +645,11 @@ $(WINDOWS_UPGRADE_SCRIPT): $(WINDOWS_UPGRADE_DIST_STAGE)
$(WINDOWS_UPGRADE_INSTALL_ZIP): build-windows-archive $(WINDOWS_UPGRADE_DIST_STAGE)
cp $(WINDOWS_ARCHIVE) $@

# Build the tool to generate the install-calico-windows.ps1 installation script.
$(WINDOWS_GEN_INSTALL_SCRIPT_BIN):
mkdir -p hack/bin
$(DOCKER_RUN) $(CALICO_BUILD) sh -c ' \
$(GIT_CONFIG_SSH) \
go build -o $@ ./hack/gen-install-calico-windows-script'

# Generate the install-calico-windows.ps1 installation script.
# For dev releases, override WINDOWS_ARCHIVE_BASE_URL.
install-calico-windows-script $(WINDOWS_INSTALL_SCRIPT): $(WINDOWS_GEN_INSTALL_SCRIPT_BIN)
$(WINDOWS_GEN_INSTALL_SCRIPT_BIN) \
-product "$(WINDOWS_INSTALL_SCRIPT_PRODUCT)" \
-version $(GIT_VERSION) \
-templatePath windows-packaging/install-calico-windows.ps1.tpl \
-baseUrl $(WINDOWS_ARCHIVE_BASE_URL) > $(WINDOWS_INSTALL_SCRIPT)
# Build the docs site and copy over the install-calico-windows.ps1 script.
$(WINDOWS_INSTALL_SCRIPT):
-mkdir -p dist
make -C ../calico clean _site
cp $(CURDIR)/../calico/_site/scripts/install-calico-windows.ps1 $@

# Copy the install-calico-windows.ps1 script to the temporary directory where we
# build the windows upgrade zip file.
Expand Down
126 changes: 0 additions & 126 deletions node/hack/gen-install-calico-windows-script/main.go

This file was deleted.

Loading

0 comments on commit 95b839a

Please sign in to comment.