Skip to content

Commit

Permalink
ci(k8s): download calico manifests as needed (backport of #11851) (#1…
Browse files Browse the repository at this point in the history
…1857)

Automatic cherry-pick of #11851 for branch release-2.5

Generated by
[action](https://github.com/kumahq/kuma/actions/runs/11511857576)

cherry-picked commit 529694b
⚠️ ⚠️ ⚠️ Conflicts happened when cherry-picking!
⚠️ ⚠️ ⚠️
```
On branch release-2.5
Your branch is up to date with 'origin/release-2.5'.

You are currently cherry-picking commit 529694b.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	deleted:    test/k3d/calico.yaml.kubelint-excluded

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   .gitignore
	both modified:   mk/dependencies/deps.lock
	both modified:   mk/dependencies/k3d.sh
	both modified:   mk/k3d.mk

```

---------

Signed-off-by: Mike Beaumont <[email protected]>
Signed-off-by: slonka <[email protected]>
Co-authored-by: Mike Beaumont <[email protected]>
Co-authored-by: slonka <[email protected]>
  • Loading branch information
3 people authored Oct 25, 2024
1 parent 6420c84 commit e7c9b51
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3,764 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ build/
# to embed ebpf programs by using go:embed, we have to copy programs first
pkg/transparentproxy/ebpf/programs/amd64/mb_*
pkg/transparentproxy/ebpf/programs/arm64/mb_*

# Used to download manifests for k3d
/test/k3d
2 changes: 1 addition & 1 deletion mk/dependencies/deps.lock
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8833e8be9eeeee4903952db5e738daf19645c938
b7ed391a41482e10d356d722a0d99e1dd4537b95
13 changes: 9 additions & 4 deletions mk/dependencies/k3d.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

OUTPUT_DIR=$1/bin
VERSION="5.4.7"
# see https://raw.githubusercontent.com/rancher/k3d/main/install.sh
curl --fail --location -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | \
PATH=${OUTPUT_DIR}:${PATH} TAG=v${VERSION} USE_SUDO="false" K3D_INSTALL_DIR="${OUTPUT_DIR}" bash

if [[ $2 == "get-version" ]]; then
echo ${VERSION}
else
# see https://raw.githubusercontent.com/rancher/k3d/main/install.sh
curl --fail --location -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | \
PATH=${OUTPUT_DIR}:${PATH} TAG=v${VERSION} USE_SUDO="false" K3D_INSTALL_DIR="${OUTPUT_DIR}" bash
fi
12 changes: 10 additions & 2 deletions mk/k3d.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CI_K3S_VERSION ?= $(K8S_MIN_VERSION)
METALLB_VERSION ?= v0.13.9
K3D_VERSION ?= $(shell $(TOP)/mk/dependencies/k3d.sh - get-version)

KUMA_MODE ?= standalone
KUMA_NAMESPACE ?= kuma-system
Expand Down Expand Up @@ -51,7 +52,7 @@ K3D_CLUSTER_CREATE_OPTS ?= -i rancher/k3s:$(CI_K3S_VERSION) \
--timeout 120s

ifeq ($(K3D_NETWORK_CNI),calico)
K3D_CLUSTER_CREATE_OPTS += --volume "$(TOP)/test/k3d/calico.yaml.kubelint-excluded:/var/lib/rancher/k3s/server/manifests/calico.yaml" \
K3D_CLUSTER_CREATE_OPTS += --volume "$(TOP)/$(KUMA_DIR)/test/k3d/calico.$(K3D_VERSION).yaml:/var/lib/rancher/k3s/server/manifests/calico.yaml" \
--k3s-arg '--flannel-backend=none@server:*'
endif

Expand Down Expand Up @@ -81,8 +82,15 @@ k3d/network/create:
else docker network create -d=bridge $(KIND_NETWORK_OPTS) kind || true; fi && \
rm -f $(BUILD_DIR)/k3d_network.lock

$(TOP)/$(KUMA_DIR)/test/k3d/calico.$(K3D_VERSION).yaml:
@mkdir -p $(TOP)/$(KUMA_DIR)/test/k3d
curl --location --fail --silent --retry 5 \
-o $(TOP)/$(KUMA_DIR)/test/k3d/calico.$(K3D_VERSION).yaml \
https://k3d.io/v$(K3D_VERSION)/usage/advanced/calico.yaml

.PHONY: k3d/start
k3d/start: ${KIND_KUBECONFIG_DIR} k3d/network/create
k3d/start: ${KIND_KUBECONFIG_DIR} k3d/network/create \
$(if $(findstring calico,$(K3D_NETWORK_CNI)),$(TOP)/$(KUMA_DIR)/test/k3d/calico.$(K3D_VERSION).yaml)
@echo "PORT_PREFIX=$(PORT_PREFIX)"
@KUBECONFIG=$(KIND_KUBECONFIG) \
$(K3D_BIN) cluster create "$(KIND_CLUSTER_NAME)" $(K3D_CLUSTER_CREATE_OPTS)
Expand Down
Loading

0 comments on commit e7c9b51

Please sign in to comment.