Skip to content

Commit

Permalink
Automated upgrade support for Jenkins kind clusters
Browse files Browse the repository at this point in the history
Signed-off-by: KMAnju-2021 <km074btcse18@igdtuw.ac.in>
  • Loading branch information
KMAnju-2021 committed Nov 20, 2023
1 parent bdf2d6b commit 0b1ae22
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 6 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ on:
type: boolean
default: false

env:
KIND_VERSION: v0.18.0

jobs:
test:
Expand Down Expand Up @@ -61,6 +59,7 @@ jobs:
./hack/build-antrea-linux-all.sh --pull
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ on:
- release-*
- feature/*

env:
KIND_VERSION: v0.20.0

jobs:
check-changes:
Expand Down Expand Up @@ -95,6 +93,7 @@ jobs:
docker load -i antrea-ubuntu.tar
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
Expand Down Expand Up @@ -156,6 +155,7 @@ jobs:
docker load -i antrea-ubuntu.tar
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
Expand Down Expand Up @@ -223,6 +223,7 @@ jobs:
docker load -i antrea-ubuntu.tar
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
Expand Down Expand Up @@ -290,6 +291,7 @@ jobs:
docker load -i antrea-ubuntu.tar
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
Expand Down Expand Up @@ -351,6 +353,7 @@ jobs:
docker load -i antrea-ubuntu.tar
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
Expand Down Expand Up @@ -424,6 +427,7 @@ jobs:
docker load -i flow-aggregator.tar
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
Expand Down Expand Up @@ -486,6 +490,7 @@ jobs:
docker tag antrea/antrea-ubuntu-coverage:latest antrea/antrea-ubuntu:latest
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
Expand Down Expand Up @@ -530,6 +535,7 @@ jobs:
docker tag antrea/antrea-ubuntu-coverage:latest antrea/antrea-ubuntu:latest
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
Expand Down Expand Up @@ -574,6 +580,7 @@ jobs:
docker tag antrea/antrea-ubuntu-coverage:latest antrea/antrea-ubuntu:latest
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
Expand Down Expand Up @@ -618,6 +625,7 @@ jobs:
docker tag antrea/antrea-ubuntu-coverage:latest antrea/antrea-ubuntu:latest
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
Expand Down Expand Up @@ -662,6 +670,7 @@ jobs:
docker tag antrea/antrea-ubuntu-coverage:latest antrea/antrea-ubuntu:latest
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
Expand Down Expand Up @@ -703,6 +712,7 @@ jobs:
docker tag antrea/antrea-ubuntu-coverage:latest antrea/antrea-ubuntu:latest
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/netpol_cyclonus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
# run once a day at midnight
- cron: '0 0 * * *'

env:
KIND_VERSION: v0.20.0

jobs:
test-netpol-cyclonus:
Expand All @@ -22,6 +20,7 @@ jobs:
- run: make
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
Expand Down
1 change: 1 addition & 0 deletions ci/jenkins/jobs/macros.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
# we have configured for running conformance and NetworkPolicy tests on Kind,
# so clusters older than that can de deleted safely.
./ci/kind/kind-setup.sh destroy --all --until 135
./ci/kind/kind-install.sh
./ci/kind/kind-setup.sh --antrea-cni create "${{JOB_NAME}}-${{BUILD_NUMBER}}"
kind export kubeconfig -n "${{JOB_NAME}}-${{BUILD_NUMBER}}" --kubeconfig ${{PWD}}/.kube/config
set +ex
Expand Down
55 changes: 55 additions & 0 deletions ci/kind/kind-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash

# Copyright 2023 Antrea Authors
#
# 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.

set -eo pipefail
LATEST_KIND_VERSION=$(head -n1 ./ci/kind/version)

# on linux
function upgrade_kind {
arch_name="$(uname -m)"
binary_name=""
case "$arch_name" in
"x86_64")
binary_name="kind-linux-amd64"
;;
"aarch64")
binary_name="kind-linux-arm64"
;;
*)
echoerr "Unsupported platform $arch_name"
exit 1
;;
esac

curl -Lo ./kind https://kind.sigs.k8s.io/dl/$LATEST_KIND_VERSION/$binary_name
chmod +x ./kind
sudo mv kind /usr/local/bin
}

CMD_RETURN_CODE=0
kind_version=$(kind version | awk '{print $2}') || CMD_RETURN_CODE=$?
if [[ ${CMD_RETURN_CODE} -ne 0 ]]; then
echo "=== Installing Kind ==="
upgrade_kind
exit 0
elif [[ "$kind_version" != "$LATEST_KIND_VERSION" ]]; then
echo "=== Upgrading Kind to the latest version $LATEST_KIND_VERSION ==="
upgrade_kind
else
echo "=== Existing Kind version $kind_version is up to date ==="
exit 0
fi

1 change: 1 addition & 0 deletions ci/kind/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.20.0

0 comments on commit 0b1ae22

Please sign in to comment.