Skip to content

Commit ffc1c87

Browse files
authored
pipeline: New Cyclonus NPM windows only pipeline (#1595)
* pipeline: New Cyclonus NPM windows only pipeline * pipeline: New Cyclonus NPM windows only pipeline
1 parent 1b5420a commit ffc1c87

File tree

1 file changed

+217
-0
lines changed

1 file changed

+217
-0
lines changed
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
variables:
2+
- name: VNET_NAME
3+
value: npm-vnet
4+
- name: NUM_PARALLEL_JOBS_FOR_STRESS_TEST
5+
value: "3"
6+
7+
jobs:
8+
- job: setup
9+
displayName: "Configure Test Environment"
10+
pool:
11+
name: $(BUILD_POOL_NAME_DEFAULT)
12+
demands:
13+
- agent.os -equals Linux
14+
- Role -equals Build
15+
steps:
16+
- checkout: self
17+
18+
- script: |
19+
go version
20+
go env
21+
which go
22+
echo $PATH
23+
mkdir -p '$(GOBIN)'
24+
mkdir -p '$(GOPATH)/pkg'
25+
BUILD_NUMBER=$(Build.BuildNumber)
26+
RG=e2e-$(echo "npm-`date "+%Y-%m-%d-%S"`")
27+
28+
git --version
29+
TAG=$(git -c "versionsort.suffix=-" ls-remote --tags https://github.com/Azure/azure-container-networking | grep -v "zapai" | grep -v "ipam" | grep -v "{}"| cut --delimiter="/" --fields=3 | sort -V | tail -1)
30+
echo "Resource group: $RG"
31+
echo "Image tag: $TAG"
32+
33+
echo "##vso[task.setvariable variable=RESOURCE_GROUP;isOutput=true;]$RG"
34+
echo "##vso[task.setvariable variable=TAG;isOutput=true;]$TAG"
35+
36+
name: "EnvironmentalVariables"
37+
displayName: "Set environmental variables"
38+
condition: always()
39+
40+
- job: Create_Windows_Cluster_and_Run_Test
41+
timeoutInMinutes: 360
42+
displayName: "Run Windows Cyclonus"
43+
pool:
44+
name: $(BUILD_POOL_NAME_DEFAULT)
45+
demands:
46+
- agent.os -equals Linux
47+
- Role -equals Build
48+
dependsOn: [setup]
49+
variables:
50+
RESOURCE_GROUP: $[ dependencies.setup.outputs['EnvironmentalVariables.RESOURCE_GROUP'] ]
51+
TAG: $[ dependencies.setup.outputs['EnvironmentalVariables.TAG'] ]
52+
FQDN: empty
53+
strategy:
54+
matrix:
55+
v2-windows:
56+
PROFILE: "cyc-ws22"
57+
steps:
58+
- checkout: self
59+
- download: none
60+
61+
- task: AzureCLI@2
62+
displayName: "Create AKS Cluster"
63+
inputs:
64+
azureSubscription: $(BUILD_VALIDATIONS_SERVICE_CONNECTION)
65+
scriptType: "bash"
66+
scriptLocation: "inlineScript"
67+
failOnStderr: true
68+
inlineScript: |
69+
az extension add --name aks-preview
70+
az extension update --name aks-preview
71+
72+
# Enable Microsoft.ContainerService/AKSWindows2022Preview
73+
az feature register --namespace Microsoft.ContainerService --name AKSWindows2022Preview
74+
az provider register -n Microsoft.ContainerService
75+
76+
export CLUSTER_NAME=$(RESOURCE_GROUP)-$(PROFILE)
77+
78+
echo "Creating resource group named $CLUSTER_NAME"
79+
az group create --name $CLUSTER_NAME -l $(LOCATION) -o table
80+
81+
if [ $? != 0 ]
82+
then
83+
echo "Failing fast since previous command failed"
84+
exit 1
85+
fi
86+
87+
echo "Creating resource group named $CLUSTER_NAME"
88+
az aks create \
89+
--resource-group $CLUSTER_NAME \
90+
--name $CLUSTER_NAME \
91+
--generate-ssh-keys \
92+
--windows-admin-username e2eadmin \
93+
--windows-admin-password alpha@numeric!password2 \
94+
--network-plugin azure \
95+
--vm-set-type VirtualMachineScaleSets \
96+
--node-vm-size Standard_D4s_v3 \
97+
--kubernetes-version v1.23.5 \
98+
--node-count 1
99+
100+
if [ $? != 0 ]
101+
then
102+
echo "Failing fast since previous command failed"
103+
exit 1
104+
fi
105+
106+
# don't schedule anything on the linux system pool
107+
echo "Updating $CLUSTER_NAME to not schedule anything on linux pool..."
108+
az aks nodepool update \
109+
--cluster-name $CLUSTER_NAME \
110+
-g $CLUSTER_NAME \
111+
-n nodepool1 \
112+
--node-taints CriticalAddonsOnly=true:NoSchedule
113+
114+
if [ $? != 0 ]
115+
then
116+
echo "Failing fast since previous command failed"
117+
exit 1
118+
fi
119+
120+
echo "Adding Windows nodepool to $CLUSTER_NAME"
121+
az aks nodepool add \
122+
--resource-group $CLUSTER_NAME \
123+
--cluster-name $CLUSTER_NAME \
124+
--name awin22 \
125+
--os-type Windows \
126+
--os-sku Windows2022 \
127+
--node-vm-size Standard_D4s_v3 \
128+
--node-count 3
129+
130+
if [ $? != 0 ]
131+
then
132+
echo "Failing fast since previous command failed"
133+
exit 1
134+
fi
135+
136+
echo "Getting credentials to $CLUSTER_NAME"
137+
az aks get-credentials -g $CLUSTER_NAME -n $CLUSTER_NAME --overwrite-existing --file ./kubeconfig
138+
mkdir -p ~/.kube/
139+
cp ./kubeconfig ~/.kube/config
140+
141+
- task: AzureCLI@2
142+
displayName: "Deploy NPM to Test Cluster"
143+
inputs:
144+
azureSubscription: $(BUILD_VALIDATIONS_SERVICE_CONNECTION)
145+
scriptType: "bash"
146+
scriptLocation: "inlineScript"
147+
failOnStderr: true
148+
inlineScript: |
149+
export CLUSTER_NAME=$(RESOURCE_GROUP)-$(PROFILE)
150+
151+
curl -LO https://dl.k8s.io/release/v1.23.0/bin/linux/amd64/kubectl
152+
chmod +x kubectl
153+
154+
# deploy azure-npm
155+
./kubectl --kubeconfig=./kubeconfig apply -f https://raw.githubusercontent.com/Azure/azure-container-networking/master/npm/examples/windows/azure-npm.yaml
156+
157+
# swap azure-npm image with one built during run
158+
./kubectl --kubeconfig=./kubeconfig set image daemonset/azure-npm-win -n kube-system azure-npm=$IMAGE_REGISTRY/azure-npm:windows-amd64-$(TAG)
159+
160+
echo "sleeping 3 minutes to allow NPM pods to restart"
161+
sleep 180
162+
163+
./kubectl --kubeconfig=./kubeconfig get po -n kube-system -owide -A
164+
165+
echo "Showing cluster status for $CLUSTER_NAME"
166+
FQDN=`az aks show -n $CLUSTER_NAME -g $CLUSTER_NAME --query fqdn -o tsv`
167+
echo "##vso[task.setvariable variable=FQDN]$FQDN"
168+
169+
- script: |
170+
cat ~/.kube/config
171+
curl -fsSL github.com/mattfenwick/cyclonus/releases/latest/download/cyclonus_linux_amd64.tar.gz | tar -zxv
172+
name: download_cyclonus
173+
displayName: "Download Cyclonus"
174+
failOnStderr: false
175+
condition: always()
176+
177+
- script: |
178+
./test/cyclonus/test-cyclonus-windows.sh
179+
name: cyclonus
180+
displayName: "Run Cyclonus Test"
181+
failOnStderr: false
182+
condition: always()
183+
184+
- bash: |
185+
export CLUSTER_NAME=$(RESOURCE_GROUP)-$(PROFILE)
186+
cp cyclonus-$CLUSTER_NAME $(System.DefaultWorkingDirectory)/$CLUSTER_NAME/cyclonus-$CLUSTER_NAME
187+
echo "Getting cluster state for $CLUSTER_NAME"
188+
mkdir -p $(System.DefaultWorkingDirectory)/$CLUSTER_NAME
189+
kubectl logs -n kube-system -l k8s-app=azure-npm --tail -1 --prefix > $(System.DefaultWorkingDirectory)/$CLUSTER_NAME/npm-logs_$(PROFILE).txt
190+
cp ./kubeconfig $(System.DefaultWorkingDirectory)/$CLUSTER_NAME/.kubeconfig
191+
condition: always()
192+
193+
- publish: $(System.DefaultWorkingDirectory)/$(RESOURCE_GROUP)-$(PROFILE)
194+
condition: always()
195+
artifact: NpmLogs-$(RESOURCE_GROUP)-$(PROFILE)
196+
197+
- job: clean_up
198+
displayName: "Cleanup"
199+
pool:
200+
name: $(BUILD_POOL_NAME_DEFAULT)
201+
demands:
202+
- agent.os -equals Linux
203+
- Role -equals Build
204+
dependsOn: [Create_Windows_Cluster_and_Run_Test, setup]
205+
variables:
206+
RESOURCE_GROUP: $[ dependencies.setup.outputs['EnvironmentalVariables.RESOURCE_GROUP'] ]
207+
steps:
208+
- checkout: none
209+
- task: AzureCLI@2
210+
displayName: "Delete Test Cluster Resource Group"
211+
inputs:
212+
azureSubscription: $(BUILD_VALIDATIONS_SERVICE_CONNECTION)
213+
scriptType: "bash"
214+
scriptLocation: "inlineScript"
215+
inlineScript: |
216+
echo Deleting $(RESOURCE_GROUP)
217+
az group delete -n $(RESOURCE_GROUP) --yes

0 commit comments

Comments
 (0)