Pipeline support for Go submodules versioned independently of root repo (#1533)

* use submodule specific tags

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>

* support separate go submodule versions

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>

* move version and tag responsibilities to the makefile

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>

* update integration tests to use component tags

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>

Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
This commit is contained in:
Evan Baker 2022-09-01 11:35:01 -07:00 коммит произвёл GitHub
Родитель d32a66fc10
Коммит 8888338c62
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
26 изменённых файлов: 291 добавлений и 340 удалений

Просмотреть файл

@ -42,7 +42,7 @@ jobs:
- name: Make NPM image
run: |
make npm-image VERSION=cyclonus PLATFORM=linux/amd64 CONTAINER_BUILDER=docker
make npm-image NPM_PLATFORM_TAG=cyclonus PLATFORM=linux/amd64 CONTAINER_BUILDER=docker
- name: Install Azure NPM
# set the ConfigMap based on the build matrix

2
.github/workflows/cyclonus-netpol-test.yaml поставляемый
Просмотреть файл

@ -42,7 +42,7 @@ jobs:
- name: Make NPM image
run: |
make npm-image VERSION=cyclonus PLATFORM=linux/amd64 CONTAINER_BUILDER=docker
make npm-image NPM_PLATFORM_TAG=cyclonus PLATFORM=linux/amd64 CONTAINER_BUILDER=docker
- name: Install Azure NPM
# set the ConfigMap based on the build matrix

Просмотреть файл

@ -1,25 +0,0 @@
FROM mcr.microsoft.com/oss/mirror/docker.io/library/ubuntu:18.04
RUN apt-get update && apt-get install -y software-properties-common sudo wget apt-utils apt-transport-https curl lsb-release gnupg jq
RUN wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
RUN dpkg -i packages-microsoft-prod.deb
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
RUN curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
RUN apt install -y git python3-pip gcc zip dotnet-sdk-3.1 azure-cli
RUN apt install -y --no-install-recommends clang cmake zlib1g-dev libboost-dev libboost-thread-dev gdb build-essential libssl-dev
RUN pip3 install coverage
RUN echo "deb http://archive.ubuntu.com/ubuntu/ bionic multiverse" | sudo tee -a /etc/apt/sources.list
RUN echo "deb http://archive.ubuntu.com/ubuntu/ bionic universe" | sudo tee -a /etc/apt/sources.list
RUN echo "deb http://archive.ubuntu.com/ubuntu/ bionic main" | sudo tee -a /etc/apt/sources.list
RUN apt-get update && apt-get install -y iptables ipset iproute2 ebtables
RUN wget -qO- https://golang.org/dl/go1.19.linux-amd64.tar.gz | tar zxf - -C /usr/lib/
ENV PATH="/usr/lib/go/bin/:${PATH}"
ENV GOROOT="/usr/lib/go"
ENV GOPATH="/root/go"
ENV PATH="/root/go/bin/:${PATH}"
RUN go get github.com/docker/libnetwork/driverapi
RUN go get github.com/gorilla/mux
RUN go get github.com/jstemmer/go-junit-report
RUN go get github.com/axw/gocov/gocov
RUN go get github.com/AlekSi/gocov-xml
RUN go get -u gopkg.in/matm/v1/gocov-html
RUN go get -u github.com/onsi/ginkgo/ginkgo

Просмотреть файл

@ -12,7 +12,7 @@ steps:
addPipelineData: false
- powershell: |
powershell.exe -command "& { . .\windows.ps1; Retry({${{ parameters.name }}-image windows-${{ parameters.arch }}-${{ parameters.tag }}}) }"
powershell.exe -command "& { . .\build\scripts\windows.ps1; Retry({${{ parameters.name }}-image windows-${{ parameters.arch }}-${{ parameters.tag }}}) }"
name: image_build
displayName: Image Build

Просмотреть файл

@ -2,7 +2,6 @@ parameters:
name: ""
os: ""
arch: ""
tag: ""
steps:
- task: Docker@2
@ -14,35 +13,31 @@ steps:
- script: |
set -e
sudo podman run --rm --privileged multiarch/qemu-user-static --reset -p yes
make qemu-user-static
name: container_env
displayName: Prepare Environment
- script: |
set -e
export PLATFORM_TAG=$(make container-platform-tag TAG=${{ parameters.tag }} PLATFORM=${{ parameters.os }}/${{ parameters.arch }})
make ${{ parameters.name }}-image OS=${{ parameters.os }} ARCH=${{ parameters.arch }} PLATFORM=${{ parameters.os }}/${{ parameters.arch }} TAG=$PLATFORM_TAG
make ${{ parameters.name }}-image OS=${{ parameters.os }} ARCH=${{ parameters.arch }}
name: image_build
displayName: Image Build
retryCountOnTaskFailure: 3
- script: |
set -e
export PLATFORM_TAG=$(make container-platform-tag TAG=${{ parameters.tag }} PLATFORM=${{ parameters.os }}/${{ parameters.arch }})
export REF=$(IMAGE_REGISTRY)/$(make ${{ parameters.name }}-image-name):$PLATFORM_TAG
skopeo copy containers-storage:$REF docker-daemon:$REF
make ${{ parameters.name }}-skopeo-export OS=${{ parameters.os }} ARCH=${{ parameters.arch }}
wget https://github.com/aquasecurity/trivy/releases/download/v0.18.1/trivy_0.18.1_Linux-64bit.tar.gz
tar -zxvf trivy*.tar.gz
mkdir -p ./trivy-cache
sudo ./trivy --exit-code 1 --cache-dir ./trivy-cache --severity HIGH,CRITICAL $REF
name: trivy
displayName: Vulnerability Scan
retryCountOnTaskFailure: 3
- script: |
set -e
export PLATFORM_TAG=$(make container-platform-tag TAG=${{ parameters.tag }} PLATFORM=${{ parameters.os }}/${{ parameters.arch }})
make ${{ parameters.name }}-image-push PLATFORM=${{ parameters.os }}/${{ parameters.arch }} TAG=$PLATFORM_TAG
make ${{ parameters.name }}-image-pull PLATFORM=${{ parameters.os }}/${{ parameters.arch }} TAG=$PLATFORM_TAG
make ${{ parameters.name }}-image-push OS=${{ parameters.os }} ARCH=${{ parameters.arch }}
retryCountOnTaskFailure: 3
name: image_push
displayName: Push Images

Просмотреть файл

@ -1,7 +1,6 @@
parameters:
name: ""
platforms: ""
tag: ""
steps:
- task: Docker@2
@ -13,19 +12,15 @@ steps:
- script: |
set -e
make ${{ parameters.name }}-multiarch-manifest-create PLATFORMS="${{ parameters.platforms }}" TAG=${{ parameters.tag }}
make ${{ parameters.name }}-image-info TAG=${{ parameters.tag }}
make ${{ parameters.name }}-manifest-create PLATFORMS="${{ parameters.platforms }}"
name: manifest_build
displayName: Manifest Build
- script: |
set -e
export IMAGE=$(make ${{ parameters.name }}-image-name)
export TAG=${{ parameters.tag }}
make multiarch-manifest-push IMAGE=$IMAGE TAG=$TAG
make container-pull IMAGE=$IMAGE TAG=$TAG
make ${{ parameters.name }}-manifest-push
mkdir -p $(Build.ArtifactStagingDirectory)/images
skopeo copy --all docker://$IMAGE_REGISTRY/$IMAGE:$TAG oci-archive:$(Build.ArtifactStagingDirectory)/images/$IMAGE-$TAG.tar
make ${{ parameters.name }}-skopeo-archive IMAGE_ARCHIVE_DIR=$(Build.ArtifactStagingDirectory)/images
name: manifest_push
displayName: Manifest Push
@ -36,12 +31,6 @@ steps:
command: "logout"
addPipelineData: false
- task: CopyFiles@2
inputs:
sourceFolder: "output"
targetFolder: $(Build.ArtifactStagingDirectory)
condition: succeeded()
- task: ManifestGeneratorTask@0
displayName: "Add SBOM Generator tool"
inputs:

Просмотреть файл

@ -27,7 +27,7 @@ jobs:
mkdir -p '$(GOPATH)/pkg'
BUILD_NUMBER=$(Build.BuildNumber)
RG=e2e-$(echo "npm-`date "+%Y-%m-%d-%S"`")
TAG=$(make version)-conformance-test
TAG=$(make npm-version)
echo "Resource group: $RG"
echo "Image tag: $TAG"
@ -57,7 +57,6 @@ jobs:
name: $(name)
os: $(os)
arch: $(arch)
tag: $(TAG)
- job: containerize_windows
dependsOn: [setup]
@ -76,7 +75,6 @@ jobs:
parameters:
name: $(name)
arch: $(arch)
tag: $(TAG)
- job: k8se2e
displayName: "Build Kubernetes Test Suite"

Просмотреть файл

@ -23,6 +23,8 @@ stages:
BUILD_NUMBER=$(Build.BuildNumber)
echo "##vso[task.setvariable variable=StorageID;isOutput=true]$(echo ${BUILD_NUMBER//./-})"
echo "##vso[task.setvariable variable=Tag;isOutput=true]$(make version)"
echo "##vso[task.setvariable variable=cniVersion;isOutput=true]$(make cni-version)"
echo "##vso[task.setvariable variable=npmVersion;isOutput=true]$(make npm-version)"
cat /etc/os-release
uname -a
sudo chown -R $(whoami):$(whoami) .
@ -90,13 +92,12 @@ stages:
- job: build
displayName: Build Binaries
variables:
TAG: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
STORAGE_ID: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.StorageID'] ]
pool:
name: "$(BUILD_POOL_NAME_DEFAULT)"
steps:
- script: |
make all-binaries-platforms VERSION=$(TAG)
make all-binaries-platforms
name: "BuildAllPlatformBinaries"
displayName: "Build all platform binaries"
@ -144,8 +145,6 @@ stages:
jobs:
- job: containerize
displayName: Build Images
variables:
TAG: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
pool:
name: "$(BUILD_POOL_NAME_DEFAULT)"
strategy:
@ -188,7 +187,6 @@ stages:
name: $(name)
os: $(os)
arch: $(arch)
tag: $(TAG)
- job: containerize_windows
displayName: Build Images
variables:
@ -213,13 +211,10 @@ stages:
- stage: publish
displayName: Publish Multiarch Manifests
dependsOn:
- setup
- containerize
jobs:
- job: manifest
displayName: Compile Manifests
variables:
TAG: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
pool:
name: "$(BUILD_POOL_NAME_DEFAULT)"
strategy:
@ -241,7 +236,6 @@ stages:
parameters:
name: $(name)
platforms: $(platforms)
tag: $(TAG)
- template: singletenancy/cilium/cilium-e2e-job-template.yaml
parameters:

Просмотреть файл

@ -28,9 +28,9 @@ stages:
GOPATH: "$(Agent.TempDirectory)/go" # Go workspace path
GOBIN: "$(GOPATH)/bin" # Go binaries path
acnPath: "$(GOPATH)/src/github.com/Azure/azure-container-networking"
Tag: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
CommitHash: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.CommitHash'] ]
StorageID: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.StorageID'] ]
cniVersion: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.cniVersion'] ]
steps:
- task: DownloadPipelineArtifact@2
inputs:
@ -39,15 +39,14 @@ stages:
targetPath: $(Pipeline.Workspace)
- bash: |
ls -lah
export CNI_URL=https://$(ARTIFACT_STORAGE).blob.core.windows.net/acn-$(StorageID)/azure-vnet-cni-${{ parameters.clusterDefinitionCniBuildOS }}-amd64-$(Tag)${{ parameters.clusterDefinitionCniBuildExt }}
export CNI_URL=https://$(ARTIFACT_STORAGE).blob.core.windows.net/acn-$(StorageID)/azure-vnet-cni-${{ parameters.clusterDefinitionCniBuildOS }}-amd64-$(cniVersion)${{ parameters.clusterDefinitionCniBuildExt }}
export CNI_TYPE=${{ parameters.clusterDefinitionCniTypeKey }}
echo CNI type is $CNI_TYPE
echo Tag is $(Tag)
echo CNI_URL is $CNI_URL
echo Config: '${{ parameters.clusterDefinition }}'
cat '${{ parameters.clusterDefinition }}'
cat '${{ parameters.clusterDefinition }}' | jq --arg cnikey $CNI_TYPE --arg cniurl $CNI_URL '.properties.orchestratorProfile.kubernetesConfig[$cnikey]= $cniurl' > '${{ parameters.clusterDefinition }}'.tmp
cat '${{ parameters.clusterDefinition }}'.tmp | jq --arg tag $(Tag) '.properties.orchestratorProfile.kubernetesConfig.azureCNIVersion = $tag' > '${{ parameters.clusterDefinition }}'
cat '${{ parameters.clusterDefinition }}'.tmp | jq --arg ver $(cniVersion) '.properties.orchestratorProfile.kubernetesConfig.azureCNIVersion = $ver' > '${{ parameters.clusterDefinition }}'
mv '${{ parameters.clusterDefinition }}'.tmp '${{ parameters.clusterDefinition }}'
echo "Running E2E tests against a cluster built with the following API model:"
cp ${{ parameters.clusterDefinition }} clusterDefinition.json

Просмотреть файл

@ -29,9 +29,10 @@ stages:
GOBIN: "$(GOPATH)/bin" # Go binaries path
modulePath: "$(GOPATH)/src/github.com/Azure/aks-engine"
acnPath: "$(GOPATH)/src/github.com/Azure/azure-container-networking"
Tag: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
CommitHash: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.CommitHash'] ]
StorageID: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.StorageID'] ]
cniVersion: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.cniVersion'] ]
npmVersion: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.npmVersion'] ]
steps:
- template: e2e-step-template.yaml
parameters:
@ -40,3 +41,5 @@ stages:
clusterDefinitionCniTypeKey: ${{ parameters.clusterDefinitionCniTypeKey }}
clusterDefinitionCniBuildOS: ${{ parameters.clusterDefinitionCniBuildOS }}
clusterDefinitionCniBuildExt: ${{ parameters.clusterDefinitionCniBuildExt }}
cniVersion: $(cniVersion)
npmVersion: $(npmVersion)

Просмотреть файл

@ -4,6 +4,8 @@ parameters:
clusterDefinitionCniTypeKey: ""
clusterDefinitionCniBuildOS: ""
clusterDefinitionCniBuildExt: ""
cniVersion: ""
npmVersion: ""
steps:
- checkout: none
@ -63,16 +65,16 @@ steps:
- bash: |
ls -lah
export CNI_URL=https://$(ARTIFACT_STORAGE).blob.core.windows.net/acn-$(StorageID)/azure-vnet-cni-${{ parameters.clusterDefinitionCniBuildOS }}-amd64-$(Tag)${{ parameters.clusterDefinitionCniBuildExt }}
cd $(modulePath)
export CNI_URL=https://$(ARTIFACT_STORAGE).blob.core.windows.net/acn-$(StorageID)/azure-vnet-cni-${{ parameters.clusterDefinitionCniBuildOS }}-amd64-${{ parameters.cniVersion }}${{ parameters.clusterDefinitionCniBuildExt }}
export CNI_TYPE=${{ parameters.clusterDefinitionCniTypeKey }}
echo CNI type is $CNI_TYPE
echo Tag is $(Tag)
echo CNI_URL is $CNI_URL
echo Config: '${{ parameters.clusterDefinition }}'
cat '${{ parameters.clusterDefinition }}'
cat '${{ parameters.clusterDefinition }}' | jq --arg cnikey $CNI_TYPE --arg cniurl $CNI_URL '.properties.orchestratorProfile.kubernetesConfig[$cnikey]= $cniurl' > '${{ parameters.clusterDefinition }}'.tmp
cat '${{ parameters.clusterDefinition }}'.tmp | jq --arg tag $(Tag) '.properties.orchestratorProfile.kubernetesConfig.azureCNIVersion = $tag' > '${{ parameters.clusterDefinition }}'
cat '${{ parameters.clusterDefinition }}' | jq --arg npmimage $IMAGE_REGISTRY/azure-npm:$(Tag) '.properties.orchestratorProfile.kubernetesConfig.addons[0].containers[0].image = $npmimage' > '${{ parameters.clusterDefinition }}'.tmp
cat '${{ parameters.clusterDefinition }}'.tmp | jq --arg ver ${{ parameters.cniVersion }} '.properties.orchestratorProfile.kubernetesConfig.azureCNIVersion = $ver' > '${{ parameters.clusterDefinition }}'
cat '${{ parameters.clusterDefinition }}' | jq --arg ver $IMAGE_REGISTRY/azure-npm:${{ parameters.npmVersion }} '.properties.orchestratorProfile.kubernetesConfig.addons[0].containers[0].image = $ver' > '${{ parameters.clusterDefinition }}'.tmp
if [ "${{ parameters.Name }}" == "windows_20_22_e2e" ]; then
if [[ -z $(WS2022_IMG_SUBSCRIPTION) || -z $(WS2022_IMG_VERSION) ]]; then
echo WS2022 Gallery/Image Subscription and Version not set, using defaults in cniWindows2022.json
@ -86,7 +88,6 @@ steps:
echo "Running E2E tests against a cluster built with the following API model:"
cp ${{ parameters.clusterDefinition }} clusterDefinition.json
displayName: Configure AKS-Engine
workingDirectory: "$(modulePath)"
- task: AzureCLI@1
inputs:
@ -141,4 +142,4 @@ steps:
scriptLocation: 'inlineScript'
inlineScript: |
echo "Deleting: $(RESOURCE_GROUP)"
az group delete -n $(RESOURCE_GROUP) --yes
az group delete -n $(RESOURCE_GROUP) --yes

Просмотреть файл

@ -21,7 +21,6 @@ stages:
variables:
GOPATH: "$(Agent.TempDirectory)/go" # Go workspace path
GOBIN: "$(GOPATH)/bin" # Go binaries path
Tag: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
modulePath: "$(GOPATH)/src/github.com/Azure/azure-container-networking"
steps:
- template: e2e-step-template.yaml

Просмотреть файл

@ -20,10 +20,6 @@ steps:
name: "GoEnv"
displayName: "Set up the Go environment"
- bash: |
echo $(Tag)
displayName: Echo Tag
- task: AzureCLI@1
inputs:
azureSubscription: $(AZURE_TEST_AGENT_SERVICE_CONNECTION)
@ -61,7 +57,7 @@ steps:
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl cluster-info
kubectl get po -owide -A
sudo -E env "PATH=$PATH" VERSION=$(Tag) INSTALL_CNS=true INSTALL_AZURE_VNET=true make test-integration
sudo -E env "PATH=$PATH" make test-integration CNS_VERSION=$(make cns-version) CNI_DROPGZ_VERSION=$(make cni-dropgz-version) INSTALL_CNS=true INSTALL_AZURE_VNET=true
retryCountOnTaskFailure: 3
name: "aksswifte2e"
displayName: "Run AKS Swift E2E"

Просмотреть файл

@ -21,7 +21,6 @@ stages:
variables:
GOPATH: "$(Agent.TempDirectory)/go" # Go workspace path
GOBIN: "$(GOPATH)/bin" # Go binaries path
Tag: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
modulePath: "$(GOPATH)/src/github.com/Azure/azure-container-networking"
steps:
- template: cilium-e2e-step-template.yaml

Просмотреть файл

@ -20,10 +20,6 @@ steps:
name: "GoEnv"
displayName: "Set up the Go environment"
- bash: |
echo $(Tag)
displayName: Echo Tag
- task: AzureCLI@1
inputs:
azureSubscription: $(AZURE_TEST_AGENT_SERVICE_CONNECTION)
@ -75,7 +71,7 @@ steps:
- script: |
echo "Start Azilium E2E Tests"
kubectl get po -owide -A
sudo -E env "PATH=$PATH" VERSION=$(Tag) INSTALL_CNS=true INSTALL_AZILIUM=true make test-integration
sudo -E env "PATH=$PATH" make test-integration CNS_VERSION=$(make cns-version) CNI_DROPGZ_VERSION=$(make cni-dropgz-version) INSTALL_CNS=true INSTALL_AZILIUM=true
retryCountOnTaskFailure: 3
name: "aziliumTest"
displayName: "Run Azilium E2E"

406
Makefile
Просмотреть файл

@ -1,9 +1,9 @@
.DEFAULT_GOAL := help
# Default platform commands
SHELL=/bin/bash
MKDIR := mkdir -p
RMDIR := rm -rf
SHELL = /bin/bash
MKDIR := mkdir -p
RMDIR := rm -rf
ARCHIVE_CMD = tar -czvf
# Default platform extensions
@ -16,21 +16,32 @@ RMDIR := powershell.exe -NoProfile -Command Remove-Item -Recurse -Force
endif
# Build defaults.
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
GOOSES ?= "linux windows" # To override at the cli do: GOOSES="\"darwin bsd\""
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
GOOSES ?= "linux windows" # To override at the cli do: GOOSES="\"darwin bsd\""
GOARCHES ?= "amd64 arm64" # To override at the cli do: GOARCHES="\"ppc64 mips\""
WINVER ?= "10.0.20348.643"
WINVER ?= "10.0.20348.643"
# Windows specific extensions
# set these based on the GOOS, not the OS
ifeq ($(GOOS),windows)
ARCHIVE_CMD = zip -9lq
ARCHIVE_EXT = zip
EXE_EXT = .exe
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 "cni-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 "cni-dropgz*" --tags --always))
CNS_VERSION ?= $(ACN_VERSION)
NPM_VERSION ?= $(ACN_VERSION)
ZAPAI_VERSION ?= $(notdir $(shell git describe --match "zapai*" --tags --always))
# Build directories.
REPO_ROOT = $(shell git rev-parse --show-toplevel)
AZURE_IPAM_DIR = $(REPO_ROOT)/azure-ipam
CNM_DIR = $(REPO_ROOT)/cnm/plugin
CNI_NET_DIR = $(REPO_ROOT)/cni/network/plugin
@ -65,37 +76,35 @@ CNS_AI_PATH=$(ACN_PACKAGE_PATH)/cns/logger.aiMetadata
NPM_AI_PATH=$(ACN_PACKAGE_PATH)/npm.aiMetadata
# Tool paths
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
GOCOV := $(TOOLS_BIN_DIR)/gocov
GOCOV_XML := $(TOOLS_BIN_DIR)/gocov-xml
GOFUMPT := $(TOOLS_BIN_DIR)/gofumpt
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
GOCOV := $(TOOLS_BIN_DIR)/gocov
GOCOV_XML := $(TOOLS_BIN_DIR)/gocov-xml
GOFUMPT := $(TOOLS_BIN_DIR)/gofumpt
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint
GO_JUNIT_REPORT := $(TOOLS_BIN_DIR)/go-junit-report
MOCKGEN := $(TOOLS_BIN_DIR)/mockgen
MOCKGEN := $(TOOLS_BIN_DIR)/mockgen
# Archive file names.
CNM_ARCHIVE_NAME = azure-vnet-cnm-$(GOOS)-$(GOARCH)-$(VERSION).$(ARCHIVE_EXT)
CNI_ARCHIVE_NAME = azure-vnet-cni-$(GOOS)-$(GOARCH)-$(VERSION).$(ARCHIVE_EXT)
ACNCLI_ARCHIVE_NAME = acncli-$(GOOS)-$(GOARCH)-$(VERSION).$(ARCHIVE_EXT)
CNI_MULTITENANCY_ARCHIVE_NAME = azure-vnet-cni-multitenancy-$(GOOS)-$(GOARCH)-$(VERSION).$(ARCHIVE_EXT)
CNI_MULTITENANCY_TRANSPARENT_VLAN_ARCHIVE_NAME = azure-vnet-cni-multitenancy-transparent-vlan-$(GOOS)-$(GOARCH)-$(VERSION).$(ARCHIVE_EXT)
CNI_SWIFT_ARCHIVE_NAME = azure-vnet-cni-swift-$(GOOS)-$(GOARCH)-$(VERSION).$(ARCHIVE_EXT)
CNI_OVERLAY_ARCHIVE_NAME = azure-vnet-cni-overlay-$(GOOS)-$(GOARCH)-$(VERSION).$(ARCHIVE_EXT)
CNI_BAREMETAL_ARCHIVE_NAME = azure-vnet-cni-baremetal-$(GOOS)-$(GOARCH)-$(VERSION).$(ARCHIVE_EXT)
CNS_ARCHIVE_NAME = azure-cns-$(GOOS)-$(GOARCH)-$(VERSION).$(ARCHIVE_EXT)
NPM_ARCHIVE_NAME = azure-npm-$(GOOS)-$(GOARCH)-$(VERSION).$(ARCHIVE_EXT)
NPM_IMAGE_INFO_FILE = azure-npm-$(VERSION).txt
CNIDROPGZ_IMAGE_ARCHIVE_NAME = cni-dropgz-$(GOOS)-$(GOARCH)-$(VERSION).$(ARCHIVE_EXT)
CNIDROPGZ_IMAGE_INFO_FILE = cni-dropgz-$(VERSION).txt
CNS_IMAGE_INFO_FILE = azure-cns-$(VERSION).txt
ACNCLI_ARCHIVE_NAME = acncli-$(GOOS)-$(GOARCH)-$(ACN_VERSION).$(ARCHIVE_EXT)
CNI_ARCHIVE_NAME = azure-vnet-cni-$(GOOS)-$(GOARCH)-$(CNI_VERSION).$(ARCHIVE_EXT)
CNI_MULTITENANCY_ARCHIVE_NAME = azure-vnet-cni-multitenancy-$(GOOS)-$(GOARCH)-$(CNI_VERSION).$(ARCHIVE_EXT)
CNI_MULTITENANCY_TRANSPARENT_VLAN_ARCHIVE_NAME = azure-vnet-cni-multitenancy-transparent-vlan-$(GOOS)-$(GOARCH)-$(CNI_VERSION).$(ARCHIVE_EXT)
CNI_SWIFT_ARCHIVE_NAME = azure-vnet-cni-swift-$(GOOS)-$(GOARCH)-$(CNI_VERSION).$(ARCHIVE_EXT)
CNI_OVERLAY_ARCHIVE_NAME = azure-vnet-cni-overlay-$(GOOS)-$(GOARCH)-$(CNI_VERSION).$(ARCHIVE_EXT)
CNI_BAREMETAL_ARCHIVE_NAME = azure-vnet-cni-baremetal-$(GOOS)-$(GOARCH)-$(CNI_VERSION).$(ARCHIVE_EXT)
CNM_ARCHIVE_NAME = azure-vnet-cnm-$(GOOS)-$(GOARCH)-$(ACN_VERSION).$(ARCHIVE_EXT)
CNS_ARCHIVE_NAME = azure-cns-$(GOOS)-$(GOARCH)-$(CNS_VERSION).$(ARCHIVE_EXT)
NPM_ARCHIVE_NAME = azure-npm-$(GOOS)-$(GOARCH)-$(NPM_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
# Docker libnetwork (CNM) plugin v2 image parameters.
CNM_PLUGIN_IMAGE ?= microsoft/azure-vnet-plugin
CNM_PLUGIN_ROOTFS = azure-vnet-plugin-rootfs
REVISION ?= $(shell git rev-parse --short HEAD)
VERSION ?= $(shell git describe --exclude "azure-ipam*" --exclude "cni-dropgz*" --exclude "zapai*" --tags --always --dirty)
# Default target
all-binaries-platforms: ## Make all platform binaries
@for goos in "$(GOOSES)"; do \
@ -123,90 +132,131 @@ azure-cnms: azure-cnms-binary cnms-archive
azure-npm: azure-npm-binary npm-archive
##@ Versioning
revision: ## print the current git revision
@echo $(REVISION)
version: ## prints the root version
@echo $(ACN_VERSION)
acncli-version: version
azure-ipam-version: ## prints the azure-ipam version
@echo $(AZURE_IPAM_VERSION)
cni-version: ## prints the cni version
@echo $(CNI_VERSION)
cni-dropgz-version: ## prints the cni-dropgz version
@echo $(CNI_DROPGZ_VERSION)
cns-version:
@echo $(CNS_VERSION)
npm-version:
@echo $(NPM_VERSION)
zapai-version: ## prints the zapai version
@echo $(ZAPAI_VERSION)
##@ Binaries
# Build the delegated IPAM plugin binary.
azure-ipam-binary:
cd $(AZURE_IPAM_DIR) && CGO_ENABLED=0 go build -v -o $(AUZRE_IPAM_BUILD_DIR)/azure-ipam$(EXE_EXT) -ldflags "-X main.version=$(VERSION)" -gcflags="-dwarflocationlists=true"
cd $(AZURE_IPAM_DIR) && CGO_ENABLED=0 go build -v -o $(AUZRE_IPAM_BUILD_DIR)/azure-ipam$(EXE_EXT) -ldflags "-X main.version=$(AZURE_IPAM_VERSION)" -gcflags="-dwarflocationlists=true"
# Build the Azure CNM binary.
cnm-binary:
cd $(CNM_DIR) && CGO_ENABLED=0 go build -v -o $(CNM_BUILD_DIR)/azure-vnet-plugin$(EXE_EXT) -ldflags "-X main.version=$(VERSION)" -gcflags="-dwarflocationlists=true"
cd $(CNM_DIR) && CGO_ENABLED=0 go build -v -o $(CNM_BUILD_DIR)/azure-vnet-plugin$(EXE_EXT) -ldflags "-X main.version=$(ACN_VERSION)" -gcflags="-dwarflocationlists=true"
# Build the Azure CNI network binary.
azure-vnet-binary:
cd $(CNI_NET_DIR) && CGO_ENABLED=0 go build -v -o $(CNI_BUILD_DIR)/azure-vnet$(EXE_EXT) -ldflags "-X main.version=$(VERSION)" -gcflags="-dwarflocationlists=true"
cd $(CNI_NET_DIR) && CGO_ENABLED=0 go build -v -o $(CNI_BUILD_DIR)/azure-vnet$(EXE_EXT) -ldflags "-X main.version=$(CNI_VERSION)" -gcflags="-dwarflocationlists=true"
# Build the Azure CNI IPAM binary.
azure-vnet-ipam-binary:
cd $(CNI_IPAM_DIR) && CGO_ENABLED=0 go build -v -o $(CNI_BUILD_DIR)/azure-vnet-ipam$(EXE_EXT) -ldflags "-X main.version=$(VERSION)" -gcflags="-dwarflocationlists=true"
cd $(CNI_IPAM_DIR) && CGO_ENABLED=0 go build -v -o $(CNI_BUILD_DIR)/azure-vnet-ipam$(EXE_EXT) -ldflags "-X main.version=$(CNI_VERSION)" -gcflags="-dwarflocationlists=true"
# Build the Azure CNI IPAMV6 binary.
azure-vnet-ipamv6-binary:
cd $(CNI_IPAMV6_DIR) && CGO_ENABLED=0 go build -v -o $(CNI_BUILD_DIR)/azure-vnet-ipamv6$(EXE_EXT) -ldflags "-X main.version=$(VERSION)" -gcflags="-dwarflocationlists=true"
cd $(CNI_IPAMV6_DIR) && CGO_ENABLED=0 go build -v -o $(CNI_BUILD_DIR)/azure-vnet-ipamv6$(EXE_EXT) -ldflags "-X main.version=$(CNI_VERSION)" -gcflags="-dwarflocationlists=true"
# Build the Azure CNI telemetry binary.
azure-vnet-telemetry-binary:
cd $(CNI_TELEMETRY_DIR) && CGO_ENABLED=0 go build -v -o $(CNI_BUILD_DIR)/azure-vnet-telemetry$(EXE_EXT) -ldflags "-X main.version=$(VERSION) -X $(CNI_AI_PATH)=$(CNI_AI_ID)" -gcflags="-dwarflocationlists=true"
cd $(CNI_TELEMETRY_DIR) && CGO_ENABLED=0 go build -v -o $(CNI_BUILD_DIR)/azure-vnet-telemetry$(EXE_EXT) -ldflags "-X main.version=$(CNI_VERSION) -X $(CNI_AI_PATH)=$(CNI_AI_ID)" -gcflags="-dwarflocationlists=true"
# Build the Azure CLI network binary.
acncli-binary:
cd $(ACNCLI_DIR) && CGO_ENABLED=0 go build -v -o $(ACNCLI_BUILD_DIR)/acn$(EXE_EXT) -ldflags "-X main.version=$(VERSION)" -gcflags="-dwarflocationlists=true"
cd $(ACNCLI_DIR) && CGO_ENABLED=0 go build -v -o $(ACNCLI_BUILD_DIR)/acn$(EXE_EXT) -ldflags "-X main.version=$(ACN_VERSION)" -gcflags="-dwarflocationlists=true"
# Build the Azure CNS binary.
azure-cns-binary:
cd $(CNS_DIR) && CGO_ENABLED=0 go build -v -o $(CNS_BUILD_DIR)/azure-cns$(EXE_EXT) -ldflags "-X main.version=$(VERSION) -X $(CNS_AI_PATH)=$(CNS_AI_ID) -X $(CNI_AI_PATH)=$(CNI_AI_ID)" -gcflags="-dwarflocationlists=true"
cd $(CNS_DIR) && CGO_ENABLED=0 go build -v -o $(CNS_BUILD_DIR)/azure-cns$(EXE_EXT) -ldflags "-X main.version=$(CNS_VERSION) -X $(CNS_AI_PATH)=$(CNS_AI_ID) -X $(CNI_AI_PATH)=$(CNI_AI_ID)" -gcflags="-dwarflocationlists=true"
# Build the Azure NPM binary.
azure-npm-binary:
cd $(CNI_TELEMETRY_DIR) && CGO_ENABLED=0 go build -v -o $(NPM_BUILD_DIR)/azure-vnet-telemetry$(EXE_EXT) -ldflags "-X main.version=$(VERSION)" -gcflags="-dwarflocationlists=true"
cd $(NPM_DIR) && CGO_ENABLED=0 go build -v -o $(NPM_BUILD_DIR)/azure-npm$(EXE_EXT) -ldflags "-X main.version=$(VERSION) -X $(NPM_AI_PATH)=$(NPM_AI_ID)" -gcflags="-dwarflocationlists=true"
cd $(CNI_TELEMETRY_DIR) && CGO_ENABLED=0 go build -v -o $(NPM_BUILD_DIR)/azure-vnet-telemetry$(EXE_EXT) -ldflags "-X main.version=$(NPM_VERSION)" -gcflags="-dwarflocationlists=true"
cd $(NPM_DIR) && CGO_ENABLED=0 go build -v -o $(NPM_BUILD_DIR)/azure-npm$(EXE_EXT) -ldflags "-X main.version=$(NPM_VERSION) -X $(NPM_AI_PATH)=$(NPM_AI_ID)" -gcflags="-dwarflocationlists=true"
##@ Containers
ACNCLI_IMAGE = acncli
CNIDROPGZ_IMAGE = cni-dropgz
CNS_IMAGE = azure-cns
NPM_IMAGE = azure-npm
TAG ?= $(VERSION)
## Common variables for all containers.
IMAGE_REGISTRY ?= acnpublic.azurecr.io
OS ?= $(GOOS)
ARCH ?= $(GOARCH)
PLATFORM ?= $(GOOS)/$(GOARCH)
CONTAINER_BUILDER = buildah
PLATFORM ?= $(OS)/$(ARCH)
CONTAINER_BUILDER ?= buildah
CONTAINER_RUNTIME ?= podman
# prefer buildah, if available, but fall back to docker if that binary is not in the path.
ifeq (, $(shell which $(CONTAINER_BUILDER)))
CONTAINER_BUILDER = docker
endif
# prefer podman, if available, but fall back to docker if that binary is not in the path.
ifeq (, $(shell which $(CONTAINER_RUNTIME)))
CONTAINER_RUNTIME = docker
endif
## This section is for building individual container images.
## Image name definitions.
ACNCLI_IMAGE = acncli
CNI_DROPGZ_IMAGE = cni-dropgz
CNS_IMAGE = azure-cns
NPM_IMAGE = azure-npm
container-platform-tag: # util target to print the container tag
@echo $(subst /,-,$(PLATFORM))-$(TAG)
## Image platform tags.
ACNCLI_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))-$(ACN_VERSION)
CNI_DROPGZ_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))-$(CNI_DROPGZ_VERSION)
CNS_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))-$(CNS_VERSION)
NPM_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))-$(NPM_VERSION)
containerize-buildah: # util target to build container images using buildah. do not invoke directly.
qemu-user-static: ## Set up the host to run qemu multiplatform container builds.
sudo $(CONTAINER_RUNTIME) run --rm --privileged multiarch/qemu-user-static --reset -p yes
## Reusable build targets for building individual container images.
container-buildah: # util target to build container images using buildah. do not invoke directly.
buildah bud \
--jobs 16 \
--platform $(PLATFORM) \
-f $(DOCKERFILE) \
--build-arg VERSION=$(VERSION) $(EXTRA_BUILD_ARGS) \
--build-arg VERSION=$(TAG) $(EXTRA_BUILD_ARGS) \
-t $(IMAGE_REGISTRY)/$(IMAGE):$(TAG) \
.
containerize-docker: # util target to build container images using docker buildx. do not invoke directly.
container-docker: # util target to build container images using docker buildx. do not invoke directly.
docker buildx build \
--platform $(PLATFORM) \
-f $(DOCKERFILE) \
--build-arg VERSION=$(VERSION) $(EXTRA_BUILD_ARGS) \
--build-arg VERSION=$(TAG) $(EXTRA_BUILD_ARGS) \
-t $(IMAGE_REGISTRY)/$(IMAGE):$(TAG) \
.
container-tag-test: # util target to retag an image with -test suffix. do not invoke directly.
$(CONTAINER_BUILDER) tag \
$(IMAGE_REGISTRY)/$(IMAGE):$(TAG) \
$(IMAGE_REGISTRY)/$(IMAGE):$(TAG)-test
container: # util target to build container images. do not invoke directly.
$(MAKE) container-$(CONTAINER_BUILDER)
container-push: # util target to publish container image. do not invoke directly.
$(CONTAINER_BUILDER) push \
@ -216,126 +266,117 @@ container-pull: # util target to pull container image. do not invoke directly.
$(CONTAINER_BUILDER) pull \
$(IMAGE_REGISTRY)/$(IMAGE):$(TAG)
container-info: # util target to write container info file. do not invoke directly.
# these commands need to be root due to some ongoing perms issues in the pipeline.
sudo mkdir -p $(IMAGE_DIR)
sudo chown -R $$(whoami) $(IMAGE_DIR)
sudo chmod -R 777 $(IMAGE_DIR)
skopeo-export: # util target to copy a container from containers-storage to the docker daemon.
skopeo copy \
containers-storage:$(REF) \
docker-daemon:$(REF)
## Build specific container images.
# acncli
acncli-image-name: # util target to print the CNI manager image name.
@echo $(ACNCLI_IMAGE)
acncli-image: ## build cni-manager container image.
$(MAKE) containerize-$(CONTAINER_BUILDER) \
PLATFORM=$(PLATFORM) \
$(MAKE) container \
DOCKERFILE=tools/acncli/Dockerfile \
REGISTRY=$(IMAGE_REGISTRY) \
IMAGE=$(ACNCLI_IMAGE) \
TAG=$(TAG)
acncli-image-info: # util target to write cni-manager container info file.
$(MAKE) container-info IMAGE=$(ACNCLI_IMAGE) TAG=$(TAG) FILE=$(ACNCLI_IMAGE_INFO_FILE)
TAG=$(ACNCLI_PLATFORM_TAG)
acncli-image-push: ## push cni-manager container image.
$(MAKE) container-push \
PLATFORM=$(PLATFORM) \
REGISTRY=$(IMAGE_REGISTRY) \
IMAGE=$(ACNCLI_IMAGE) \
TAG=$(TAG)
TAG=$(ACNCLI_PLATFORM_TAG)
acncli-image-pull: ## pull cni-manager container image.
$(MAKE) container-pull \
PLATFORM=$(PLATFORM) \
REGISTRY=$(IMAGE_REGISTRY) \
IMAGE=$(ACNCLI_IMAGE) \
TAG=$(TAG)
TAG=$(ACNCLI_PLATFORM_TAG)
acncli-skopeo-export:
$(MAKE) skopeo-export \
REF=$(IMAGE_REGISTRY)/$(ACNCLI_IMAGE):$(ACNCLI_PLATFORM_TAG)
# cni-dropgz
cni-dropgz-image-name: # util target to print the CNI dropgz image name.
@echo $(CNIDROPGZ_IMAGE)
@echo $(CNI_DROPGZ_IMAGE)
cni-dropgz-image: ## build cni-dropgz container image.
$(MAKE) containerize-$(CONTAINER_BUILDER) \
PLATFORM=$(PLATFORM) \
$(MAKE) container \
DOCKERFILE=dropgz/build/cni.Dockerfile \
REGISTRY=$(IMAGE_REGISTRY) \
IMAGE=$(CNIDROPGZ_IMAGE) \
EXTRA_BUILD_ARGS='--build-arg OS=$(OS) --build-arg ARCH=$(ARCH)' \
TAG=$(TAG)
cni-dropgz-image-info: # util target to write cni-dropgz container info file.
$(MAKE) container-info IMAGE=$(CNIDROPGZ_IMAGE) TAG=$(TAG) FILE=$(CNIDROPGZ_IMAGE_INFO_FILE)
IMAGE=$(CNI_DROPGZ_IMAGE) \
TAG=$(CNI_DROPGZ_PLATFORM_TAG)
cni-dropgz-image-push: ## push cni-dropgz container image.
$(MAKE) container-push \
PLATFORM=$(PLATFORM) \
REGISTRY=$(IMAGE_REGISTRY) \
IMAGE=$(CNIDROPGZ_IMAGE) \
TAG=$(TAG)
IMAGE=$(CNI_DROPGZ_IMAGE) \
TAG=$(CNI_DROPGZ_PLATFORM_TAG)
cni-dropgz-image-pull: ## pull cni-dropgz container image.
$(MAKE) container-pull \
PLATFORM=$(PLATFORM) \
REGISTRY=$(IMAGE_REGISTRY) \
IMAGE=$(CNIDROPGZ_IMAGE) \
TAG=$(TAG)
IMAGE=$(CNI_DROPGZ_IMAGE) \
TAG=$(CNI_DROPGZ_PLATFORM_TAG)
cni-dropgz-skopeo-export:
$(MAKE) skopeo-export \
REF=$(IMAGE_REGISTRY)/$(CNI_DROPGZ_IMAGE):$(CNI_DROPGZ_PLATFORM_TAG)
# cns
cns-image-name: # util target to print the CNS image name
@echo $(CNS_IMAGE)
cns-image: ## build cns container image.
$(MAKE) containerize-$(CONTAINER_BUILDER) \
PLATFORM=$(PLATFORM) \
$(MAKE) container \
DOCKERFILE=cns/Dockerfile \
REGISTRY=$(IMAGE_REGISTRY) \
IMAGE=$(CNS_IMAGE) \
EXTRA_BUILD_ARGS='--build-arg CNS_AI_PATH=$(CNS_AI_PATH) --build-arg CNS_AI_ID=$(CNS_AI_ID)' \
TAG=$(TAG)
cns-image-info: # util target to write cns container info file.
$(MAKE) container-info IMAGE=$(CNS_IMAGE) TAG=$(TAG) FILE=$(CNS_IMAGE_INFO_FILE)
TAG=$(CNS_PLATFORM_TAG)
cns-image-push: ## push cns container image.
$(MAKE) container-push \
PLATFORM=$(PLATFORM) \
REGISTRY=$(IMAGE_REGISTRY) \
IMAGE=$(CNS_IMAGE) \
TAG=$(TAG)
TAG=$(CNS_PLATFORM_TAG)
cns-image-pull: ## pull cns container image.
$(MAKE) container-pull \
PLATFORM=$(PLATFORM) \
REGISTRY=$(IMAGE_REGISTRY) \
IMAGE=$(CNS_IMAGE) \
TAG=$(TAG)
TAG=$(CNS_PLATFORM_TAG)
cns-skopeo-export:
$(MAKE) skopeo-export \
REF=$(IMAGE_REGISTRY)/$(CNS_IMAGE):$(CNS_PLATFORM_TAG)
# npm
npm-image-name: # util target to print the NPM image name
@echo $(NPM_IMAGE)
npm-image: ## build the npm container image.
$(MAKE) containerize-$(CONTAINER_BUILDER) \
PLATFORM=$(PLATFORM) \
$(MAKE) container-$(CONTAINER_BUILDER) \
DOCKERFILE=npm/Dockerfile \
REGISTRY=$(IMAGE_REGISTRY) \
IMAGE=$(NPM_IMAGE) \
EXTRA_BUILD_ARGS='--build-arg NPM_AI_PATH=$(NPM_AI_PATH) --build-arg NPM_AI_ID=$(NPM_AI_ID)' \
TAG=$(TAG)
npm-image-info: # util target to write npm container info file.
$(MAKE) container-info IMAGE=$(NPM_IMAGE) TAG=$(TAG) FILE=$(NPM_IMAGE_INFO_FILE)
TAG=$(NPM_PLATFORM_TAG)
npm-image-push: ## push npm container image.
$(MAKE) container-push \
PLATFORM=$(PLATFORM) \
REGISTRY=$(IMAGE_REGISTRY) \
IMAGE=$(NPM_IMAGE) \
TAG=$(TAG)
TAG=$(NPM_PLATFORM_TAG)
npm-image-pull: ## pull cns container image.
$(MAKE) container-pull \
PLATFORM=$(PLATFORM) \
REGISTRY=$(IMAGE_REGISTRY) \
IMAGE=$(NPM_IMAGE) \
TAG=$(TAG)
TAG=$(NPM_PLATFORM_TAG)
npm-skopeo-export:
$(MAKE) skopeo-export \
REF=$(IMAGE_REGISTRY)/$(NPM_IMAGE):$(NPM_PLATFORM_TAG)
## can probably be combined with above with a GOOS.Dockerfile change?
# Build the windows cns image
@ -344,30 +385,30 @@ cns-image-windows:
docker build \
--no-cache \
-f cns/windows.Dockerfile \
-t $(IMAGE_REGISTRY)/$(CNS_IMAGE)-win:$(TAG) \
--build-arg VERSION=$(TAG) \
-t $(IMAGE_REGISTRY)/$(CNS_IMAGE)-win:$(CNS_PLATFORM_TAG) \
--build-arg VERSION=$(CNS_VERSION) \
--build-arg CNS_AI_PATH=$(CNS_AI_PATH) \
--build-arg CNS_AI_ID=$(CNS_AI_ID) \
.
echo $(CNS_IMAGE)-win:$(TAG) > $(IMAGE_DIR)/$(CNS_IMAGE_INFO_FILE)
echo $(CNS_IMAGE)-win:$(CNS_VERSION) > $(IMAGE_DIR)/$(CNS_IMAGE_INFO_FILE)
## Legacy
# Build the Azure CNM plugin image, installable with "docker plugin install".
azure-cnm-plugin-image: azure-cnm-plugin ## build the azure-cnm plugin container image.
docker images -q $(CNM_PLUGIN_ROOTFS):$(TAG) > cid
docker images -q $(CNM_PLUGIN_ROOTFS):$(ACN_VERSION) > cid
docker build --no-cache \
-f Dockerfile.cnm \
-t $(CNM_PLUGIN_ROOTFS):$(TAG) \
-t $(CNM_PLUGIN_ROOTFS):$(ACN_VERSION) \
--build-arg CNM_BUILD_DIR=$(CNM_BUILD_DIR) \
.
$(eval CID := `cat cid`)
docker rmi $(CID) || true
# Create a container using the image and export its rootfs.
docker create $(CNM_PLUGIN_ROOTFS):$(TAG) > cid
docker create $(CNM_PLUGIN_ROOTFS):$(ACN_VERSION) > cid
$(eval CID := `cat cid`)
$(MKDIR) $(OUTPUT_DIR)/$(CID)/rootfs
docker export $(CID) | tar -x -C $(OUTPUT_DIR)/$(CID)/rootfs
@ -378,17 +419,19 @@ azure-cnm-plugin-image: azure-cnm-plugin ## build the azure-cnm plugin container
chgrp -R docker $(OUTPUT_DIR)/$(CID)
# Create the plugin.
docker plugin rm $(CNM_PLUGIN_IMAGE):$(TAG) || true
docker plugin create $(CNM_PLUGIN_IMAGE):$(TAG) $(OUTPUT_DIR)/$(CID)
docker plugin rm $(CNM_PLUGIN_IMAGE):$(ACN_VERSION) || true
docker plugin create $(CNM_PLUGIN_IMAGE):$(ACN_VERSION) $(OUTPUT_DIR)/$(CID)
# Cleanup temporary files.
rm -rf $(OUTPUT_DIR)/$(CID)
rm cid
## This section is for building multi-arch/os container image manifests.
## Reusable targets for building multiplat container image manifests.
multiarch-manifest-create: # util target to compose multiarch container manifests from os/arch images.
IMAGE_ARCHIVE_DIR ?= $(shell pwd)
manifest-create: # util target to compose multiarch container manifests from platform specific images.
$(CONTAINER_BUILDER) manifest create $(IMAGE_REGISTRY)/$(IMAGE):$(TAG)
$(foreach PLATFORM,$(PLATFORMS), \
$(if $(filter $(PLATFORM),windows/amd64), \
@ -396,32 +439,78 @@ multiarch-manifest-create: # util target to compose multiarch container manifest
, \
$(CONTAINER_BUILDER) manifest add $(IMAGE_REGISTRY)/$(IMAGE):$(TAG) docker://$(IMAGE_REGISTRY)/$(IMAGE):$(subst /,-,$(PLATFORM))-$(TAG);))
multiarch-manifest-push: # util target to push multiarch container manifest.
manifest-push: # util target to push multiarch container manifest.
$(CONTAINER_BUILDER) manifest push --all $(IMAGE_REGISTRY)/$(IMAGE):$(TAG) docker://$(IMAGE_REGISTRY)/$(IMAGE):$(TAG)
acncli-multiarch-manifest-create: ## build acncli multi-arch container manifest.
$(MAKE) multiarch-manifest-create \
manifest-skopeo-archive: # util target to export tar archive of multiarch container manifest.
skopeo copy --all docker://$(IMAGE_REGISTRY)/$(IMAGE):$(TAG) oci-archive:$(IMAGE_ARCHIVE_DIR)/$(IMAGE)-$(TAG).tar
## Build specific multiplat images.
acncli-manifest-create: ## build acncli multiplat container manifest.
$(MAKE) manifest-create \
PLATFORMS="$(PLATFORMS)" \
IMAGE=$(ACNCLI_IMAGE) \
TAG=$(TAG)
TAG=$(ACN_VERSION)
cni-dropgz-multiarch-manifest-create: ## build cni-dropgz multi-arch container manifest.
$(MAKE) multiarch-manifest-create \
acncli-manifest-push: ## push acncli multiplat container manifest
$(MAKE) manifest-push \
IMAGE=$(ACNCLI_IMAGE) \
TAG=$(ACN_VERSION)
acncli-skopeo-archive: ## export tar archive of acncli multiplat container manifest.
$(MAKE) manifest-skopeo-archive \
IMAGE=$(ACNCLI_IMAGE) \
TAG=$(ACN_VERSION)
cni-dropgz-manifest-create: ## build cni-dropgz multiplat container manifest.
$(MAKE) manifest-create \
PLATFORMS="$(PLATFORMS)" \
IMAGE=$(CNIDROPGZ_IMAGE) \
TAG=$(TAG)
IMAGE=$(CNI_DROPGZ_IMAGE) \
TAG=$(CNI_DROPGZ_VERSION)
cns-multiarch-manifest-create: ## build azure-cns multi-arch container manifest.
$(MAKE) multiarch-manifest-create \
cni-dropgz-manifest-push: ## push cni-dropgz multiplat container manifest
$(MAKE) manifest-push \
IMAGE=$(CNI_DROPGZ_IMAGE) \
TAG=$(CNI_DROPGZ_VERSION)
cni-dropgz-skopeo-archive: ## export tar archive of cni-dropgz multiplat container manifest.
$(MAKE) manifest-skopeo-archive \
IMAGE=$(CNI_DROPGZ_IMAGE) \
TAG=$(CNI_DROPGZ_VERSION)
cns-manifest-create: ## build azure-cns multiplat container manifest.
$(MAKE) manifest-create \
PLATFORMS="$(PLATFORMS)" \
IMAGE=$(CNS_IMAGE) \
TAG=$(TAG)
TAG=$(CNS_VERSION)
npm-multiarch-manifest-create: ## build azure-npm multi-arch container manifest.
$(MAKE) multiarch-manifest-create \
cns-manifest-push: ## push cns multiplat container manifest
$(MAKE) manifest-push \
IMAGE=$(CNS_IMAGE) \
TAG=$(CNS_VERSION)
cns-skopeo-archive: ## export tar archive of cns multiplat container manifest.
$(MAKE) manifest-skopeo-archive \
IMAGE=$(CNS_IMAGE) \
TAG=$(CNS_VERSION)
npm-manifest-create: ## build azure-npm multiplat container manifest.
$(MAKE) manifest-create \
PLATFORMS="$(PLATFORMS)" \
IMAGE=$(NPM_IMAGE) \
TAG=$(TAG)
TAG=$(NPM_VERSION)
npm-manifest-push: ## push multiplat container manifest
$(MAKE) manifest-push \
IMAGE=$(NPM_IMAGE) \
TAG=$(NPM_VERSION)
npm-skopeo-archive: ## export tar archive of multiplat container manifest.
$(MAKE) manifest-skopeo-archive \
IMAGE=$(NPM_IMAGE) \
TAG=$(NPM_VERSION)
########################### Archives ################################
@ -497,17 +586,6 @@ ifeq ($(GOOS),linux)
cd $(NPM_BUILD_DIR) && $(ARCHIVE_CMD) $(NPM_ARCHIVE_NAME) azure-npm$(EXE_EXT)
endif
########################### Tasks ###################################
# Release tag
.PHONY: release
release:
./scripts/semver-release.sh
# Publish the Azure CNM plugin image to a Docker registry.
.PHONY: publish-azure-cnm-plugin-image
publish-azure-cnm-plugin-image:
docker plugin push $(CNM_PLUGIN_IMAGE):$(VERSION)
##@ Utils
@ -535,6 +613,7 @@ fmt: $(GOFUMPT) ## run gofumpt on $FMT_PKG (default "cni cns npm").
workspace: ## Set up the Go workspace.
go work init
go work use .
go work use ./azure-ipam
go work use ./build/tools
go work use ./dropgz
go work use ./zapai
@ -551,7 +630,9 @@ test-all: ## run all unit tests.
test-integration: ## run all integration tests.
go test -buildvcs=false -timeout 1h -coverpkg=./... -race -covermode atomic -coverprofile=coverage.out -tags=integration ./test/integration...
CNI_DROPGZ_VERSION=$(CNI_DROPGZ_VERSION) \
CNS_VERSION=$(CNS_VERSION) \
go test -buildvcs=false -timeout 1h -coverpkg=./... -race -covermode atomic -coverprofile=coverage.out -tags=integration ./test/integration...
test-cyclonus: ## run the cyclonus test for npm.
cd test/cyclonus && bash ./test-cyclonus.sh
@ -565,7 +646,6 @@ test-extended-cyclonus: ## run the cyclonus test for npm.
cd test/cyclonus && bash ./test-cyclonus.sh extended
cd ..
.PHONY: kind
kind:
kind create cluster --config ./test/kind/kind.yaml
@ -578,13 +658,7 @@ $(REPO_ROOT)/.git/hooks/pre-push:
install-hooks: $(REPO_ROOT)/.git/hooks/pre-push ## installs git hooks
setup: tools install-hooks ## performs common required repo setup
revision: ## print the current git revision
@echo $(REVISION)
version: ## prints the version
@echo $(VERSION)
setup: tools install-hooks workspace ## performs common required repo setup
##@ Tools

Просмотреть файл

Просмотреть файл

@ -72,6 +72,7 @@ swift-up: rg-up net-up ## Brings up a swift cluster $name in $SUB/$REGION
--network-plugin azure \
--vnet-subnet-id /subscriptions/$(SUB)/resourceGroups/$(GROUP)/providers/Microsoft.Network/virtualNetworks/$(VNET)/subnets/nodenet \
--pod-subnet-id /subscriptions/$(SUB)/resourceGroups/$(GROUP)/providers/Microsoft.Network/virtualNetworks/$(VNET)/subnets/podnet \
--generate-ssh-keys \
--yes
@$(MAKE) set-kubeconf

Просмотреть файл

@ -1,5 +1,4 @@
//go:build integration
// +build integration
package k8s

Просмотреть файл

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package k8s

Просмотреть файл

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package k8s

Просмотреть файл

@ -1,34 +1,27 @@
//go:build integration
// +build integration
package k8s
import (
"context"
"fmt"
"log"
"os"
"runtime/debug"
"strconv"
"testing"
v1 "k8s.io/api/apps/v1"
"k8s.io/client-go/kubernetes"
)
const (
exitFail = 1
envTag = "VERSION"
envInstallCNI = "INSTALL_CNI"
envCNIDropgzVersion = "CNI_DROPGZ_VERSION"
envCNSVersion = "CNS_VERSION"
envInstallCNS = "INSTALL_CNS"
envInstallAzilium = "INSTALL_AZILIUM"
envInstallAzureVnet = "INSTALL_AZURE_VNET"
// relative azure-cni-manager path
cniDaemonSetPath = "manifests/cni/manager.yaml"
cniLabelSelector = "acn=azure-cni-manager"
// relative cns manifest paths
cnsManifestFolder = "manifests/cns"
cnsDaemonSetPath = cnsManifestFolder + "/daemonset.yaml"
@ -48,7 +41,6 @@ func TestMain(m *testing.M) {
var (
err error
exitCode int
clientset *kubernetes.Clientset
cnicleanup func() error
cnscleanup func() error
)
@ -74,28 +66,16 @@ func TestMain(m *testing.M) {
os.Exit(exitCode)
}()
if clientset, err = mustGetClientset(); err != nil {
clientset, err := mustGetClientset()
if err != nil {
return
}
ctx := context.Background()
if installopt := os.Getenv(envInstallCNI); installopt != "" {
// create dirty cni-manager ds
if installCNI, err := strconv.ParseBool(installopt); err == nil && installCNI == true {
if cnicleanup, err = installCNIManagerDaemonset(ctx, clientset, os.Getenv(envTag), logDir); err != nil {
log.Print(err)
exitCode = 2
return
}
}
} else {
log.Printf("Env %v not set to true, skipping", envInstallCNI)
}
if installopt := os.Getenv(envInstallCNS); installopt != "" {
// create dirty cns ds
if installCNS, err := strconv.ParseBool(installopt); err == nil && installCNS == true {
if cnscleanup, err = installCNSDaemonset(ctx, clientset, os.Getenv(envTag), logDir); err != nil {
if cnscleanup, err = installCNSDaemonset(ctx, clientset, logDir); err != nil {
log.Print(err)
exitCode = 2
return
@ -108,23 +88,18 @@ func TestMain(m *testing.M) {
exitCode = m.Run()
}
func installCNSDaemonset(ctx context.Context, clientset *kubernetes.Clientset, imageTag, logDir string) (func() error, error) {
var (
err error
cns v1.DaemonSet
)
if imageTag == "" {
return nil, fmt.Errorf("Azure CNS image tag not set")
}
func installCNSDaemonset(ctx context.Context, clientset *kubernetes.Clientset, logDir string) (func() error, error) {
cniDropgzVersion := os.Getenv(envCNIDropgzVersion)
cnsVersion := os.Getenv(envCNSVersion)
// setup daemonset
if cns, err = mustParseDaemonSet(cnsDaemonSetPath); err != nil {
cns, err := mustParseDaemonSet(cnsDaemonSetPath)
if err != nil {
return nil, err
}
image, _ := parseImageString(cns.Spec.Template.Spec.Containers[0].Image)
cns.Spec.Template.Spec.Containers[0].Image = getImageString(image, imageTag)
cns.Spec.Template.Spec.Containers[0].Image = getImageString(image, cnsVersion)
// check environment scenario
log.Printf("Checking environment scenario")
@ -132,7 +107,7 @@ func installCNSDaemonset(ctx context.Context, clientset *kubernetes.Clientset, i
if azureVnetScenario, err := strconv.ParseBool(installBool1); err == nil && azureVnetScenario == true {
log.Printf("Env %v set to true, deploy azure-vnet", envInstallAzureVnet)
initImage, _ := parseImageString(cns.Spec.Template.Spec.InitContainers[0].Image)
cns.Spec.Template.Spec.InitContainers[0].Image = getImageString(initImage, imageTag)
cns.Spec.Template.Spec.InitContainers[0].Image = getImageString(initImage, cniDropgzVersion)
cns.Spec.Template.Spec.InitContainers[0].Args = []string{"deploy", "azure-vnet", "-o", "/opt/cni/bin/azure-vnet", "azure-swift.conflist", "-o", "/etc/cni/net.d/10-azure.conflist"}
}
} else {
@ -143,7 +118,7 @@ func installCNSDaemonset(ctx context.Context, clientset *kubernetes.Clientset, i
if aziliumScenario, err := strconv.ParseBool(installBool2); err == nil && aziliumScenario == true {
log.Printf("Env %v set to true, deploy azure-ipam and cilium-cni", envInstallAzilium)
initImage, _ := parseImageString(cns.Spec.Template.Spec.InitContainers[0].Image)
cns.Spec.Template.Spec.InitContainers[0].Image = getImageString(initImage, imageTag)
cns.Spec.Template.Spec.InitContainers[0].Image = getImageString(initImage, cniDropgzVersion)
cns.Spec.Template.Spec.InitContainers[0].Args = []string{"deploy", "azure-ipam", "-o", "/opt/cni/bin/azure-ipam", "azilium.conflist", "-o", "/etc/cni/net.d/05-cilium.conflist", "cilium-cni", "-o", "/opt/cni/bin/cilium-cni"}
}
} else {
@ -185,45 +160,3 @@ func installCNSDaemonset(ctx context.Context, clientset *kubernetes.Clientset, i
return cleanupds, nil
}
func installCNIManagerDaemonset(ctx context.Context, clientset *kubernetes.Clientset, imageTag, logDir string) (func() error, error) {
var (
err error
cni v1.DaemonSet
)
if imageTag == "" {
return nil, fmt.Errorf("No image tag specified, set using the VERSION environmental variable")
}
if cni, err = mustParseDaemonSet(cniDaemonSetPath); err != nil {
return nil, err
}
// set the custom image tag and install
image, _ := parseImageString(cni.Spec.Template.Spec.Containers[0].Image)
cni.Spec.Template.Spec.Containers[0].Image = getImageString(image, imageTag)
cniDaemonsetClient := clientset.AppsV1().DaemonSets(cni.Namespace)
log.Printf("Installing CNI with image %s", cni.Spec.Template.Spec.Containers[0].Image)
if err = mustCreateDaemonset(ctx, cniDaemonsetClient, cni); err != nil {
return nil, err
}
if err = waitForPodsRunning(ctx, clientset, cni.Namespace, cniLabelSelector); err != nil {
return nil, err
}
cleanupds := func() error {
if err := exportLogsByLabelSelector(ctx, clientset, cni.Namespace, cniLabelSelector, logDir); err != nil {
return err
}
if err := mustDeleteDaemonset(ctx, cniDaemonsetClient, cni); err != nil {
return err
}
return nil
}
return cleanupds, nil
}

Просмотреть файл

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package k8s

Просмотреть файл

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package k8s

Просмотреть файл

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package k8s

Просмотреть файл

@ -1,4 +1,4 @@
// +build integration
//go:build integration
package k8s