1
- GKERegion = " us-central1-a"
1
+ region = " us-central1-a"
2
2
testUrlPrefix= " https://percona-jenkins-artifactory-public.s3.amazonaws.com/cloud-psmdb-operator"
3
3
tests= []
4
4
5
5
void createCluster (String CLUSTER_SUFFIX ) {
6
6
withCredentials([string(credentialsId : ' GCP_PROJECT_ID' , variable : ' GCP_PROJECT' ), file(credentialsId : ' gcloud-key-file' , variable : ' CLIENT_SECRET_FILE' )]) {
7
7
sh """
8
8
export KUBECONFIG=/tmp/$CLUSTER_NAME -${ CLUSTER_SUFFIX}
9
- export USE_GKE_GCLOUD_AUTH_PLUGIN=True
10
- source $HOME /google-cloud-sdk/path.bash.inc
11
9
ret_num=0
12
10
while [ \$ {ret_num} -lt 15 ]; do
13
11
ret_val=0
14
12
gcloud auth activate-service-account --key-file $CLIENT_SECRET_FILE
15
13
gcloud config set project $GCP_PROJECT
16
- gcloud container clusters list --filter $CLUSTER_NAME -${ CLUSTER_SUFFIX} --zone $G KERegion --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone $G KERegion --quiet || true
17
- gcloud container clusters create --zone $G KERegion $CLUSTER_NAME -${ CLUSTER_SUFFIX} --cluster-version=1.25 --machine-type=n1-standard-4 --preemptible --num-nodes=3 --network=jenkins-vpc --subnetwork=jenkins-${ CLUSTER_SUFFIX} --no-enable-autoupgrade --cluster-ipv4-cidr=/21 --labels delete-cluster-after-hours=6 --enable-ip-alias --workload-pool=cloud-dev-112233.svc.id.goog && \
14
+ gcloud container clusters list --filter $CLUSTER_NAME -${ CLUSTER_SUFFIX} --zone $r egion --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone $r egion --quiet || true
15
+ gcloud container clusters create --zone $r egion $CLUSTER_NAME -${ CLUSTER_SUFFIX} --cluster-version=1.25 --machine-type=n1-standard-4 --preemptible --num-nodes=3 --network=jenkins-vpc --subnetwork=jenkins-${ CLUSTER_SUFFIX} --no-enable-autoupgrade --cluster-ipv4-cidr=/21 --labels delete-cluster-after-hours=6 --enable-ip-alias --workload-pool=cloud-dev-112233.svc.id.goog && \
18
16
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user jenkins@"$GCP_PROJECT ".iam.gserviceaccount.com || ret_val=\$ ?
19
17
if [ \$ {ret_val} -eq 0 ]; then break; fi
20
18
ret_num=\$ ((ret_num + 1))
21
19
done
22
20
if [ \$ {ret_num} -eq 15 ]; then
23
- gcloud container clusters list --filter $CLUSTER_NAME -${ CLUSTER_SUFFIX} --zone $G KERegion --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone $G KERegion --quiet || true
21
+ gcloud container clusters list --filter $CLUSTER_NAME -${ CLUSTER_SUFFIX} --zone $r egion --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone $r egion --quiet || true
24
22
exit 1
25
23
fi
26
24
"""
@@ -31,8 +29,6 @@ void shutdownCluster(String CLUSTER_SUFFIX) {
31
29
withCredentials([string(credentialsId : ' GCP_PROJECT_ID' , variable : ' GCP_PROJECT' ), file(credentialsId : ' gcloud-key-file' , variable : ' CLIENT_SECRET_FILE' )]) {
32
30
sh """
33
31
export KUBECONFIG=/tmp/$CLUSTER_NAME -${ CLUSTER_SUFFIX}
34
- export USE_GKE_GCLOUD_AUTH_PLUGIN=True
35
- source $HOME /google-cloud-sdk/path.bash.inc
36
32
gcloud auth activate-service-account --key-file $CLIENT_SECRET_FILE
37
33
gcloud config set project $GCP_PROJECT
38
34
for namespace in \$ (kubectl get namespaces --no-headers | awk '{print \$ 1}' | grep -vE "^kube-|^openshift" | sed '/-operator/ s/^/1-/' | sort | sed 's/^1-//'); do
@@ -44,17 +40,15 @@ void shutdownCluster(String CLUSTER_SUFFIX) {
44
40
kubectl delete pods --all -n \$ namespace --force --grace-period=0 || true
45
41
done
46
42
kubectl get svc --all-namespaces || true
47
- gcloud container clusters delete --zone $G KERegion $CLUSTER_NAME -${ CLUSTER_SUFFIX}
43
+ gcloud container clusters delete --zone $r egion $CLUSTER_NAME -${ CLUSTER_SUFFIX}
48
44
"""
49
45
}
50
46
}
51
47
52
48
void deleteOldClusters (String FILTER ) {
53
49
withCredentials([string(credentialsId : ' GCP_PROJECT_ID' , variable : ' GCP_PROJECT' ), file(credentialsId : ' gcloud-key-file' , variable : ' CLIENT_SECRET_FILE' )]) {
54
50
sh """
55
- if [ -f $HOME /google-cloud-sdk/path.bash.inc ]; then
56
- export USE_GKE_GCLOUD_AUTH_PLUGIN=True
57
- source $HOME /google-cloud-sdk/path.bash.inc
51
+ if gcloud --version > /dev/null 2>&1; then
58
52
gcloud auth activate-service-account --key-file $CLIENT_SECRET_FILE
59
53
gcloud config set project $GCP_PROJECT
60
54
for GKE_CLUSTER in \$ (gcloud container clusters list --format='csv[no-heading](name)' --filter="$FILTER "); do
@@ -70,7 +64,7 @@ void deleteOldClusters(String FILTER) {
70
64
break
71
65
fi
72
66
done
73
- gcloud container clusters delete --async --zone $G KERegion --quiet \$ GKE_CLUSTER || true
67
+ gcloud container clusters delete --async --zone $r egion --quiet \$ GKE_CLUSTER || true
74
68
done
75
69
fi
76
70
"""
@@ -208,7 +202,6 @@ void runTest(Integer TEST_ID) {
208
202
export DEBUG_TESTS=1
209
203
fi
210
204
export KUBECONFIG=/tmp/$CLUSTER_NAME -$clusterSuffix
211
- source $HOME /google-cloud-sdk/path.bash.inc
212
205
./e2e-tests/$testName /run
213
206
"""
214
207
}
@@ -278,35 +271,35 @@ pipeline {
278
271
}
279
272
}
280
273
}
281
- sh '''
282
- sudo yum install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm || true
283
- sudo percona-release enable-only tools
284
- sudo yum install -y | true
274
+ sh """
275
+ sudo curl -s -L -o /usr/local/bin/kubectl https://dl.k8s.io/release/\$ (curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl && sudo chmod +x /usr/local/bin/kubectl
276
+ kubectl version --client --output=yaml
285
277
286
- if [ ! -d $HOME/google-cloud-sdk/bin ]; then
287
- rm -rf $HOME/google-cloud-sdk
288
- curl https://sdk.cloud.google.com | bash
289
- fi
278
+ curl -fsSL https://get.helm.sh/helm-v3.12.3-linux-amd64.tar.gz | sudo tar -C /usr/local/bin --strip-components 1 -xzf - linux-amd64/helm
290
279
291
- source $HOME/google-cloud-sdk/path.bash.inc
292
- gcloud components install alpha
293
- gcloud components install kubectl
280
+ sudo sh -c "curl -s -L https://github.com/mikefarah/yq/releases/download/v4.35.1/yq_linux_amd64 > /usr/local/bin/yq"
281
+ sudo chmod +x /usr/local/bin/yq
294
282
295
- curl -fsSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
296
- curl -s -L https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz \
297
- | sudo tar -C /usr/local/bin --strip-components 1 --wildcards -zxvpf - '*/oc'
283
+ sudo sh -c "curl -s -L https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64 > /usr/local/bin/jq"
284
+ sudo chmod +x /usr/local/bin/jq
298
285
299
- curl -s -L https://github.com/mitchellh/golicense/releases/latest/download/golicense_0.2.0_linux_x86_64.tar.gz \
300
- | sudo tar -C /usr/local/bin --wildcards -zxvpf -
286
+ sudo tee /etc/yum.repos.d/google-cloud-sdk.repo << EOF
287
+ [google-cloud-cli]
288
+ name=Google Cloud CLI
289
+ baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
290
+ enabled=1
291
+ gpgcheck=1
292
+ repo_gpgcheck=0
293
+ gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
294
+ EOF
295
+ sudo yum install -y google-cloud-cli google-cloud-cli-gke-gcloud-auth-plugin
296
+
297
+ curl -sL https://github.com/mitchellh/golicense/releases/latest/download/golicense_0.2.0_linux_x86_64.tar.gz | sudo tar -C /usr/local/bin -xzf - golicense
298
+ """
301
299
302
- sudo sh -c "curl -s -L https://github.com/mikefarah/yq/releases/download/v4.34.1/yq_linux_amd64 > /usr/local/bin/yq"
303
- sudo chmod +x /usr/local/bin/yq
304
- sudo sh -c "curl -s -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 > /usr/local/bin/jq"
305
- sudo chmod +x /usr/local/bin/jq
306
- '''
307
300
withCredentials([file(credentialsId : ' cloud-secret-file' , variable : ' CLOUD_SECRET_FILE' )]) {
308
301
sh '''
309
- cp $CLOUD_SECRET_FILE ./ e2e-tests/conf/cloud-secret.yml
302
+ cp $CLOUD_SECRET_FILE e2e-tests/conf/cloud-secret.yml
310
303
'''
311
304
}
312
305
deleteOldClusters(" jen-psmdb-$CHANGE_ID " )
@@ -498,9 +491,8 @@ pipeline {
498
491
}
499
492
deleteOldClusters(" $CLUSTER_NAME " )
500
493
sh """
501
- sudo docker system prune -fa
502
- sudo rm -rf ./*
503
- sudo rm -rf $HOME /google-cloud-sdk
494
+ sudo docker system prune --volumes -af
495
+ sudo rm -rf *
504
496
"""
505
497
deleteDir()
506
498
}
0 commit comments