Skip to content

Commit

Permalink
feat: build azure-ipam installer image
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
  • Loading branch information
rbtr authored Oct 30, 2023
1 parent 7e5994d commit 6b26e21
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 2 deletions.
22 changes: 22 additions & 0 deletions .pipelines/pipeline.yaml
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:
azure_ipam_linux_amd64:
arch: amd64
name: azure-ipam
os: linux
azure_ipam_windows2019_amd64:
arch: amd64
name: azure-ipam
os: windows
os_version: ltsc2019
azure_ipam_windows2022_amd64:
arch: amd64
name: azure-ipam
os: windows
os_version: ltsc2022
cni_linux_amd64:
arch: amd64
name: cni
Expand Down Expand Up @@ -239,6 +253,10 @@ stages:
name: "$(BUILD_POOL_NAME_LINUX_ARM64)"
strategy:
matrix:
azure_ipam_linux_arm64:
arch: arm64
name: azure-ipam
os: linux
cni_linux_arm64:
arch: arm64
name: cni
Expand Down Expand Up @@ -312,6 +330,10 @@ stages:
name: "$(BUILD_POOL_NAME_DEFAULT)"
strategy:
matrix:
azure_ipam:
name: azure-ipam
os_versions: ltsc2019 ltsc2022
platforms: linux/amd64 linux/arm64 windows/amd64
cni:
name: cni
os_versions: ltsc2019 ltsc2022
Expand Down
53 changes: 51 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ endif

## Image name definitions.
ACNCLI_IMAGE = acncli
AZURE_IPAM_IMAGE = azure-ipam
CNI_IMAGE = azure-cni
CNI_DROPGZ_IMAGE = cni-dropgz
CNI_DROPGZ_TEST_IMAGE = cni-dropgz-test
Expand All @@ -256,6 +257,7 @@ NPM_IMAGE = azure-npm

## Image platform tags.
ACNCLI_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(ACN_VERSION)
AZURE_IPAM_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(AZURE_IPAM_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)
Expand Down Expand Up @@ -335,12 +337,42 @@ acncli-image-pull: ## pull cni-manager container image.
TAG=$(ACNCLI_PLATFORM_TAG)


# azure-ipam

azure-ipam-image-name: # util target to print the AZURE_IPAM image name.
@echo $(AZURE_IPAM_IMAGE)

azure-ipam-image-name-and-tag: # util target to print the AZURE_IPAM image name and tag.
@echo $(IMAGE_REGISTRY)/$(AZURE_IPAM_IMAGE):$(AZURE_IPAM_PLATFORM_TAG)

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

azure-ipam-image-push: ## push cni container image.
$(MAKE) container-push \
IMAGE=$(AZURE_IPAM_IMAGE) \
TAG=$(AZURE_IPAM_PLATFORM_TAG)

azure-ipam-image-pull: ## pull cni container image.
$(MAKE) container-pull \
IMAGE=$(AZURE_IPAM_IMAGE) \
TAG=$(AZURE_IPAM_PLATFORM_TAG)


# cni

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

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

cni-image: ## build cni container image.
Expand Down Expand Up @@ -554,6 +586,23 @@ acncli-skopeo-archive: ## export tar archive of acncli multiplat container manif
IMAGE=$(ACNCLI_IMAGE) \
TAG=$(ACN_VERSION)

azure-ipam-manifest-build: ## build azure-ipam multiplat container manifest.
$(MAKE) manifest-build \
PLATFORMS="$(PLATFORMS)" \
IMAGE=$(AZURE_IPAM_IMAGE) \
TAG=$(AZURE_IPAM_VERSION) \
OS_VERSIONS="$(OS_VERSIONS)"

azure-ipam-manifest-push: ## push azure-ipam multiplat container manifest
$(MAKE) manifest-push \
IMAGE=$(AZURE_IPAM_IMAGE) \
TAG=$(AZURE_IPAM_VERSION)

azure-ipam-skopeo-archive: ## export tar archive of azure-ipam multiplat container manifest.
$(MAKE) manifest-skopeo-archive \
IMAGE=$(AZURE_IPAM_IMAGE) \
TAG=$(AZURE_IPAM_VERSION)

cni-manifest-build: ## build cni multiplat container manifest.
$(MAKE) manifest-build \
PLATFORMS="$(PLATFORMS)" \
Expand Down
32 changes: 32 additions & 0 deletions azure-ipam/linux.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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-ipam
ARG OS
ARG VERSION
WORKDIR /azure-ipam
COPY ./azure-ipam .
RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-ipam -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" .

FROM mcr.microsoft.com/cbl-mariner/base/core:2.0 AS compressor
ARG OS
WORKDIR /payload
COPY --from=azure-ipam /go/bin/* /payload
COPY --from=azure-ipam /azure-ipam/*.conflist /payload
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
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" ]
32 changes: 32 additions & 0 deletions azure-ipam/windows.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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-ipam
ARG OS
ARG VERSION
WORKDIR /azure-ipam
COPY ./azure-ipam .
RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-ipam -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" .

FROM --platform=linux/${ARCH} mcr.microsoft.com/cbl-mariner/base/core:2.0 AS compressor
ARG OS
WORKDIR /payload
COPY --from=azure-ipam /go/bin/* /payload
COPY --from=azure-ipam /azure-ipam/*.conflist /payload
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" ]

0 comments on commit 6b26e21

Please sign in to comment.