Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebuild containernetworking binaries, so we don't need to create rele… #8909

Merged
merged 7 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cni-plugin/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ report/*.xml
crds.yaml
Makefile.common*
config/
.containernetworking-plugins*
containernetworking-plugins/
32 changes: 25 additions & 7 deletions cni-plugin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ WINFV_SRCFILES=$(shell find win_tests -name '*.go')
# fail if unable to download
CURL=curl -C - -sSf

# Use forked CNI plugin URL and corresponding tagged artifacts.
CNI_VERSION=v1.1.1-calico+go-1.22.3
CNI_ARTIFACTS_URL=https://github.com/projectcalico/containernetworking-plugins/releases/download
FLANNEL_ARTIFACTS_URL=https://github.com/projectcalico/flannel-cni-plugin/releases/download
FLANNEL_VERSION=v1.2.0-flannel2-go1.22.2
Expand Down Expand Up @@ -61,6 +59,7 @@ clean: clean-windows
rm -rf bin $(DEPLOY_CONTAINER_MARKER) pkg/install/install.test
rm -rf config/ dist/
-docker image rm -f $$(docker images $(CNI_PLUGIN_IMAGE) -a -q)
rm -rf containernetworking-plugins .containernetworking-plugins-*

clean-windows: clean-windows-builder
rm -rf $(WINDOWS_BIN) $(WINDOWS_DIST)
Expand Down Expand Up @@ -140,14 +139,33 @@ $(DEPLOY_CONTAINER_FIPS_MARKER): Dockerfile build fetch-cni-bins
$(MAKE) retag-build-images-with-registries VALIDARCHES=$(ARCH) IMAGETAG=latest-fips LATEST_IMAGE_TAG=latest-fips
touch $@


# These are the files that we need to copy from the containernetworking-plugins project to our image.
CN_FILES := host-local portmap loopback tuning bandwidth

CONTAINERNETWORKING_PLUGINS_CLONED=.containernetworking-plugins-$(CNI_VERSION).cloned

$(CONTAINERNETWORKING_PLUGINS_CLONED):
rene-dekker marked this conversation as resolved.
Show resolved Hide resolved
rm -rf containernetworking-plugins .containernetworking-plugins-*.cloned
@$(foreach file,$(CN_FILES),find bin -name $(file) -type f -delete;)
git clone --single-branch --branch $(CNI_VERSION) https://github.com/projectcalico/containernetworking-plugins.git
touch $@

CN_FLAGS=-ldflags "-X github.com/containernetworking/plugins/pkg/utils/buildversion.BuildVersion=$(GIT_VERSION)"

$(BIN)/host-local $(BIN)/loopback $(BIN)/portmap $(BIN)/tuning $(BIN)/bandwidth &: $(CONTAINERNETWORKING_PLUGINS_CLONED)
docker run \
-v $(CURDIR)/containernetworking-plugins:/go/src/github.com/containernetworking/plugins:z \
-e LOCAL_USER_ID=$(LOCAL_USER_ID) -w /go/src/github.com/containernetworking/plugins --rm $(CALICO_BUILD) \
/bin/sh -xe -c ' \
GOFLAGS='-buildvcs=false' CGO_ENABLED=0 GOARCH=$(ARCH) ./build_linux.sh $(CN_FLAGS)'
-mkdir -p $(BIN)
@$(foreach file,$(CN_FILES),cp containernetworking-plugins/bin/$(file) $(BIN);)

.PHONY: fetch-cni-bins fetch-win-cni-bins
fetch-cni-bins: $(BIN)/flannel $(BIN)/loopback $(BIN)/host-local $(BIN)/portmap $(BIN)/tuning $(BIN)/bandwidth
fetch-win-cni-bins: $(WINDOWS_BIN)/flannel.exe

$(BIN)/loopback $(BIN)/host-local $(BIN)/portmap $(BIN)/tuning $(BIN)/bandwidth:
-mkdir -p $(BIN)
$(CURL) -L --retry 5 $(CNI_ARTIFACTS_URL)/$(CNI_VERSION)/cni-plugins-linux-$(subst v7,,$(ARCH))-$(CNI_VERSION).tgz | tar -xz -C $(BIN) ./loopback ./host-local ./portmap ./tuning ./bandwidth

$(BIN)/flannel:
-mkdir -p $(BIN)
$(CURL) -L --retry 5 $(FLANNEL_ARTIFACTS_URL)/$(FLANNEL_VERSION)/cni-plugin-flannel-linux-$(subst v7,,$(ARCH))-$(FLANNEL_VERSION).tgz | tar -xz -C $(BIN) flannel-$(subst v7,,$(ARCH))
Expand Down Expand Up @@ -183,7 +201,7 @@ ut-datastore:
-v $(CERTS_PATH):/home/user/certs \
$(CALICO_BUILD) sh -c '$(GIT_CONFIG_SSH) \
cd /go/src/$(PACKAGE_NAME) && \
ginkgo -cover -r -skipPackage pkg/install $(GINKGO_ARGS)'
ginkgo -cover -r -skipPackage pkg/install,containernetworking-plugins $(GINKGO_ARGS)'
rene-dekker marked this conversation as resolved.
Show resolved Hide resolved

ut-etcd: run-k8s-controller-manager build $(BIN)/host-local
$(MAKE) ut-datastore DATASTORE_TYPE=etcdv3
Expand Down
4 changes: 4 additions & 0 deletions metadata.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ WINDOWS_DIST = dist/windows
WINDOWS_HPC_VERSION ?= v1.0.0
# The Windows versions used as base for Calico Windows images
WINDOWS_VERSIONS ?= 1809 ltsc2022

# The CNI plugin code that will be cloned and rebuilt with this repo's go-build image
# whenever the cni-plugin image is created.
CNI_VERSION=v1.1.1-calico+go-1.22.5