Skip to content

Commit

Permalink
ci: [CNI] Adding aks cluster creation steps for k8s e2e test (#2052)
Browse files Browse the repository at this point in the history
* ci: [CNI] Adding aks cluster creation steps for k8s e2e test

* Add  validate step to the pipeline

* Adding the telemetry config to the cluster

(cherry picked from commit 846e508)
  • Loading branch information
vipul-21 authored and jpayne3506 committed Sep 12, 2023
1 parent 52f88b1 commit c1b39e8
Show file tree
Hide file tree
Showing 10 changed files with 336 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ stages:
os: $(os)
os_version: $(os_version)
- stage: update_cni
dependsOn:
dependsOn:
- createAKSclusterWindows
- build_images
displayName: "Update CNI on Cluster"
Expand All @@ -66,7 +66,7 @@ stages:
addSpnToEnvironment: true
inlineScript: |
set -ex
export CNI_IMAGE=$(make acncli-image-name-and-tag OS=$(os) ARCH=$(arch) OS_VERSION=$(os_version))
export CNI_IMAGE=$(make cni-plugin-image-name-and-tag OS=$(os) ARCH=$(arch) OS_VERSION=$(os_version))
az extension add --name aks-preview
clusterName=${{ parameters.clusterName }}-$(make revision)
make -C ./hack/aks set-kubeconf AZCLI=az CLUSTER=${clusterName}
Expand Down
57 changes: 57 additions & 0 deletions .pipelines/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ stages:
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)"
echo "##vso[task.setvariable variable=dropgzVersion;isOutput=true]$(make cni-dropgz-version)"
cat /etc/os-release
uname -a
sudo chown -R $(whoami):$(whoami) .
Expand Down Expand Up @@ -167,6 +168,16 @@ stages:
arch: amd64
name: cni-dropgz-test
os: linux
cni_plugin_windows2022_amd64:
os: windows
name: cni-plugin
arch: amd64
os_version: ltsc2022
cni_plugin_windows2019_amd64:
os: windows
name: cni-plugin
arch: amd64
os_version: ltsc2019
cns_linux_amd64:
arch: amd64
name: cns
Expand Down Expand Up @@ -344,6 +355,48 @@ stages:
clusterName: "swifte2e"
osSku: "Ubuntu"

- template: singletenancy/aks/e2e-job-template.yaml
parameters:
name: "aks_ubuntu_18_04_linux_e2e"
displayName: AKS Ubuntu 18.04
arch: 'amd64'
os: 'linux'
clusterType: linux-cniv1-up
clusterName: 'ubuntu18e2e'
k8sVersion: 1.24.9

- template: singletenancy/aks/e2e-job-template.yaml
parameters:
name: "aks_ubuntu_22_linux_e2e"
displayName: AKS Ubuntu 22
arch: 'amd64'
os: 'linux'
clusterType: linux-cniv1-up
clusterName: 'ubuntu22e2e'
k8sVersion: 1.25

- template: singletenancy/aks/e2e-job-template.yaml
parameters:
name: "aks_windows_19_03_e2e"
displayName: AKS Windows 1903
arch: amd64
os: windows
clusterType: windows-cniv1-up
clusterName: 'win19e2e'
windowsOsSku: 'Windows2019'
os_version: 'ltsc2019'

- template: singletenancy/aks/e2e-job-template.yaml
parameters:
name: "aks_windows_22_e2e"
displayName: AKS Windows 2022
arch: amd64
os: windows
clusterType: windows-cniv1-up
clusterName: 'win22e2e'
windowsOsSku: 'Windows2022'
os_version: 'ltsc2022'

- template: singletenancy/aks-engine/e2e-job-template.yaml
parameters:
name: "ubuntu_18_04_linux_e2e"
Expand Down Expand Up @@ -389,6 +442,10 @@ stages:
dependsOn:
- "aks_swift_e2e"
- "cilium_e2e"
- "aks_ubuntu_18_04_linux_e2e"
- "aks_windows_19_03_e2e"
- "aks_ubuntu_22_linux_e2e"
- "aks_windows_22_e2e"
- "ubuntu_18_04_linux_e2e"
- "windows_19_03_e2e"
jobs:
Expand Down
44 changes: 44 additions & 0 deletions .pipelines/singletenancy/aks/e2e-job-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
parameters:
name: ""
displayName: ""
arch: ""
os: ""
clusterType: ""
clusterName: ""
k8sVersion: ""
windowsOsSku: ""
os_version: ""

stages:
- stage: ${{ parameters.name }}
displayName: E2E - ${{ parameters.displayName }}
dependsOn:
- setup
- publish
jobs:
- job: ${{ parameters.name }}
displayName: Singletenancy AKS - (${{ parameters.name }})
pool:
name: $(BUILD_POOL_NAME_DEFAULT)
demands:
- agent.os -equals Linux
- Role -equals $(CUSTOM_E2E_ROLE)
variables:
GOPATH: "$(Agent.TempDirectory)/go" # Go workspace path
GOBIN: "$(GOPATH)/bin" # Go binaries path
modulePath: "$(GOPATH)/src/github.com/Azure/azure-container-networking"
dropgzVersion: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.dropgzVersion'] ]
cniVersion: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.cniVersion'] ]
steps:
- template: e2e-step-template.yaml
parameters:
name: ${{ parameters.name }}
clusterType: ${{ parameters.clusterType }}
clusterName: ${{ parameters.clusterName }}
arch: ${{ parameters.arch }}
os: ${{ parameters.os }}
k8sVersion: ${{ parameters.k8sVersion }}
windowsOsSku: ${{ parameters.windowsOsSku }}
os_version: ${{ parameters.os_version }}
version: $(dropgzVersion)
cniVersion: $(cniVersion)
95 changes: 95 additions & 0 deletions .pipelines/singletenancy/aks/e2e-step-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
parameters:
name: ""
clusterType: ""
clusterName: ""
nodeCount: ""
vmSize: ""
windowsVMSize: ""
k8sVersion: ""
version: ""
os: ""
windowsOsSku: ""
cniVersion: ""
os_version: ""

steps:
- bash: |
go version
go env
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
name: "GoEnv"
displayName: "Set up the Go environment"
- task: AzureCLI@1
inputs:
azureSubscription: $(AZURE_TEST_AGENT_SERVICE_CONNECTION)
scriptLocation: "inlineScript"
scriptType: "bash"
addSpnToEnvironment: true
inlineScript: |
mkdir -p ~/.kube/
echo "Create AKS cluster"
echo "parameters ${{ parameters.windowsOsSku }}"
make -C ./hack/aks azcfg AZCLI=az REGION=$(REGION_AKS_CLUSTER_TEST)
make -C ./hack/aks ${{ parameters.clusterType }} AZCLI=az REGION=$(REGION_AKS_CLUSTER_TEST) SUB=$(SUB_AZURE_NETWORK_AGENT_TEST) CLUSTER=${{ parameters.clusterName }}-$(make revision) K8S_VER=${{ parameters.k8sVersion }} WINDOWS_OS_SKU=${{ parameters.windowsOsSku }} WINDOWS_USERNAME=${WINDOWS_USERNAME} WINDOWS_PASSWORD=${WINDOWS_PASSWORD}
echo "Cluster successfully created"
displayName: Create test cluster
- script: |
echo "Upload CNI"
if [ "${{parameters.os}}" == "windows" ]; then
export DROP_GZ_URL=$( make cni-dropgz-test-image-name-and-tag OS='linux' ARCH=${{ parameters.arch }} CNI_DROPGZ_VERSION=${{ parameters.version }})
envsubst < ./test/integration/manifests/cni/cni-installer-v1.yaml | kubectl apply -f -
kubectl rollout status daemonset/azure-cni -n kube-system
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 }})
envsubst < ./hack/manifests/windows-update.yaml | kubectl apply -f -
kubectl rollout status daemonset/azure-cni-windows -n kube-system
else
export DROP_GZ_URL=$( make cni-dropgz-test-image-name-and-tag OS=${{ parameters.os }} ARCH=${{ parameters.arch }} CNI_DROPGZ_VERSION=${{ parameters.version }})
envsubst < ./test/integration/manifests/cni/cni-installer-v1.yaml | kubectl apply -f -
kubectl rollout status daemonset/azure-cni -n kube-system
fi
name: "UploadCni"
displayName: "Upload CNI"
- task: AzureCLI@1
inputs:
azureSubscription: $(AZURE_TEST_AGENT_SERVICE_CONNECTION)
scriptLocation: "inlineScript"
scriptType: "bash"
addSpnToEnvironment: true
inlineScript: |
clusterName=${{ parameters.clusterName }}-$(make revision)
echo "Restarting nodes"
for val in $(az vmss list -g MC_${clusterName}_${clusterName}_$(REGION_AKS_CLUSTER_TEST) --query "[].name" -o tsv); do
make -C ./hack/aks restart-vmss AZCLI=az CLUSTER=${clusterName} REGION=$(REGION_AKS_CLUSTER_TEST) VMSS_NAME=${val}
done
displayName: "Restart Nodes"
- script: |
kubectl get pods -A -o wide
echo "Deploying test pods"
cd test/integration/load
go test -count 1 -timeout 30m -tags load -run ^TestLoad$ -tags=load -iterations=2 -scaleup=40 -os=${{ parameters.os }}
cd ../../..
# Remove this once we have cniv1 support for validating the test cluster
echo "Validate State skipped for linux cniv1 for now"
if [ "${{parameters.os}}" == "windows" ]; then
make test-validate-state OS=${{ parameters.os }}
fi
displayName: "Validate State"
retryCountOnTaskFailure: 3
- task: AzureCLI@1
inputs:
azureSubscription: $(AZURE_TEST_AGENT_SERVICE_CONNECTION)
scriptLocation: "inlineScript"
scriptType: "bash"
addSpnToEnvironment: true
inlineScript: |
echo "Skipping Deleting cluster"
make -C ./hack/aks azcfg AZCLI=az REGION=$(REGION_AKS_CLUSTER_TEST)
make -C ./hack/aks down AZCLI=az REGION=$(REGION_AKS_CLUSTER_TEST) SUB=$(SUB_AZURE_NETWORK_AGENT_TEST) CLUSTER=${{ parameters.clusterName }}-$(make revision)
echo "Cluster and resources down"
displayName: "Delete test cluster"
condition: always()

47 changes: 34 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ azure-ipam: azure-ipam-binary azure-ipam-archive

revision: ## print the current git revision
@echo $(REVISION)

version: ## prints the root version
@echo $(ACN_VERSION)

Expand All @@ -159,15 +159,15 @@ cni-dropgz-test-version: ## prints the cni-dropgz version
@echo $(CNI_DROPGZ_TEST_VERSION)

cns-version:
@echo $(CNS_VERSION)
@echo $(CNS_VERSION)

npm-version:
@echo $(NPM_VERSION)
@echo $(NPM_VERSION)

zapai-version: ## prints the zapai version
@echo $(ZAPAI_VERSION)

##@ Binaries
##@ Binaries

# Build the delegated IPAM plugin binary.
azure-ipam-binary:
Expand Down Expand Up @@ -245,13 +245,15 @@ endif

## Image name definitions.
ACNCLI_IMAGE = acncli
CNI_PLUGIN_IMAGE = azure-cni-plugin
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_PLUGIN_PLATFORM_TAG ?= $(subst /,-,$(PLATFORM))$(if $(OS_VERSION),-$(OS_VERSION),)-$(CNI_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)
Expand Down Expand Up @@ -436,6 +438,7 @@ npm-image-pull: ## pull cns container image.
IMAGE=$(NPM_IMAGE) \
TAG=$(NPM_PLATFORM_TAG)

<<<<<<< HEAD
# cni-plugin

cni-plugin-image: ## build cni plugin container image.
Expand All @@ -449,6 +452,24 @@ cni-plugin-image: ## build cni plugin container image.
ARCH=$(ARCH) \
OS_VERSION=$(OS_VERSION)

||||||| parent of 8f00357b (ci: [CNI] Adding aks cluster creation steps for k8s e2e test (#2052))
=======
# cni-plugin - Specifically used for windows clusters, will be removed once we have Dropgz for windows
cni-plugin-image-name-and-tag: # util target to print the CNI plugin image name and tag.
@echo $(IMAGE_REGISTRY)/$(CNI_PLUGIN_IMAGE):$(CNI_PLUGIN_PLATFORM_TAG)

cni-plugin-image: ## build cni plugin container image.
$(MAKE) container \
DOCKERFILE=cni/build/$(OS).Dockerfile \
IMAGE=$(CNI_PLUGIN_IMAGE) \
EXTRA_BUILD_ARGS='--build-arg CNI_AI_PATH=$(CNI_AI_PATH) --build-arg CNI_AI_ID=$(CNI_AI_ID) --build-arg OS_VERSION=$(OS_VERSION)' \
PLATFORM=$(PLATFORM) \
TAG=$(CNI_PLUGIN_PLATFORM_TAG) \
OS=$(OS) \
ARCH=$(ARCH) \
OS_VERSION=$(OS_VERSION)

>>>>>>> 8f00357b (ci: [CNI] Adding aks cluster creation steps for k8s e2e test (#2052))

## Legacy

Expand Down Expand Up @@ -503,8 +524,8 @@ manifest-build: # util target to compose multiarch container manifests from plat
$(MAKE) manifest-add PLATFORM=$(PLATFORM);\
)\
)\



manifest-push: # util target to push multiarch container manifest.
$(CONTAINER_BUILDER) manifest push --all $(IMAGE_REGISTRY)/$(IMAGE):$(TAG) docker://$(IMAGE_REGISTRY)/$(IMAGE):$(TAG)
Expand All @@ -528,7 +549,7 @@ acncli-manifest-push: ## push acncli multiplat container manifest
acncli-skopeo-archive: ## export tar archive of acncli multiplat container manifest.
$(MAKE) manifest-skopeo-archive \
IMAGE=$(ACNCLI_IMAGE) \
TAG=$(ACN_VERSION)
TAG=$(ACN_VERSION)

cni-dropgz-manifest-build: ## build cni-dropgz multiplat container manifest.
$(MAKE) manifest-build \
Expand Down Expand Up @@ -680,7 +701,7 @@ ifeq ($(GOOS),linux)
endif


##@ Utils
##@ Utils

clean: ## Clean build artifacts.
$(RMDIR) $(OUTPUT_DIR)
Expand Down Expand Up @@ -711,7 +732,7 @@ workspace: ## Set up the Go workspace.
go work use ./dropgz
go work use ./zapai

##@ Test
##@ Test

COVER_PKG ?= .
#Restart case is used for cni load test pipeline for restarting the nodes cluster.
Expand Down Expand Up @@ -769,7 +790,7 @@ gitconfig: ## configure the local git repository
setup: tools install-hooks gitconfig ## performs common required repo setup


##@ Tools
##@ Tools

$(TOOLS_DIR)/go.mod:
cd $(TOOLS_DIR); go mod init && go mod tidy
Expand All @@ -779,7 +800,7 @@ $(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod

controller-gen: $(CONTROLLER_GEN) ## Build controller-gen

protoc:
protoc:
source ${REPO_ROOT}/scripts/install-protoc.sh

$(GOCOV): $(TOOLS_DIR)/go.mod
Expand Down Expand Up @@ -812,13 +833,13 @@ $(MOCKGEN): $(TOOLS_DIR)/go.mod

mockgen: $(MOCKGEN) ## Build mockgen

clean-tools:
clean-tools:
rm -r build/tools/bin

tools: acncli gocov gocov-xml go-junit-report golangci-lint gofumpt protoc ## Build bins for build tools


##@ Help
##@ Help

help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
Loading

0 comments on commit c1b39e8

Please sign in to comment.