Skip to content
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
31 changes: 31 additions & 0 deletions .pipelines/containers/container-template-windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
parameters:
name: ""
arch: ""
tag: ""

steps:
- task: Docker@2
displayName: Login
inputs:
containerRegistry: $(ACR_SERVICE_CONNECTION)
command: 'login'
addPipelineData: false

- powershell: |
powershell.exe -command "& { . .\windows.ps1; Retry({${{ parameters.name }}-image windows-${{ parameters.arch }}-${{ parameters.tag }}}) }"
name: image_build
displayName: Image Build

- powershell: |
$registry = "acnpublic.azurecr.io"
docker push $registry/azure-${{ parameters.name }}:windows-${{ parameters.arch }}-${{ parameters.tag }}
name: image_push
displayName: Image Push
retryCountOnTaskFailure: 3

- task: Docker@2
displayName: Logout
inputs:
containerRegistry: $(ACR_SERVICE_CONNECTION)
command: 'logout'
addPipelineData: false
9 changes: 4 additions & 5 deletions .pipelines/containers/manifest-template.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
parameters:
name: ""
oses: ""
arches: ""
platforms: ""
tag: ""

steps:
Expand All @@ -14,15 +13,15 @@ steps:

- script: |
set -e
make ${{ parameters.name }}-multiarch-manifest-create OSES="${{ parameters.oses }}" ARCHES="${{ parameters.arches }}" TAG=${{ parameters.tag }}
make ${{ parameters.name }}-multiarch-manifest-create PLATFORMS="${{ parameters.platforms }}" TAG=${{ parameters.tag }}
make ${{ parameters.name }}-image-info TAG=${{ parameters.tag }}
name: manifest_build
displayName: Manifest Build

- script: |
set -e
make multiarch-manifest-push REGISTRY=$IMAGE_REGISTRY IMAGE=$(make ${{ parameters.name }}-image-name) TAG=${{ parameters.tag }}
make container-pull REGISTRY=$IMAGE_REGISTRY IMAGE=$(make ${{ parameters.name }}-image-name) TAG=${{ parameters.tag }}
make multiarch-manifest-push IMAGE=$(make ${{ parameters.name }}-image-name) TAG=${{ parameters.tag }}
make container-pull IMAGE=$(make ${{ parameters.name }}-image-name) TAG=${{ parameters.tag }}
name: manifest_push
displayName: Manifest Push

Expand Down
30 changes: 25 additions & 5 deletions .pipelines/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ stages:
condition: always()

- stage: test
displayName: Test
displayName: Test ACN
dependsOn:
- setup
jobs:
Expand Down Expand Up @@ -136,8 +136,6 @@ stages:
- publish: ./test/apimodels/
artifact: clusterdefinitions

- template: windows-image.yaml

Comment on lines -139 to -140
Copy link
Collaborator

Choose a reason for hiding this comment

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

😍

- stage: containerize
displayName: Build Images
dependsOn:
Expand Down Expand Up @@ -183,6 +181,26 @@ stages:
os: $(os)
arch: $(arch)
tag: $(TAG)
- job: containerize_windows
displayName: Build Images
variables:
TAG: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.Tag'] ]
pool:
name: "$(BUILD_POOL_NAME_DEFAULT_WINDOWS)"
strategy:
matrix:
cns_windows_amd64:
arch: amd64
name: cns
npm_windows_amd64:
arch: amd64
name: npm
steps:
- template: containers/container-template-windows.yaml
parameters:
name: $(name)
arch: $(arch)
tag: $(TAG)

- stage: publish
displayName: Publish Multiarch Manifests
Expand All @@ -200,16 +218,18 @@ stages:
matrix:
cni-manager:
name: cni-manager
platforms: linux/amd64 linux/arm64
cns:
name: cns
platforms: linux/amd64 linux/arm64 windows/amd64
npm:
name: npm
platforms: linux/amd64 linux/arm64 windows/amd64
steps:
- template: containers/manifest-template.yaml
parameters:
name: $(name)
oses: linux
arches: amd64 arm64
platforms: $(platforms)
tag: $(TAG)

- template: singletenancy/aks-swift/e2e-job-template.yaml
Expand Down
56 changes: 0 additions & 56 deletions .pipelines/windows-image.yaml

This file was deleted.

36 changes: 17 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ 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"

# Windows specific extensions
ifeq ($(GOOS),windows)
Expand Down Expand Up @@ -180,29 +181,29 @@ containerize-buildah: # util target to build container images using buildah. do
--platform $(PLATFORM) \
-f $(DOCKERFILE) \
--build-arg VERSION=$(VERSION) $(EXTRA_BUILD_ARGS) \
-t $(REGISTRY)/$(IMAGE):$(TAG) \
-t $(IMAGE_REGISTRY)/$(IMAGE):$(TAG) \
.

containerize-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) \
-t $(REGISTRY)/$(IMAGE):$(TAG) \
-t $(IMAGE_REGISTRY)/$(IMAGE):$(TAG) \
.

container-tag-test: # util target to retag an image with -test suffix. do not invoke directly.
$(CONTAINER_BUILDER) tag \
$(REGISTRY)/$(IMAGE):$(TAG) \
$(REGISTRY)/$(IMAGE):$(TAG)-test
$(IMAGE_REGISTRY)/$(IMAGE):$(TAG) \
$(IMAGE_REGISTRY)/$(IMAGE):$(TAG)-test

container-push: # util target to publish container image. do not invoke directly.
$(CONTAINER_BUILDER) push \
$(REGISTRY)/$(IMAGE):$(TAG)
$(IMAGE_REGISTRY)/$(IMAGE):$(TAG)

container-pull: # util target to pull container image. do not invoke directly.
$(CONTAINER_BUILDER) pull \
$(REGISTRY)/$(IMAGE):$(TAG)
$(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.
Expand Down Expand Up @@ -350,34 +351,31 @@ azure-cnm-plugin-image: azure-cnm-plugin ## build the azure-cnm plugin container
## This section is for building multi-arch/os container image manifests.

multiarch-manifest-create: # util target to compose multiarch container manifests from os/arch images.
$(CONTAINER_BUILDER) manifest create \
$(REGISTRY)/$(IMAGE):$(TAG) \
$(foreach OS,$(OSES),$(foreach ARCH,$(ARCHES),$(REGISTRY)/$(IMAGE):$(OS)-$(ARCH)-$(TAG)))
$(CONTAINER_BUILDER) manifest create $(IMAGE_REGISTRY)/$(IMAGE):$(TAG)
$(foreach PLATFORM,$(PLATFORMS), \
$(if $(filter $(PLATFORM),windows/amd64), \
$(CONTAINER_BUILDER) manifest add --os-version=$(WINVER) $(IMAGE_REGISTRY)/$(IMAGE):$(TAG) docker://$(IMAGE_REGISTRY)/$(IMAGE):$(subst /,-,$(PLATFORM))-$(TAG); \
, \
$(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.
$(CONTAINER_BUILDER) manifest push $(REGISTRY)/$(IMAGE):$(TAG) docker://$(REGISTRY)/$(IMAGE):$(TAG)
$(CONTAINER_BUILDER) manifest push --all $(IMAGE_REGISTRY)/$(IMAGE):$(TAG) docker://$(IMAGE_REGISTRY)/$(IMAGE):$(TAG)

cni-manager-multiarch-manifest-create: ## build cni-manager multi-arch container manifest.
$(MAKE) multiarch-manifest-create \
OSES="$(OSES)" \
ARCHES="$(ARCHES)" \
REGISTRY=$(IMAGE_REGISTRY) \
PLATFORMS="$(PLATFORMS)" \
IMAGE=$(CNI_IMAGE) \
TAG=$(TAG)

cns-multiarch-manifest-create: ## build azure-cns multi-arch container manifest.
$(MAKE) multiarch-manifest-create \
OSES="$(OSES)" \
ARCHES="$(ARCHES)" \
REGISTRY=$(IMAGE_REGISTRY) \
PLATFORMS="$(PLATFORMS)" \
IMAGE=$(CNS_IMAGE) \
TAG=$(TAG)

npm-multiarch-manifest-create: ## build azure-npm multi-arch container manifest.
$(MAKE) multiarch-manifest-create \
OSES="$(OSES)" \
ARCHES="$(ARCHES)" \
REGISTRY=$(IMAGE_REGISTRY) \
PLATFORMS="$(PLATFORMS)" \
IMAGE=$(NPM_IMAGE) \
TAG=$(TAG)

Expand Down
4 changes: 2 additions & 2 deletions cns/windows.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build cns
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.18 AS builder
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.18-windowsservercore-ltsc2022 AS builder
# Build args
ARG VERSION
ARG CNS_AI_PATH
Expand All @@ -14,7 +14,7 @@ COPY . .
RUN $Env:CGO_ENABLED=0; go build -v -o /usr/local/bin/azure-cns.exe -ldflags """-X main.version=${env:VERSION} -X ${env:CNS_AI_PATH}=${env:CNS_AI_ID}""" -gcflags="-dwarflocationlists=true" ./cns/service

# Copy into final image
FROM mcr.microsoft.com/windows/nanoserver:1809
FROM mcr.microsoft.com/windows/servercore:ltsc2022
COPY --from=builder /usr/local/bin/azure-cns.exe \
/usr/local/bin/azure-cns.exe

Expand Down
File renamed without changes.
17 changes: 16 additions & 1 deletion windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,25 @@ function npm-image {

if ($null -eq $env:VERSION) { $env:VERSION = $args[0] }
docker build `
-f npm/Dockerfile.windows `
-f npm/windows.Dockerfile `
-t acnpublic.azurecr.io/azure-npm:$env:VERSION `
--build-arg VERSION=$env:VERSION `
--build-arg NPM_AI_PATH=$env:NPM_AI_PATH `
--build-arg NPM_AI_ID=$env:NPM_AI_ID `
.
}

function cns-image {
$env:ACN_PACKAGE_PATH = "github.com/Azure/azure-container-networking"
$env:CNS_AI_ID = "ce672799-8f08-4235-8c12-08563dc2acef"
$env:CNS_AI_PATH = "$env:ACN_PACKAGE_PATH/cns/logger.aiMetadata"

if ($null -eq $env:VERSION) { $env:VERSION = $args[0] }
docker build `
-f cns/windows.Dockerfile `
-t acnpublic.azurecr.io/azure-cns:$env:VERSION `
--build-arg VERSION=$env:VERSION `
--build-arg CNS_AI_PATH=$env:CNS_AI_PATH `
--build-arg CNS_AI_ID=$env:CNS_AI_ID `
.
}