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

feat: build cni installer image with cni builds #2324

Merged
merged 1 commit into from
Oct 30, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions .pipelines/pipeline.yaml
rbtr marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ stages:
name: "$(BUILD_POOL_NAME_LINUX_AMD64)"
strategy:
matrix:
cni_linux_amd64:
rbtr marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless this gets renamed back to cni-dropgz, which from the PR description it is indicating that it will be,

Instead of deploying a "dropgz:v0.0.4" with unknown (at least, non-obvious) CNI payload versions, we produce a "cni-dropgz:v1.5.11"

we need to add this to the cleanup script regex for acnpublic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will follow up

arch: amd64
name: cni
os: linux
cni_windows2019_amd64:
arch: amd64
name: cni
os: windows
os_version: ltsc2019
cni_windows2022_amd64:
arch: amd64
name: cni
os: windows
os_version: ltsc2022
cni_dropgz_linux_amd64:
arch: amd64
name: cni-dropgz
Expand Down Expand Up @@ -225,6 +239,10 @@ stages:
name: "$(BUILD_POOL_NAME_LINUX_ARM64)"
strategy:
matrix:
cni_linux_arm64:
arch: arm64
name: cni
os: linux
cni_dropgz_linux_arm64:
arch: arm64
name: cni-dropgz
Expand Down Expand Up @@ -294,6 +312,10 @@ stages:
name: "$(BUILD_POOL_NAME_DEFAULT)"
strategy:
matrix:
cni:
name: cni
os_versions: ltsc2019 ltsc2022
platforms: linux/amd64 linux/arm64 windows/amd64
cni_dropgz:
name: cni-dropgz
os_versions: ltsc2019 ltsc2022
Expand Down
100 changes: 76 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ EXE_EXT = .exe
endif

# Interrogate the git repo and set some variables
REPO_ROOT = $(shell git rev-parse --show-toplevel)
REVISION ?= $(shell git rev-parse --short HEAD)
ACN_VERSION ?= $(shell git describe --exclude "azure-ipam*" --exclude "dropgz*" --exclude "zapai*" --tags --always)
AZURE_IPAM_VERSION ?= $(notdir $(shell git describe --match "azure-ipam*" --tags --always))
CNI_VERSION ?= $(ACN_VERSION)
CNI_DROPGZ_VERSION ?= $(notdir $(shell git describe --match "dropgz*" --tags --always))
CNI_DROPGZ_TEST_VERSION ?= $(notdir $(shell git describe --match "dropgz-test*" --tags --always))
CNS_VERSION ?= $(ACN_VERSION)
NPM_VERSION ?= $(ACN_VERSION)
ZAPAI_VERSION ?= $(notdir $(shell git describe --match "zapai*" --tags --always))
REPO_ROOT = $(shell git rev-parse --show-toplevel)
REVISION ?= $(shell git rev-parse --short HEAD)
ACN_VERSION ?= $(shell git describe --exclude "azure-ipam*" --exclude "dropgz*" --exclude "zapai*" --tags --always)
AZURE_IPAM_VERSION ?= $(notdir $(shell git describe --match "azure-ipam*" --tags --always))
CNI_VERSION ?= $(ACN_VERSION)
CNI_DROPGZ_VERSION ?= $(notdir $(shell git describe --match "dropgz*" --tags --always))
CNI_DROPGZ_TEST_VERSION ?= $(notdir $(shell git describe --match "dropgz-test*" --tags --always))
CNS_VERSION ?= $(ACN_VERSION)
NPM_VERSION ?= $(ACN_VERSION)
ZAPAI_VERSION ?= $(notdir $(shell git describe --match "zapai*" --tags --always))
rbtr marked this conversation as resolved.
Show resolved Hide resolved

# Build directories.
AZURE_IPAM_DIR = $(REPO_ROOT)/azure-ipam
Expand Down Expand Up @@ -102,9 +102,10 @@ NPM_ARCHIVE_NAME = azure-npm-$(GOOS)-$(GOARCH)-$(NPM_VERSION).$(ARCHIVE_EXT)
AZURE_IPAM_ARCHIVE_NAME = azure-ipam-$(GOOS)-$(GOARCH)-$(AZURE_IPAM_VERSION).$(ARCHIVE_EXT)

# Image info file names.
CNI_DROPGZ_IMAGE_INFO_FILE = cni-dropgz-$(CNI_DROPGZ_VERSION).txt
CNS_IMAGE_INFO_FILE = azure-cns-$(CNS_VERSION).txt
NPM_IMAGE_INFO_FILE = azure-npm-$(NPM_VERSION).txt
CNI_IMAGE_INFO_FILE = azure-cni-$(CNI_VERSION).txt
CNI_DROPGZ_IMAGE_INFO_FILE = cni-dropgz-$(CNI_DROPGZ_VERSION).txt
CNS_IMAGE_INFO_FILE = azure-cns-$(CNS_VERSION).txt
NPM_IMAGE_INFO_FILE = azure-npm-$(NPM_VERSION).txt

# Docker libnetwork (CNM) plugin v2 image parameters.
CNM_PLUGIN_IMAGE ?= microsoft/azure-vnet-plugin
Expand Down Expand Up @@ -246,19 +247,22 @@ CONTAINER_TRANSPORT = docker
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
ACNCLI_IMAGE = acncli
CNI_IMAGE = azure-cni
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))$(if $(OS_VERSION),-$(OS_VERSION),)-$(ACN_VERSION)
CNI_DROPGZ_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(CNI_DROPGZ_VERSION)
CNI_DROPGZ_TEST_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(CNI_DROPGZ_TEST_VERSION)
CNS_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(CNS_VERSION)
CNS_WINDOWS_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(CNS_VERSION)-$(OS_SKU_WIN)
NPM_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(NPM_VERSION)
ACNCLI_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(ACN_VERSION)
CNI_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(CNI_VERSION)
CNI_WINDOWS_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(CNI_VERSION)-$(OS_SKU_WIN)
CNI_DROPGZ_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(CNI_DROPGZ_VERSION)
CNI_DROPGZ_TEST_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(CNI_DROPGZ_TEST_VERSION)
CNS_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(CNS_VERSION)
CNS_WINDOWS_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(CNS_VERSION)-$(OS_SKU_WIN)
NPM_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(NPM_VERSION)


qemu-user-static: ## Set up the host to run qemu multiplatform container builds.
Expand Down Expand Up @@ -330,6 +334,37 @@ acncli-image-pull: ## pull cni-manager container image.
IMAGE=$(ACNCLI_IMAGE) \
TAG=$(ACNCLI_PLATFORM_TAG)


# cni

cni-image-name: # util target to print the CNI image name.
@echo $(CNI_IMAGE)

cni-image-name-and-tag: # util target to print the CNI image name and tag.
@echo $(IMAGE_REGISTRY)/$(CNI_IMAGE):$(CNI_PLATFORM_TAG)

cni-image: ## build cni container image.
$(MAKE) container \
DOCKERFILE=cni/$(OS).Dockerfile \
IMAGE=$(CNI_IMAGE) \
EXTRA_BUILD_ARGS='--build-arg OS=$(OS) --build-arg ARCH=$(ARCH) --build-arg OS_VERSION=$(OS_VERSION)' \
PLATFORM=$(PLATFORM) \
TAG=$(CNI_PLATFORM_TAG) \
OS=$(OS) \
ARCH=$(ARCH) \
OS_VERSION=$(OS_VERSION)

cni-image-push: ## push cni container image.
$(MAKE) container-push \
IMAGE=$(CNI_IMAGE) \
TAG=$(CNI_PLATFORM_TAG)

cni-image-pull: ## pull cni container image.
$(MAKE) container-pull \
IMAGE=$(CNI_IMAGE) \
TAG=$(CNI_PLATFORM_TAG)


# cni-dropgz

cni-dropgz-image-name: # util target to print the CNI dropgz image name.
Expand Down Expand Up @@ -519,6 +554,23 @@ acncli-skopeo-archive: ## export tar archive of acncli multiplat container manif
IMAGE=$(ACNCLI_IMAGE) \
TAG=$(ACN_VERSION)

cni-manifest-build: ## build cni multiplat container manifest.
$(MAKE) manifest-build \
PLATFORMS="$(PLATFORMS)" \
IMAGE=$(CNI_IMAGE) \
TAG=$(CNI_VERSION) \
OS_VERSIONS="$(OS_VERSIONS)"

cni-manifest-push: ## push cni multiplat container manifest
$(MAKE) manifest-push \
IMAGE=$(CNI_IMAGE) \
TAG=$(CNI_VERSION)

cni-skopeo-archive: ## export tar archive of cni multiplat container manifest.
$(MAKE) manifest-skopeo-archive \
IMAGE=$(CNI_IMAGE) \
TAG=$(CNI_VERSION)

cni-dropgz-manifest-build: ## build cni-dropgz multiplat container manifest.
$(MAKE) manifest-build \
PLATFORMS="$(PLATFORMS)" \
Expand Down
38 changes: 38 additions & 0 deletions cni/linux.Dockerfile
camrynl marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
ARG ARCH
ARG DROPGZ_VERSION=v0.0.12
ARG OS_VERSION
ARG OS

FROM mcr.microsoft.com/oss/go/microsoft/golang:1.21 AS azure-vnet
ARG OS
pjohnst5 marked this conversation as resolved.
Show resolved Hide resolved
ARG VERSION
WORKDIR /azure-container-networking
COPY . .
RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/network/plugin/main.go
RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet-telemetry -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/telemetry/service/telemetrymain.go
RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet-ipam -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/ipam/plugin/main.go
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So does this include azure-vnet-ipam then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting, how is that? What is this /go/bin/azure-vnet-ipam binary? How does it differ from the azure-vnet-ipam?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the legacy (v1) ipam plugin for azure-vnet


FROM mcr.microsoft.com/cbl-mariner/base/core:2.0 AS compressor
ARG OS
WORKDIR /payload
COPY --from=azure-vnet /go/bin/* /payload
COPY --from=azure-vnet /azure-container-networking/cni/azure-$OS.conflist /payload/azure.conflist
COPY --from=azure-vnet /azure-container-networking/cni/azure-$OS-swift.conflist /payload/azure-swift.conflist
COPY --from=azure-vnet /azure-container-networking/cni/azure-$OS-swift-overlay.conflist /payload/azure-swift-overlay.conflist
COPY --from=azure-vnet /azure-container-networking/cni/azure-$OS-swift-overlay-dualstack.conflist /payload/azure-swift-overlay-dualstack.conflist
COPY --from=azure-vnet /azure-container-networking/telemetry/azure-vnet-telemetry.config /payload/azure-vnet-telemetry.config
RUN cd /payload && sha256sum * > sum.txt
RUN gzip --verbose --best --recursive /payload && for f in /payload/*.gz; do mv -- "$f" "${f%%.gz}"; done

FROM mcr.microsoft.com/oss/go/microsoft/golang:1.21 AS dropgz
ARG DROPGZ_VERSION
ARG OS
ARG VERSION
RUN go mod download github.com/azure/azure-container-networking/dropgz@$DROPGZ_VERSION
pjohnst5 marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR /go/pkg/mod/github.com/azure/azure-container-networking/dropgz\@$DROPGZ_VERSION
COPY --from=compressor /payload/* /pkg/embed/fs/
RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/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 /go/bin/dropgz dropgz
ENTRYPOINT [ "dropgz" ]
38 changes: 38 additions & 0 deletions cni/windows.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
ARG ARCH
ARG DROPGZ_VERSION=v0.0.12
ARG OS
ARG OS_VERSION

FROM --platform=linux/${ARCH} mcr.microsoft.com/oss/go/microsoft/golang:1.21 AS azure-vnet
ARG OS
ARG VERSION
WORKDIR /azure-container-networking
COPY . .
RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/network/plugin/main.go
RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet-telemetry -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/telemetry/service/telemetrymain.go
RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet-ipam -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/ipam/plugin/main.go

FROM --platform=linux/${ARCH} mcr.microsoft.com/cbl-mariner/base/core:2.0 AS compressor
ARG OS
WORKDIR /payload
COPY --from=azure-vnet /go/bin/* /payload/
COPY --from=azure-vnet /azure-container-networking/cni/azure-$OS.conflist /payload/azure.conflist
COPY --from=azure-vnet /azure-container-networking/cni/azure-$OS-swift.conflist /payload/azure-swift.conflist
COPY --from=azure-vnet /azure-container-networking/cni/azure-$OS-swift-overlay.conflist /payload/azure-swift-overlay.conflist
COPY --from=azure-vnet /azure-container-networking/cni/azure-$OS-swift-overlay-dualstack.conflist /payload/azure-swift-overlay-dualstack.conflist
COPY --from=azure-vnet /azure-container-networking/telemetry/azure-vnet-telemetry.config /payload/azure-vnet-telemetry.config
RUN cd /payload && sha256sum * > sum.txt
RUN gzip --verbose --best --recursive /payload && for f in /payload/*.gz; do mv -- "$f" "${f%%.gz}"; done

FROM --platform=linux/${ARCH} mcr.microsoft.com/oss/go/microsoft/golang:1.21 AS dropgz
ARG DROPGZ_VERSION
ARG OS
ARG VERSION
RUN go mod download github.com/azure/azure-container-networking/dropgz@$DROPGZ_VERSION
WORKDIR /go/pkg/mod/github.com/azure/azure-container-networking/dropgz\@$DROPGZ_VERSION
COPY --from=compressor /payload/* /pkg/embed/fs/
RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/dropgz -trimpath -ldflags "-X github.com/Azure/azure-container-networking/dropgz/internal/buildinfo.Version="$VERSION"" -gcflags="-dwarflocationlists=true" main.go

FROM mcr.microsoft.com/windows/nanoserver:${OS_VERSION}
COPY --from=dropgz /go/bin/dropgz dropgz
ENTRYPOINT [ "dropgz" ]