Skip to content

Commit 413251a

Browse files
authored
Update rollout CloudBuild yaml files to push wrappers into two GCP projects (#116)
1 parent f0df21c commit 413251a

File tree

4 files changed

+104
-54
lines changed

4 files changed

+104
-54
lines changed

rollout/cli_tools_cloudbuild_build.yaml

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Build all the docker images and put them into container registry (gcr.io)
22
# Later, these images will be copied to artifacts registry on demand.
3+
# NOTE: Wrappers will be pushed into 2 GCP projects. This is because we still
4+
# need to push to the old one for backward compatibility.
35

46
timeout: 1800s
57

@@ -47,9 +49,12 @@ steps:
4749
env: ['CGO_ENABLED=0']
4850
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
4951
args:
50-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_vm_image_import:$_RELEASE
51-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_vm_image_import:$COMMIT_SHA
52-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_vm_image_import:$_WORKFLOW_EXECUTION_ID
52+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_vm_image_import:$_RELEASE
53+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_vm_image_import:$COMMIT_SHA
54+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_vm_image_import:$_WORKFLOW_EXECUTION_ID
55+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_vm_image_import:$_RELEASE
56+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_vm_image_import:$COMMIT_SHA
57+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_vm_image_import:$_WORKFLOW_EXECUTION_ID
5358
- --context=/workspace
5459
- --dockerfile=gce_vm_image_import.Dockerfile
5560

@@ -60,9 +65,12 @@ steps:
6065
env: ['CGO_ENABLED=0']
6166
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
6267
args:
63-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_onestep_image_import:$_RELEASE
64-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_onestep_image_import:$COMMIT_SHA
65-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_onestep_image_import:$_WORKFLOW_EXECUTION_ID
68+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_onestep_image_import:$_RELEASE
69+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_onestep_image_import:$COMMIT_SHA
70+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_onestep_image_import:$_WORKFLOW_EXECUTION_ID
71+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_onestep_image_import:$_RELEASE
72+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_onestep_image_import:$COMMIT_SHA
73+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_onestep_image_import:$_WORKFLOW_EXECUTION_ID
6674
- --context=/workspace
6775
- --dockerfile=gce_onestep_image_import.Dockerfile
6876

@@ -73,9 +81,12 @@ steps:
7381
env: ['CGO_ENABLED=0']
7482
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
7583
args:
76-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_vm_image_export:$_RELEASE
77-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_vm_image_export:$COMMIT_SHA
78-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_vm_image_export:$_WORKFLOW_EXECUTION_ID
84+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_vm_image_export:$_RELEASE
85+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_vm_image_export:$COMMIT_SHA
86+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_vm_image_export:$_WORKFLOW_EXECUTION_ID
87+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_vm_image_export:$_RELEASE
88+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_vm_image_export:$COMMIT_SHA
89+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_vm_image_export:$_WORKFLOW_EXECUTION_ID
7990
- --context=/workspace
8091
- --dockerfile=gce_vm_image_export.Dockerfile
8192

@@ -86,9 +97,12 @@ steps:
8697
env: ['CGO_ENABLED=0']
8798
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
8899
args:
89-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_ovf_import:$_RELEASE
90-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_ovf_import:$COMMIT_SHA
91-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_ovf_import:$_WORKFLOW_EXECUTION_ID
100+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_ovf_import:$_RELEASE
101+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_ovf_import:$COMMIT_SHA
102+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_ovf_import:$_WORKFLOW_EXECUTION_ID
103+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_ovf_import:$_RELEASE
104+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_ovf_import:$COMMIT_SHA
105+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_ovf_import:$_WORKFLOW_EXECUTION_ID
92106
- --context=/workspace
93107
- --dockerfile=gce_ovf_import.Dockerfile
94108

@@ -99,20 +113,31 @@ steps:
99113
env: ['CGO_ENABLED=0']
100114
- name: 'gcr.io/kaniko-project/executor:v1.1.0'
101115
args:
102-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_ovf_export:$_RELEASE
103-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_ovf_export:$COMMIT_SHA
104-
- --destination=gcr.io/$_IMAGE_PROJECT/gce_ovf_export:$_WORKFLOW_EXECUTION_ID
116+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_ovf_export:$_RELEASE
117+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_ovf_export:$COMMIT_SHA
118+
- --destination=gcr.io/$_IMAGE_PROJECT_1/gce_ovf_export:$_WORKFLOW_EXECUTION_ID
119+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_ovf_export:$_RELEASE
120+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_ovf_export:$COMMIT_SHA
121+
- --destination=gcr.io/$_IMAGE_PROJECT_2/gce_ovf_export:$_WORKFLOW_EXECUTION_ID
105122
- --context=/workspace
106123
- --dockerfile=gce_ovf_export.Dockerfile
107124

108-
# Copy Linux binaries to GCS
125+
# Copy Linux binaries to GCS - _IMAGE_PROJECT_1
109126
- name: 'gcr.io/cloud-builders/gsutil'
110-
args: ['cp', '/workspace/linux/*', 'gs://$_IMAGE_PROJECT/$_RELEASE/linux/']
127+
args: ['cp', '/workspace/linux/*', 'gs://$_IMAGE_PROJECT_1/$_RELEASE/linux/']
111128

112-
# Copy Windows binaries to GCS
129+
# Copy Linux binaries to GCS - _IMAGE_PROJECT_2
113130
- name: 'gcr.io/cloud-builders/gsutil'
114-
args: ['cp', '/workspace/windows/*', 'gs://$_IMAGE_PROJECT/$_RELEASE/windows/']
131+
args: ['cp', '/workspace/linux/*', 'gs://$_IMAGE_PROJECT_2/$_RELEASE/linux/']
115132

116-
# Make binaries world-readable.
133+
# Copy Windows binaries to GCS - _IMAGE_PROJECT_1
117134
- name: 'gcr.io/cloud-builders/gsutil'
118-
args: ['-m', 'acl', '-r', 'ch', '-u', 'AllUsers:R', 'gs://$_IMAGE_PROJECT/$_RELEASE/*']
135+
args: ['cp', '/workspace/windows/*', 'gs://$_IMAGE_PROJECT_1/$_RELEASE/windows/']
136+
137+
# Copy Windows binaries to GCS - _IMAGE_PROJECT_2
138+
- name: 'gcr.io/cloud-builders/gsutil'
139+
args: ['cp', '/workspace/windows/*', 'gs://$_IMAGE_PROJECT_2/$_RELEASE/windows/']
140+
141+
# Make binaries world-readable - _IMAGE_PROJECT_1
142+
- name: 'gcr.io/cloud-builders/gsutil'
143+
args: ['-m', 'acl', '-r', 'ch', '-u', 'AllUsers:R', 'gs://$_IMAGE_PROJECT_1/$_RELEASE/*']

rollout/cli_tools_cloudbuild_build_prepare.yaml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ steps:
1010
- |
1111
REGIONS_ARR=$(echo "$_REGIONS" | tr ";" "\n")
1212
TOOLS_ARR=$(echo "$_TOOLS" | tr ";" "\n")
13+
GCP_PROJECTS_ARR=($_IMAGE_PROJECT_1 $_IMAGE_PROJECT_2)
1314
1415
exit_on_error() {
1516
ERR=$$1
@@ -19,23 +20,31 @@ steps:
1920
fi
2021
}
2122
22-
for _REGION in $$REGIONS_ARR
23+
for _PROJECT in ${GCP_PROJECTS_ARR[@]}
2324
do
24-
for _TOOL in $$TOOLS_ARR
25+
echo "--> Start Tagging prev-release for project $$_PROJECT"
26+
for _REGION in $$REGIONS_ARR
2527
do
26-
echo "--> Tagging prev-release... $$_TOOL -> $$_REGION"
27-
28-
gcloud container images add-tag $$_REGION-docker.pkg.dev/$_IMAGE_PROJECT/wrappers/$$_TOOL:release $$_REGION-docker.pkg.dev/$_IMAGE_PROJECT/wrappers/$$_TOOL:prev-release -q
29-
exit_on_error $$?
28+
for _TOOL in $$TOOLS_ARR
29+
do
30+
echo "--> Tagging prev-release... $$_TOOL -> $$_REGION"
31+
gcloud container images add-tag $$_REGION-docker.pkg.dev/$$_PROJECT/wrappers/$$_TOOL:release $$_REGION-docker.pkg.dev/$$_PROJECT/wrappers/$$_TOOL:prev-release -q
32+
exit_on_error $$?
33+
done
34+
echo "----> Tagged all tools for $$_REGION done."
3035
done
31-
echo "----> Tagged all tools for $$_REGION done."
36+
echo "--> Finished Tagging prev-release for project $$_PROJECT"
3237
done
3338
34-
for _TOOL in $$TOOLS_ARR
39+
40+
for _PROJECT in ${GCP_PROJECTS_ARR[@]}
3541
do
36-
echo "--> Tagging prev-release... $$_TOOL -> gcr.io"
42+
for _TOOL in $$TOOLS_ARR
43+
do
44+
echo "--> Tagging prev-release for project $$_PROJECT... $$_TOOL -> gcr.io"
3745
38-
gcloud container images add-tag gcr.io/$_IMAGE_PROJECT/$$_TOOL:release gcr.io/$_IMAGE_PROJECT/$$_TOOL:prev-release -q
39-
exit_on_error $$?
46+
gcloud container images add-tag gcr.io/$$_PROJECT/$$_TOOL:release gcr.io/$$_PROJECT/$$_TOOL:prev-release -q
47+
exit_on_error $$?
48+
done
4049
done
4150
echo "----> Tagged all tools for gcr.io done."

rollout/cli_tools_cloudbuild_deploy.yaml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ steps:
1111
# It's specifically useful when the original workflow was failed and we resumed it.
1212
# 2. The commit SHA is used to track which version of source code produced the image.
1313
# 3. The "release" tag marks it as the current effective image.
14+
# NOTE: Wrappers will be pushed into 2 GCP projects. This is because we still
15+
# need to push to the old one for backward compatibility.
1416
- name: 'google/cloud-sdk:alpine'
1517
args:
1618
- 'bash'
1719
- '-c'
1820
- |
1921
REGIONS_ARR=$(echo "$_REGIONS" | tr ";" "\n")
2022
TOOLS_ARR=$(echo "$_TOOLS" | tr ";" "\n")
23+
GCP_PROJECTS_ARR=($_IMAGE_PROJECT_1 $_IMAGE_PROJECT_2)
2124
2225
exit_on_error() {
2326
ERR=$$1
@@ -27,19 +30,22 @@ steps:
2730
fi
2831
}
2932
30-
for _REGION in $$REGIONS_ARR
33+
for _PROJECT in $$GCP_PROJECTS_ARR
3134
do
32-
for _TOOL in $$TOOLS_ARR
35+
for _REGION in $$REGIONS_ARR
3336
do
34-
echo "--> Deploying... $$_TOOL -> $$_REGION"
37+
for _TOOL in $$TOOLS_ARR
38+
do
39+
echo "--> Deploying... $$_TOOL -> $$_REGION"
3540
36-
# Copy the new "release" from gcr.io and tag.
37-
gcloud container images add-tag gcr.io/$_IMAGE_PROJECT/$$_TOOL:release $$_REGION-docker.pkg.dev/$_IMAGE_PROJECT/wrappers/$$_TOOL:release -q
38-
exit_on_error $$?
39-
gcloud container images add-tag $$_REGION-docker.pkg.dev/$_IMAGE_PROJECT/wrappers/$$_TOOL:release $$_REGION-docker.pkg.dev/$_IMAGE_PROJECT/wrappers/$$_TOOL:$_WORKFLOW_EXECUTION_ID -q
40-
exit_on_error $$?
41-
gcloud container images add-tag $$_REGION-docker.pkg.dev/$_IMAGE_PROJECT/wrappers/$$_TOOL:release $$_REGION-docker.pkg.dev/$_IMAGE_PROJECT/wrappers/$$_TOOL:$COMMIT_SHA -q
42-
exit_on_error $$?
41+
# Copy the new "release" from gcr.io and tag.
42+
gcloud container images add-tag gcr.io/$$_PROJECT/$$_TOOL:release $$_REGION-docker.pkg.dev/$$_PROJECT/wrappers/$$_TOOL:release -q
43+
exit_on_error $$?
44+
gcloud container images add-tag $$_REGION-docker.pkg.dev/$$_PROJECT/wrappers/$$_TOOL:release $$_REGION-docker.pkg.dev/$$_PROJECT/wrappers/$$_TOOL:$_WORKFLOW_EXECUTION_ID -q
45+
exit_on_error $$?
46+
gcloud container images add-tag $$_REGION-docker.pkg.dev/$$_PROJECT/wrappers/$$_TOOL:release $$_REGION-docker.pkg.dev/$$_PROJECT/wrappers/$$_TOOL:$COMMIT_SHA -q
47+
exit_on_error $$?
48+
done
49+
echo "----> Deployed all tools for $$_REGION"
4350
done
44-
echo "----> Deployed all tools for $$_REGION"
4551
done

rollout/cli_tools_cloudbuild_rollback.yaml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ steps:
1111
# It's specifically useful when the original workflow was failed and we resumed it.
1212
# 2. The commit SHA is used to track which version of source code produced the image.
1313
# 3. The "release" tag marks it as the current effective image.
14+
# NOTE: Rollout will be done on 2 GCP project, this is because wrappers are be pushed into 2 GCP projects as
15+
# we still need to push to the old one for backward compatibility.
1416
- name: 'google/cloud-sdk:alpine'
1517
args:
1618
- 'bash'
1719
- '-c'
1820
- |
1921
REGIONS_ARR=$(echo "$_REGIONS" | tr ";" "\n")
2022
TOOLS_ARR=$(echo "$_TOOLS" | tr ";" "\n")
23+
GCP_PROJECTS_ARR=($_IMAGE_PROJECT_1 $_IMAGE_PROJECT_2)
2124
2225
exit_on_error() {
2326
ERR=$$1
@@ -27,23 +30,30 @@ steps:
2730
fi
2831
}
2932
30-
for _REGION in $$REGIONS_ARR
33+
34+
for _PROJECT in ${GCP_PROJECTS_ARR[@]}
3135
do
32-
for _TOOL in $$TOOLS_ARR
36+
echo "--> Start Rolling back for project $$_PROJECT .."
37+
for _REGION in $$REGIONS_ARR
3338
do
34-
echo "--> Rollback... $$_TOOL -> $$_REGION"
39+
for _TOOL in $$TOOLS_ARR
40+
do
41+
echo "--> Rollback... $$_TOOL -> $$_REGION"
3542
36-
gcloud container images add-tag $$_REGION-docker.pkg.dev/$_IMAGE_PROJECT/wrappers/$$_TOOL:prev-release $$_REGION-docker.pkg.dev/$_IMAGE_PROJECT/wrappers/$$_TOOL:release -q
37-
exit_on_error $$?
43+
gcloud container images add-tag $$_REGION-docker.pkg.dev/$$_PROJECT/wrappers/$$_TOOL:prev-release $$_REGION-docker.pkg.dev/$$_PROJECT/wrappers/$$_TOOL:release -q
44+
exit_on_error $$?
45+
done
46+
echo "----> Rollback all tools for $$_REGION done."
3847
done
39-
echo "----> Rollback all tools for $$_REGION done."
4048
done
4149
42-
for _TOOL in $$TOOLS_ARR
50+
for _PROJECT in ${GCP_PROJECTS_ARR[@]}
4351
do
44-
echo "--> Rollback... $$_TOOL -> gcr.io"
45-
46-
gcloud container images add-tag gcr.io/$_IMAGE_PROJECT/$$_TOOL:prev-release gcr.io/$_IMAGE_PROJECT/$$_TOOL:release -q
47-
exit_on_error $$?
52+
for _TOOL in $$TOOLS_ARR
53+
do
54+
echo "--> Rollback... $$_TOOL -> gcr.io in project $$_PROJECT"
55+
gcloud container images add-tag gcr.io/$$_PROJECT/$$_TOOL:prev-release gcr.io/$$_PROJECT/$$_TOOL:release -q
56+
exit_on_error $$?
57+
done
4858
done
4959
echo "----> Rollback all tools for gcr.io done."

0 commit comments

Comments
 (0)