This repository has been archived by the owner on Apr 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
arktos-e2e-pipeline
337 lines (292 loc) · 11.9 KB
/
arktos-e2e-pipeline
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
pipeline {
options {
disableConcurrentBuilds()
}
agent none
stages {
stage('Build') {
agent {
label 'e2e-slave1'
}
steps {
dir('src/k8s.io/kubernetes') {
git branch: 'master', credentialsId: 'ed65dd2c-2efa-48a8-bd14-6baef33ba29f', url: 'https://github.com/futurewei-cloud/arktos'
}
sh '''#!/bin/bash
set -e
export GOROOT=/usr/local/go
export GOPATH=$PWD
export PATH=$GOROOT/bin:$HOME/bin:$GOPATH/bin:$PATH
export KUBE_ROOT=$GOPATH/src/k8s.io/kubernetes
pwd
cd $KUBE_ROOT
make clean
source $KUBE_ROOT/aws_build_version && make quick-release
source $KUBE_ROOT/aws_kube_params.inc
PRESET_KUBE_MASTER_IP=$PARAMS_KUBE_MASTER_IP
PRESET_INSTANCES_ENABLED=true
IS_PRESET_INSTANCES_DRY_RUN=true
chmod 755 $KUBE_ROOT/cluster/kube-up.sh
$KUBE_ROOT/cluster/kube-up.sh
cp /tmp/master-user-data $GOPATH/master-user-data
cp /tmp/node-user-data $GOPATH/node-user-data
'''
stash includes: 'src/k8s.io/kubernetes/_output/release-tars/kubernetes-server-linux-amd64.tar.gz', name: 'ServerBinaryTar'
stash includes: 'master-user-data', name: 'master-user-data'
stash includes: 'node-user-data', name: 'node-user-data'
stash includes: 'src/k8s.io/kubernetes/cluster/aws/configure-vm.sh', name: 'configure-vm.sh'
stash includes: 'src/k8s.io/kubernetes/cluster/aws/cleanup-preset-vm.sh', name: 'cleanup-preset-vm.sh'
stash includes: 'src/k8s.io/kubernetes/_output/dockerized/bin/linux/amd64/kubectl', name: 'kubectl'
}
}
stage('TeardownNodes') {
parallel {
stage('TeardownMaster') {
agent {
label 'e2e-slave2'
}
steps {
unstash 'cleanup-preset-vm.sh'
sh '''#!/bin/bash
set -e
export GOROOT=/usr/local/go
export GOPATH=$PWD
export PATH=$GOROOT/bin:$HOME/bin:$GOPATH/bin:$PATH
export KUBE_ROOT=$GOPATH/src/k8s.io/kubernetes
pwd
chmod 755 $KUBE_ROOT/cluster/aws/cleanup-preset-vm.sh
sudo $KUBE_ROOT/cluster/aws/cleanup-preset-vm.sh
sudo shutdown -r +1 "Server will restart in 1 minute." & disown
'''
}
}
stage('TeardownMinion1') {
agent {
label 'e2e-slave3'
}
steps {
unstash 'cleanup-preset-vm.sh'
sh '''#!/bin/bash
set -e
export GOROOT=/usr/local/go
export GOPATH=$PWD
export PATH=$GOROOT/bin:$HOME/bin:$GOPATH/bin:$PATH
export KUBE_ROOT=$GOPATH/src/k8s.io/kubernetes
pwd
chmod 755 $KUBE_ROOT/cluster/aws/cleanup-preset-vm.sh
sudo $KUBE_ROOT/cluster/aws/cleanup-preset-vm.sh
sudo shutdown -r +1 "Server will restart in 1 minute." & disown
'''
}
}
}
}
stage('WaitingReboot') {
agent {
label 'e2e-slave1'
}
steps {
sh '''#!/bin/bash
set -e
sleep 60
'''
}
}
stage('Cleanup') {
parallel {
stage('CleanupMaster') {
agent {
label 'e2e-slave2'
}
steps {
sh '''
set -e
sudo rm -rf /etc/motd
sudo rm -rf /etc/systemd/system/multi-user.target.wants/kubelet.service
sudo rm -rf /etc/kubernetes
sudo rm -rf /etc/srv/kubernetes
sudo rm -rf /etc/systemd/system/kubelet.service.d
sudo rm -rf /home/ubuntu/.kube/
sudo rm -rf /lib/systemd/system/kubelet.service
sudo rm -rf /mnt/master-pd
sudo rm -rf /root/.kube
sudo rm -rf /srv/kubernetes
sudo rm -rf /tmp/bootstrap-script
sudo rm -rf /tmp/kubernetes-server-linux-amd64.tar.gz
sudo rm -rf /tmp/master-user-data
sudo rm -rf /usr/bin/kubeadm
sudo rm -rf /usr/bin/kubectl
sudo rm -rf /usr/bin/kubelet
sudo rm -rf /usr/libexec/kubernetes
sudo rm -rf /usr/libexec/kubernetes/kubelet-plugins
sudo rm -rf /usr/local/bin/kube-proxy
sudo rm -rf /usr/share/sosreport/sos/plugins/__pycache__/kubernetes.cpython-35.pyc
sudo rm -rf /usr/share/sosreport/sos/plugins/kubernetes.py
sudo rm -rf /usr/bin/kubelet
sudo rm -rf /var/log/containers/*
sudo rm -rf /var/log/workload-controller-manager.log
sudo rm -rf /var/cache/kubernetes-install
sudo rm -rf /var/log/pods
sudo rm -rf /usr/share/sosreport/sos/plugins/__pycache__/etcd.cpython-35.pyc
sudo rm -rf /usr/share/sosreport/sos/plugins/etcd.py
sudo rm -rf /var/lib/etcd
sudo rm -rf /var/etcd
sudo rm -rf /var/lib/kubelet
'''
}
}
stage('CleanupMinion1') {
agent {
label 'e2e-slave3'
}
steps {
sh '''
set -e
sudo rm -rf /etc/motd
sudo rm -rf /etc/systemd/system/multi-user.target.wants/kubelet.service
sudo rm -rf /etc/kubernetes
sudo rm -rf /etc/srv/kubernetes
sudo rm -rf /etc/systemd/system/kubelet.service.d
sudo rm -rf /home/ubuntu/.kube/
sudo rm -rf /lib/systemd/system/kubelet.service
sudo rm -rf /mnt/master-pd
sudo rm -rf /root/.kube
sudo rm -rf /srv/kubernetes
sudo rm -rf /tmp/bootstrap-script
sudo rm -rf /tmp/kubernetes-server-linux-amd64.tar.gz
sudo rm -rf /tmp/master-user-data
sudo rm -rf /usr/bin/kubeadm
sudo rm -rf /usr/bin/kubectl
sudo rm -rf /usr/bin/kubelet
sudo rm -rf /usr/libexec/kubernetes
sudo rm -rf /usr/libexec/kubernetes/kubelet-plugins
sudo rm -rf /usr/local/bin/kube-proxy
sudo rm -rf /usr/share/sosreport/sos/plugins/__pycache__/kubernetes.cpython-35.pyc
sudo rm -rf /usr/share/sosreport/sos/plugins/kubernetes.py
sudo rm -rf /usr/bin/kubelet
sudo rm -rf /var/log/containers/*
sudo rm -rf /var/log/workload-controller-manager.log
sudo rm -rf /var/cache/kubernetes-install
sudo rm -rf /var/log/pods
sudo rm -rf /usr/share/sosreport/sos/plugins/__pycache__/etcd.cpython-35.pyc
sudo rm -rf /usr/share/sosreport/sos/plugins/etcd.py
sudo rm -rf /var/lib/etcd
sudo rm -rf /var/etcd
sudo rm -rf /var/lib/kubelet
'''
}
}
}
}
stage('DeployMaster') {
agent {
label 'e2e-slave2'
}
steps {
unstash 'ServerBinaryTar'
unstash 'master-user-data'
unstash 'configure-vm.sh'
sh '''
set -e
export GOROOT=/usr/local/go
export GOPATH=$PWD
export PATH=$GOROOT/bin:$HOME/bin:$GOPATH/bin:$PATH
export KUBE_ROOT=$GOPATH/src/k8s.io/kubernetes
pwd
cp $KUBE_ROOT/cluster/aws/configure-vm.sh /tmp/bootstrap-script
chmod 755 /tmp/bootstrap-script
cp $KUBE_ROOT/_output/release-tars/kubernetes-server-linux-amd64.tar.gz /tmp/kubernetes-server-linux-amd64.tar.gz
echo hochan1
chmod 755 $GOPATH/master-user-data
echo hochan2
sudo $GOPATH/master-user-data
echo hochan3
sudo /tmp/bootstrap-script > /tmp/bootstrap-script.log
echo hochan4
sudo cp /home/${PARAMS_DEFAULT_USER}/.kube/config $GOPATH/config
echo hochan5
sudo chown jenkins $GOPATH/config
'''
stash includes: 'config', name: 'config'
}
}
stage('DeployMinion1') {
agent {
label 'e2e-slave3'
}
steps {
unstash 'ServerBinaryTar'
unstash 'node-user-data'
unstash 'configure-vm.sh'
sh '''
set -e
export GOROOT=/usr/local/go
export GOPATH=$PWD
export PATH=$GOROOT/bin:$HOME/bin:$GOPATH/bin:$PATH
export KUBE_ROOT=$GOPATH/src/k8s.io/kubernetes
pwd
cp $KUBE_ROOT/cluster/aws/configure-vm.sh /tmp/bootstrap-script
chmod 755 /tmp/bootstrap-script
cp $KUBE_ROOT/_output/release-tars/kubernetes-server-linux-amd64.tar.gz /tmp/kubernetes-server-linux-amd64.tar.gz
chmod 755 $GOPATH/node-user-data
sudo $GOPATH/node-user-data
sudo /tmp/bootstrap-script
'''
}
}
stage('Test') {
agent {
label 'e2e-slave1'
}
steps {
unstash 'config'
unstash 'kubectl'
sh '''#!/bin/bash
set -e
export GOROOT=/usr/local/go
export GOPATH=$PWD
export PATH=$GOROOT/bin:$HOME/bin:$GOPATH/bin:$PATH
export KUBE_ROOT=$GOPATH/src/k8s.io/kubernetes
export KUBECONFIG=/var/lib/jenkins/.kube/config
export PRESET_KUBE_MASTER_IP=$PARAMS_KUBE_MASTER_IP
pwd
cp $GOPATH/config $KUBECONFIG
sed -i "s/server: https:\\/\\/.*:6443/server: https:\\/\\/${PRESET_KUBE_MASTER_IP}:6443/" /var/lib/jenkins/.kube/config
cp $KUBE_ROOT/_output/dockerized/bin/linux/amd64/kubectl $HOME/bin/kubectl
kubectl get nodes
kubectl get pods --all-namespaces -o wide
cd /tmp
wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl --kubeconfig=$KUBECONFIG create -f /tmp/kube-flannel.yml
cd $KUBE_ROOT
export KUBE_MASTER_URL=https://${PRESET_KUBE_MASTER_IP}:6443
kubetest --test --test_args="--ginkgo.focus=\\[Arktos-CI\\]" --provider=local
'''
}
}
}
post {
success {
emailext (
subject: "Arktos E2E CICD Test Succeed: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """
Jenkins job ${env.JOB_NAME} [${env.BUILD_NUMBER}] succeed!
Job Url: ${env.BUILD_URL}
Console Url: ${env.BUILD_URL}console""",
to: 'hchang@futurewei.com'
)
}
failure {
emailext (
subject: "Arktos E2E CICD Test Failed: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """
Jenkins job ${env.JOB_NAME} [${env.BUILD_NUMBER}] failed!
To investigate, click console url and check error message there.
Job Url: ${env.BUILD_URL}
Console Url: ${env.BUILD_URL}console""",
recipientProviders: [brokenBuildSuspects()],
to: 'hchang@futurewei.com'
)
}
}
}