Skip to content

Commit 7a41178

Browse files
authored
feat: [dropgz] Dropgz for windows (#2075)
* feat: [dropgz] Dropgz for windows * Removing the code for killing the process from dropgz for windows
1 parent 0c60fc3 commit 7a41178

File tree

9 files changed

+131
-37
lines changed

9 files changed

+131
-37
lines changed

.pipelines/cni/singletenancy/windows-cni-load-test-template.yaml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ stages:
1717
displayName: "Windows AKS Cluster ${{ parameters.cni }}"
1818
jobs:
1919
- job: create_aks_cluster_with_${{ parameters.name }}
20+
pool:
21+
name: "$(BUILD_POOL_NAME_DEFAULT)"
2022
steps:
2123
- template: ../load-test-templates/create-cluster-template.yaml
2224
parameters:
@@ -36,10 +38,10 @@ stages:
3638
name: "$(BUILD_POOL_NAME_LINUX_AMD64)"
3739
strategy:
3840
matrix:
39-
windows_cniv1_amd64:
40-
os: windows
41-
name: cni-plugin
41+
cni_dropgz_windows2022_amd64:
4242
arch: amd64
43+
name: cni-dropgz-test
44+
os: windows
4345
os_version: ltsc2022
4446
steps:
4547
- template: ../../containers/container-template.yaml
@@ -49,17 +51,17 @@ stages:
4951
os: $(os)
5052
os_version: $(os_version)
5153
- stage: update_cni
52-
pool:
53-
name: $(BUILD_POOL_NAME_DEFAULT)
5454
dependsOn:
5555
- createAKSclusterWindows
5656
- build_images
5757
displayName: "Update CNI on Cluster"
5858
jobs:
5959
- job: deploy_pods
60+
pool:
61+
name: "$(BUILD_POOL_NAME_DEFAULT)"
6062
strategy:
6163
matrix:
62-
windows_cniv1_amd64:
64+
cni_dropgz_windows2022_amd64:
6365
os: windows
6466
arch: amd64
6567
os_version: ltsc2022
@@ -72,12 +74,12 @@ stages:
7274
addSpnToEnvironment: true
7375
inlineScript: |
7476
set -ex
75-
export CNI_IMAGE=$(make cni-plugin-image-name-and-tag OS=$(os) ARCH=$(arch) OS_VERSION=$(os_version))
76-
az extension add --name aks-preview
7777
clusterName=${{ parameters.clusterName }}-$(make revision)
7878
make -C ./hack/aks set-kubeconf AZCLI=az CLUSTER=${clusterName}
7979
make -C ./hack/aks azcfg AZCLI=az REGION=$(LOCATION)
80-
envsubst < ./hack/manifests/windows-update.yaml | kubectl apply -f -
80+
dropgz_version=$(make cni-dropgz-version)
81+
export DROP_GZ_URL=$( make cni-dropgz-test-image-name-and-tag OS=$(os) ARCH=$(arch) OS_VERSION=$(os_version) CNI_DROPGZ_VERSION=${dropgz_version})
82+
envsubst < ./test/integration/manifests/cni/cni-installer-v1-windows.yaml | kubectl apply -f -
8183
name: "UploadCNI"
8284
displayName: "Upload CNI"
8385
- script: |
@@ -110,6 +112,8 @@ stages:
110112
displayName: "Pod Deployment"
111113
jobs:
112114
- job: deploy_pods
115+
pool:
116+
name: "$(BUILD_POOL_NAME_DEFAULT)"
113117
steps:
114118
- template: ../load-test-templates/pod-deployment-template.yaml
115119
parameters:
@@ -125,6 +129,8 @@ stages:
125129
displayName: "Validate State"
126130
jobs:
127131
- job: validate_state
132+
pool:
133+
name: "$(BUILD_POOL_NAME_DEFAULT)"
128134
steps:
129135
- template: ../load-test-templates/validate-state-template.yaml
130136
parameters:
@@ -139,6 +145,8 @@ stages:
139145
- validate_state_windows
140146
jobs:
141147
- job: delete_resources
148+
pool:
149+
name: "$(BUILD_POOL_NAME_DEFAULT)"
142150
steps:
143151
- task: AzureCLI@1
144152
inputs:

.pipelines/pipeline.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,11 @@ stages:
165165
arch: amd64
166166
name: cni-dropgz-test
167167
os: linux
168-
cni_plugin_windows2022_amd64:
169-
os: windows
170-
name: cni-plugin
168+
cni_dropgz_test_windows2022_amd64:
171169
arch: amd64
172-
os_version: ltsc2022
173-
cni_plugin_windows2019_amd64:
170+
name: cni-dropgz-test
174171
os: windows
175-
name: cni-plugin
176-
arch: amd64
177-
os_version: ltsc2019
172+
os_version: ltsc2022
178173
cns_linux_amd64:
179174
arch: amd64
180175
name: cns
@@ -287,7 +282,7 @@ stages:
287282
platforms: linux/amd64 linux/arm64
288283
cni_dropgz_test:
289284
name: cni-dropgz-test
290-
platforms: linux/amd64 linux/arm64
285+
platforms: linux/amd64 linux/arm64 windows/amd64
291286
cns:
292287
name: cns
293288
os_versions: ltsc2019 ltsc2022

.pipelines/singletenancy/aks/e2e-step-template.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ steps:
4444
export DROP_GZ_URL=$( make cni-dropgz-test-image-name-and-tag OS='linux' ARCH=${{ parameters.arch }} CNI_DROPGZ_VERSION=${{ parameters.version }})
4545
envsubst < ./test/integration/manifests/cni/cni-installer-v1.yaml | kubectl apply -f -
4646
kubectl rollout status daemonset/azure-cni -n kube-system
47-
export CNI_IMAGE=$(make cni-plugin-image-name-and-tag OS=${{ parameters.os }} ARCH=${{ parameters.arch }} OS_VERSION=${{ parameters.os_version }} CNI_VERSION=${{ parameters.cniVersion }})
48-
envsubst < ./hack/manifests/windows-update.yaml | kubectl apply -f -
47+
echo "Deploying on windows nodes"
48+
export DROP_GZ_URL=$( make cni-dropgz-test-image-name-and-tag OS='windows' ARCH=${{ parameters.arch }} OS_VERSION=${{ parameters.os_version }} CNI_DROPGZ_VERSION=${{ parameters.version }})
49+
envsubst < ./test/integration/manifests/cni/cni-installer-v1-windows.yaml | kubectl apply -f -
4950
kubectl rollout status daemonset/azure-cni-windows -n kube-system
5051
else
5152
export DROP_GZ_URL=$( make cni-dropgz-test-image-name-and-tag OS=${{ parameters.os }} ARCH=${{ parameters.arch }} CNI_DROPGZ_VERSION=${{ parameters.version }})

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ cni-dropgz-image-name-and-tag: # util target to print the CNI dropgz image name
343343
cni-dropgz-image: ## build cni-dropgz container image.
344344
$(MAKE) container \
345345
DOCKERFILE=dropgz/build/$(OS).Dockerfile \
346-
EXTRA_BUILD_ARGS='--build-arg OS=$(OS) --build-arg ARCH=$(ARCH)' \
346+
EXTRA_BUILD_ARGS='--build-arg OS=$(OS) --build-arg ARCH=$(ARCH) --build-arg OS_VERSION=$(OS_VERSION)' \
347347
IMAGE=$(CNI_DROPGZ_IMAGE) \
348348
TAG=$(CNI_DROPGZ_PLATFORM_TAG)
349349

@@ -367,8 +367,8 @@ cni-dropgz-test-image-name-and-tag: # util target to print the CNI dropgz test i
367367

368368
cni-dropgz-test-image: ## build cni-dropgz-test container image.
369369
$(MAKE) container \
370-
DOCKERFILE=dropgz/build/cniTest.Dockerfile \
371-
EXTRA_BUILD_ARGS='--build-arg OS=$(OS)' \
370+
DOCKERFILE=dropgz/build/cniTest_$(OS).Dockerfile \
371+
EXTRA_BUILD_ARGS='--build-arg OS=$(OS) --build-arg ARCH=$(ARCH) --build-arg OS_VERSION=$(OS_VERSION)' \
372372
IMAGE=$(CNI_DROPGZ_TEST_IMAGE) \
373373
TAG=$(CNI_DROPGZ_TEST_PLATFORM_TAG)
374374

File renamed without changes.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
ARG ARCH
2+
ARG OS_VERSION
3+
FROM --platform=linux/${ARCH} mcr.microsoft.com/oss/go/microsoft/golang:1.20 AS azure-vnet
4+
ARG VERSION
5+
WORKDIR /azure-container-networking
6+
COPY . .
7+
RUN GOOS=windows CGO_ENABLED=0 go build -a -o azure-vnet.exe -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/network/plugin/main.go
8+
RUN GOOS=windows CGO_ENABLED=0 go build -a -o azure-vnet-telemetry.exe -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/telemetry/service/telemetrymain.go
9+
RUN GOOS=windows CGO_ENABLED=0 go build -a -o azure-vnet-ipam.exe -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/ipam/plugin/main.go
10+
11+
FROM --platform=linux/${ARCH} mcr.microsoft.com/cbl-mariner/base/core:2.0 AS compressor
12+
ARG OS
13+
WORKDIR /dropgz
14+
COPY dropgz .
15+
COPY --from=azure-vnet /azure-container-networking/azure-vnet.exe pkg/embed/fs
16+
COPY --from=azure-vnet /azure-container-networking/azure-vnet-telemetry.exe pkg/embed/fs
17+
COPY --from=azure-vnet /azure-container-networking/azure-vnet-ipam.exe pkg/embed/fs
18+
COPY --from=azure-vnet /azure-container-networking/telemetry/azure-vnet-telemetry.config pkg/embed/fs
19+
RUN cd pkg/embed/fs/ && sha256sum * > sum.txt
20+
RUN gzip --verbose --best --recursive pkg/embed/fs && for f in pkg/embed/fs/*.gz; do mv -- "$f" "${f%%.gz}"; done
21+
22+
FROM --platform=linux/${ARCH} mcr.microsoft.com/oss/go/microsoft/golang:1.20 AS dropgz
23+
ARG VERSION
24+
WORKDIR /dropgz
25+
COPY --from=compressor /dropgz .
26+
RUN GOOS=windows CGO_ENABLED=0 go build -a -o bin/dropgz.exe -trimpath -ldflags "-X github.com/Azure/azure-container-networking/dropgz/internal/buildinfo.Version="$VERSION"" -gcflags="-dwarflocationlists=true" main.go
27+
28+
FROM mcr.microsoft.com/windows/nanoserver:${OS_VERSION}
29+
COPY --from=dropgz /dropgz/bin/dropgz.exe dropgz.exe
30+
ENTRYPOINT [ "dropgz.exe" ]

dropgz/build/windows.Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
ARG ARCH
2+
ARG OS_VERSION
3+
FROM --platform=linux/${ARCH} mcr.microsoft.com/cbl-mariner/base/core:2.0 AS tar
4+
RUN tdnf install -y tar
5+
RUN tdnf install -y unzip
6+
RUN tdnf upgrade -y && tdnf install -y ca-certificates
7+
8+
FROM tar AS azure-vnet
9+
ARG AZCNI_VERSION=v1.5.4
10+
ARG VERSION
11+
ARG OS
12+
ARG ARCH
13+
WORKDIR /azure-container-networking
14+
COPY . .
15+
RUN curl -LO --cacert /etc/ssl/certs/ca-certificates.crt https://github.com/Azure/azure-container-networking/releases/download/$AZCNI_VERSION/azure-vnet-cni-$OS-$ARCH-$AZCNI_VERSION.zip && unzip -o azure-vnet-cni-$OS-$ARCH-$AZCNI_VERSION.zip
16+
17+
FROM --platform=linux/${ARCH} mcr.microsoft.com/cbl-mariner/base/core:2.0 AS compressor
18+
ARG OS
19+
WORKDIR /dropgz
20+
COPY dropgz .
21+
COPY --from=azure-vnet /azure-container-networking/azure-vnet.exe pkg/embed/fs
22+
COPY --from=azure-vnet /azure-container-networking/azure-vnet-telemetry.exe pkg/embed/fs
23+
COPY --from=azure-vnet /azure-container-networking/azure-vnet-ipam.exe pkg/embed/fs
24+
COPY --from=azure-vnet /azure-container-networking/azure-vnet-telemetry.config pkg/embed/fs
25+
RUN cd pkg/embed/fs/ && sha256sum * > sum.txt
26+
RUN gzip --verbose --best --recursive pkg/embed/fs && for f in pkg/embed/fs/*.gz; do mv -- "$f" "${f%%.gz}"; done
27+
28+
FROM --platform=linux/${ARCH} mcr.microsoft.com/oss/go/microsoft/golang:1.20 AS dropgz
29+
ARG VERSION
30+
WORKDIR /dropgz
31+
COPY --from=compressor /dropgz .
32+
RUN GOOS=windows CGO_ENABLED=0 go build -a -o bin/dropgz.exe -trimpath -ldflags "-X github.com/Azure/azure-container-networking/dropgz/internal/buildinfo.Version="$VERSION"" -gcflags="-dwarflocationlists=true" main.go
33+
34+
FROM mcr.microsoft.com/windows/nanoserver:${OS_VERSION}
35+
COPY --from=dropgz /dropgz/bin/dropgz.exe dropgz.exe
36+
ENTRYPOINT [ "dropgz.exe" ]

dropgz/pkg/embed/payload.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ import (
77
"io"
88
"io/fs"
99
"os"
10+
"path"
1011
"path/filepath"
11-
"strings"
1212

1313
"github.com/pkg/errors"
1414
"go.uber.org/zap"
1515
)
1616

1717
const (
1818
cwd = "fs"
19-
pathPrefix = cwd + string(filepath.Separator)
2019
oldFileSuffix = ".old"
2120
)
2221

2322
var ErrArgsMismatched = errors.New("mismatched argument count")
2423

2524
// embedfs contains the embedded files for deployment, as a read-only FileSystem containing only "embedfs/".
25+
//
2626
//nolint:typecheck // dir is populated at build.
2727
//go:embed fs
2828
var embedfs embed.FS
@@ -36,7 +36,8 @@ func Contents() ([]string, error) {
3636
if d.IsDir() {
3737
return nil
3838
}
39-
contents = append(contents, strings.TrimPrefix(path, pathPrefix))
39+
_, filename := filepath.Split(path)
40+
contents = append(contents, filename)
4041
return nil
4142
})
4243
if err != nil {
@@ -69,10 +70,10 @@ func (c *compoundReadCloser) Close() error {
6970
return nil
7071
}
7172

72-
func Extract(path string) (*compoundReadCloser, error) {
73-
f, err := embedfs.Open(filepath.Join(cwd, path))
73+
func Extract(p string) (*compoundReadCloser, error) {
74+
f, err := embedfs.Open(path.Join(cwd, p))
7475
if err != nil {
75-
return nil, errors.Wrapf(err, "failed to open file %s", path)
76+
return nil, errors.Wrapf(err, "failed to open file %s", p)
7677
}
7778
r, err := gzip.NewReader(bufio.NewReader(f))
7879
if err != nil {

hack/manifests/windows-update.yaml renamed to test/integration/manifests/cni/cni-installer-v1-windows.yaml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,42 @@ spec:
3636
hostNetwork: true
3737
serviceAccountName: azure-cni
3838
tolerations:
39-
- operator: Exists
40-
effect: NoSchedule
41-
- key: CriticalAddonsOnly
42-
operator: Exists
43-
- effect: NoExecute
44-
operator: Exists
45-
containers:
39+
- key: CriticalAddonsOnly
40+
operator: Exists
41+
- operator: "Exists"
42+
effect: NoExecute
43+
- operator: "Exists"
44+
effect: NoSchedule
45+
initContainers:
46+
- name: delete-azure-vnet-telemetry
47+
image: mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022
48+
command: ["powershell.exe", "-command"]
49+
args: ["if (Get-Process -Name 'azure-vnet-telemetry' -ErrorAction SilentlyContinue) { Stop-Process -Name 'azure-vnet-telemetry' -Force }"]
4650
- name: cni-drop
47-
image: ${CNI_IMAGE}
51+
image: ${DROP_GZ_URL}
4852
imagePullPolicy: Always
53+
command: ["%CONTAINER_SANDBOX_MOUNT_POINT%/dropgz.exe"]
54+
args:
55+
- deploy
56+
- azure-vnet.exe
57+
- -o
58+
- /k/azurecni/bin/azure-vnet.exe
59+
- azure-vnet-ipam.exe
60+
- -o
61+
- /k/azurecni/bin/azure-vnet-ipam.exe
62+
- azure-vnet-telemetry.exe
63+
- -o
64+
- /k/azurecni/bin/azure-vnet-telemetry.exe
65+
- azure-vnet-telemetry.config
66+
- -o
67+
- /k/azurecni/bin/azure-vnet-telemetry.config
4968
volumeMounts:
5069
- name: cni-bin
5170
mountPath: /k/azurecni/bin/
71+
containers:
72+
- name: pause
73+
image: mcr.microsoft.com/oss/kubernetes/pause:3.6
74+
command: ["%CONTAINER_SANDBOX_MOUNT_POINT%/pause.exe"]
5275
volumes:
5376
- name: cni-bin
5477
hostPath:

0 commit comments

Comments
 (0)