diff --git a/.pipelines/pipeline.yaml b/.pipelines/pipeline.yaml index 1f5c8fb56d..fd8b2222ad 100644 --- a/.pipelines/pipeline.yaml +++ b/.pipelines/pipeline.yaml @@ -157,6 +157,10 @@ stages: arch: amd64 os: linux name: cni-dropgz + cni_dropgz_test_linux_amd64: + arch: amd64 + os: linux + name: cni-dropgz-test cns_linux_amd64: arch: amd64 os: linux @@ -187,6 +191,10 @@ stages: arch: arm64 os: linux name: cni-dropgz + cni_dropgz_test_linux_arm64: + arch: arm64 + os: linux + name: cni-dropgz-test cns_linux_arm64: arch: arm64 os: linux @@ -240,6 +248,9 @@ stages: cni_dropgz: name: cni-dropgz platforms: linux/amd64 linux/arm64 + cni_dropgz_test: + name: cni-dropgz-test + platforms: linux/amd64 linux/arm64 cns: name: cns platforms: linux/amd64 linux/arm64 windows/amd64 diff --git a/Makefile b/Makefile index 5e8cfb4512..e71f97715a 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,7 @@ ACN_VERSION ?= $(shell git describe --exclude "azure-ipam*" --exclude "cni- AZURE_IPAM_VERSION ?= $(notdir $(shell git describe --match "azure-ipam*" --tags --always)) CNI_VERSION ?= $(ACN_VERSION) CNI_DROPGZ_VERSION ?= $(notdir $(shell git describe --match "cni-dropgz*" --tags --always)) +CNI_DROPGZ_TEST_VERSION ?= $(notdir $(shell git describe --match "cni-dropgz-test*" --tags --always)) CNS_VERSION ?= $(ACN_VERSION) NPM_VERSION ?= $(ACN_VERSION) ZAPAI_VERSION ?= $(notdir $(shell git describe --match "zapai*" --tags --always)) @@ -153,6 +154,9 @@ cni-version: ## prints the cni version cni-dropgz-version: ## prints the cni-dropgz version @echo $(CNI_DROPGZ_VERSION) +cni-dropgz-test-version: ## prints the cni-dropgz version + @echo $(CNI_DROPGZ_TEST_VERSION) + cns-version: @echo $(CNS_VERSION) @@ -223,12 +227,14 @@ endif ## Image name definitions. ACNCLI_IMAGE = acncli CNI_DROPGZ_IMAGE = cni-dropgz +CNI_DROPGZ_TEST_IMAGE = cni-dropgz-test CNS_IMAGE = azure-cns NPM_IMAGE = azure-npm ## Image platform tags. ACNCLI_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))-$(ACN_VERSION) CNI_DROPGZ_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))-$(CNI_DROPGZ_VERSION) +CNI_DROPGZ_TEST_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))-$(CNI_DROPGZ_TEST_VERSION) CNS_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))-$(CNS_VERSION) NPM_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))-$(NPM_VERSION) @@ -326,6 +332,32 @@ cni-dropgz-skopeo-export: $(MAKE) skopeo-export \ REF=$(IMAGE_REGISTRY)/$(CNI_DROPGZ_IMAGE):$(CNI_DROPGZ_PLATFORM_TAG) +# cni-dropgz-test + +cni-dropgz-test-image-name: # util target to print the CNI dropgz test image name. + @echo $(CNI_DROPGZ_TEST_IMAGE) + +cni-dropgz-test-image: ## build cni-dropgz-test container image. + $(MAKE) container \ + DOCKERFILE=dropgz/build/cniTest.Dockerfile \ + EXTRA_BUILD_ARGS='--build-arg OS=$(OS)' \ + IMAGE=$(CNI_DROPGZ_TEST_IMAGE) \ + TAG=$(CNI_DROPGZ_TEST_PLATFORM_TAG) + +cni-dropgz-test-image-push: ## push cni-dropgz-test container image. + $(MAKE) container-push \ + IMAGE=$(CNI_DROPGZ_TEST_IMAGE) \ + TAG=$(CNI_DROPGZ_TEST_PLATFORM_TAG) + +cni-dropgz-test-image-pull: ## pull cni-dropgz-test container image. + $(MAKE) container-pull \ + IMAGE=$(CNI_DROPGZ_TEST_IMAGE) \ + TAG=$(CNI_DROPGZ_TEST_PLATFORM_TAG) + +cni-dropgz-test-skopeo-export: + $(MAKE) skopeo-export \ + REF=$(IMAGE_REGISTRY)/$(CNI_DROPGZ_TEST_IMAGE):$(CNI_DROPGZ_TEST_PLATFORM_TAG) + # cns cns-image-name: # util target to print the CNS image name @@ -493,6 +525,22 @@ cni-dropgz-skopeo-archive: ## export tar archive of cni-dropgz multiplat contain IMAGE=$(CNI_DROPGZ_IMAGE) \ TAG=$(CNI_DROPGZ_VERSION) +cni-dropgz-test-manifest-create: ## build cni-dropgz multiplat container manifest. + $(MAKE) manifest-create \ + PLATFORMS="$(PLATFORMS)" \ + IMAGE=$(CNI_DROPGZ_TEST_IMAGE) \ + TAG=$(CNI_DROPGZ_TEST_VERSION) + +cni-dropgz-test-manifest-push: ## push cni-dropgz multiplat container manifest + $(MAKE) manifest-push \ + IMAGE=$(CNI_DROPGZ_TEST_IMAGE) \ + TAG=$(CNI_DROPGZ_TEST_VERSION) + +cni-dropgz-test-skopeo-archive: ## export tar archive of cni-dropgz multiplat container manifest. + $(MAKE) manifest-skopeo-archive \ + IMAGE=$(CNI_DROPGZ_TEST_IMAGE) \ + TAG=$(CNI_DROPGZ_TEST_VERSION) + cns-manifest-create: ## build azure-cns multiplat container manifest. $(MAKE) manifest-create \ PLATFORMS="$(PLATFORMS)" \ diff --git a/dropgz/build/cniTest.Dockerfile b/dropgz/build/cniTest.Dockerfile new file mode 100644 index 0000000000..dea631fb1b --- /dev/null +++ b/dropgz/build/cniTest.Dockerfile @@ -0,0 +1,32 @@ +FROM mcr.microsoft.com/oss/go/microsoft/golang:1.19 AS azure-ipam +ARG VERSION +WORKDIR /azure-ipam +COPY ./azure-ipam . +RUN CGO_ENABLED=0 go build -a -o bin/azure-ipam -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" . + +FROM mcr.microsoft.com/oss/go/microsoft/golang:1.19 AS azure-vnet +ARG VERSION +WORKDIR /azure-container-networking +COPY . . +RUN CGO_ENABLED=0 go build -a -o bin/azure-vnet -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/network/plugin/main.go + +FROM mcr.microsoft.com/cbl-mariner/base/core:2.0 AS compressor +ARG OS +WORKDIR /dropgz +COPY dropgz . +COPY --from=azure-ipam /azure-ipam/*.conflist pkg/embed/fs +COPY --from=azure-ipam /azure-ipam/bin/* pkg/embed/fs +COPY --from=azure-vnet /azure-container-networking/cni/azure-$OS-swift.conflist pkg/embed/fs/azure-swift.conflist +COPY --from=azure-vnet /azure-container-networking/bin/* pkg/embed/fs +RUN cd pkg/embed/fs/ && sha256sum * > sum.txt +RUN gzip --verbose --best --recursive pkg/embed/fs && for f in pkg/embed/fs/*.gz; do mv -- "$f" "${f%%.gz}"; done + +FROM mcr.microsoft.com/oss/go/microsoft/golang:1.19 AS dropgz +ARG VERSION +WORKDIR /dropgz +COPY --from=compressor /dropgz . +RUN CGO_ENABLED=0 go build -a -o bin/dropgz -trimpath -ldflags "-X github.com/Azure/azure-container-networking/dropgz/internal/buildinfo.Version="$VERSION"" -gcflags="-dwarflocationlists=true" main.go + +FROM scratch +COPY --from=dropgz /dropgz/bin/dropgz /dropgz +ENTRYPOINT [ "/dropgz" ] diff --git a/test/integration/manifests/cns/daemonset.yaml b/test/integration/manifests/cns/daemonset.yaml index a0f7e60c16..33e2d112ea 100644 --- a/test/integration/manifests/cns/daemonset.yaml +++ b/test/integration/manifests/cns/daemonset.yaml @@ -83,7 +83,7 @@ spec: fieldPath: spec.nodeName initContainers: - name: init-cni-dropgz - image: acnpublic.azurecr.io/cni-dropgz:v1.4.28-41-g3ecb7fb1 + image: acnpublic.azurecr.io/cni-dropgz-test:latest imagePullPolicy: Always command: ["/dropgz"] volumeMounts: