This repository has been archived by the owner on Mar 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
227 lines (201 loc) · 7.48 KB
/
dag-push-production.yaml
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
name: Build Packages Prod using dag
on:
workflow_dispatch:
push:
branches:
- main
env:
PROJECT: prod-images-c6e5
CLUSTER_NAME: tmp-cluster-prod-stage3-${{github.run_id}}
CLUSTER_ZONE: us-central1-b
SERVICE_ACCOUNT: prod-images-ci
FQ_SERVICE_ACCOUNT: prod-images-ci@prod-images-c6e5.iam.gserviceaccount.com
BUCKET: wolfi-production-registry-source/bootstrap/stage3/
SRC_BUCKET: gs://wolfi-production-registry-destination/bootstrap/stage3/
jobs:
setup-cluster:
name: Setup build cluster
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: google-github-actions/auth@v0
with:
workload_identity_provider: "projects/618116202522/locations/global/workloadIdentityPools/prod-shared-e350/providers/prod-shared-gha"
service_account: ${{env.FQ_SERVICE_ACCOUNT}}
- uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{env.PROJECT}}
- uses: actions/checkout@v3
with:
repository: wolfi-dev/dag
path: ${{github.workspace}}/dag
fetch-depth: 0
- name: Setup Build Cluster
working-directory: ${{github.workspace}}/dag
run: |
gcloud container clusters create "${CLUSTER_NAME}" \
--enable-ip-alias \
--network projects/prod-shared-37eb/global/networks/prod-shared-586cca3 \
--subnetwork projects/prod-shared-37eb/regions/us-central1/subnetworks/prod-shared-imgs-us-c1-b9c111f \
--cluster-secondary-range-name gke-a-pods \
--services-secondary-range-name gke-a-svcs \
--tags "egress-inet" \
--enable-dataplane-v2 \
--enable-intra-node-visibility \
--service-account "${FQ_SERVICE_ACCOUNT}" \
--zone "${CLUSTER_ZONE}" \
--release-channel rapid \
--workload-pool "${PROJECT}.svc.id.goog" \
--machine-type e2-standard-32 \
--num-nodes 1
gcloud container node-pools create arm-nodes \
--cluster "${CLUSTER_NAME}" \
--zone "${CLUSTER_ZONE}" \
--tags "egress-inet" \
--service-account "${FQ_SERVICE_ACCOUNT}" \
--machine-type t2a-standard-32 \
--num-nodes 1
- uses: imjasonh/gke-auth@v0.2.0
with:
project: "${PROJECT}"
location: "${CLUSTER_ZONE}"
cluster: "${CLUSTER_NAME}"
- working-directory: ${{github.workspace}}/dag
run: |
git checkout c8bb454c91090f3aa3916a65dc55488864af7169
./scripts/setup-cluster.sh ${SERVICE_ACCOUNT}
build-amd64:
name: Build (amd64)
runs-on: ubuntu-latest
needs: setup-cluster
permissions:
id-token: write
contents: read
steps:
# Checkout and build dag from main
# Can't `go install` because its go.mod has `replace`s.
- uses: actions/setup-go@v3
with:
go-version: '>=1.19.0'
- uses: actions/checkout@v3
with:
repository: wolfi-dev/dag
path: ${{github.workspace}}/dag
fetch-depth: 0
- working-directory: ${{github.workspace}}/dag
run: |
git checkout c8bb454c91090f3aa3916a65dc55488
go install
- uses: google-github-actions/auth@v0
with:
workload_identity_provider: "projects/618116202522/locations/global/workloadIdentityPools/prod-shared-e350/providers/prod-shared-gha"
service_account: ${{env.FQ_SERVICE_ACCOUNT}}
- uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{env.PROJECT}}
- uses: 'google-github-actions/get-gke-credentials@v0'
with:
cluster_name: ${{ env.CLUSTER_NAME }}
location: ${{ env.CLUSTER_ZONE }}
- run: gcloud auth configure-docker --quiet
- uses: actions/checkout@v3
with:
repository: wolfi-dev/bootstrap-stage3
path: ${{github.workspace}}/bootstrap-stage3
- working-directory: ${{github.workspace}}/bootstrap-stage3
run: |
dag pod \
--cpu=30 --ram=100Gi \
--bucket=${BUCKET} \
--src-bucket=${SRC_BUCKET} \
--secret-key
build-arm64:
name: Build (arm64)
runs-on: ubuntu-latest
needs: setup-cluster
permissions:
id-token: write
contents: read
steps:
# Checkout and build dag from main
# Can't `go install` because its go.mod has `replace`s.
- uses: actions/setup-go@v3
with:
go-version: '>=1.19.0'
- uses: actions/checkout@v3
with:
repository: wolfi-dev/dag
path: ${{github.workspace}}/dag
fetch-depth: 0
- working-directory: ${{github.workspace}}/dag
run: |
git checkout c8bb454c91090f3aa3916a65dc55488864af7169
go install
- uses: google-github-actions/auth@v0
with:
workload_identity_provider: "projects/618116202522/locations/global/workloadIdentityPools/prod-shared-e350/providers/prod-shared-gha"
service_account: ${{env.FQ_SERVICE_ACCOUNT}}
- uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{env.PROJECT}}
- uses: 'google-github-actions/get-gke-credentials@v0'
with:
cluster_name: ${{ env.CLUSTER_NAME }}
location: ${{ env.CLUSTER_ZONE }}
- run: gcloud auth configure-docker --quiet
- uses: actions/checkout@v3
with:
repository: wolfi-dev/bootstrap-stage3
path: ${{github.workspace}}/bootstrap-stage3
- working-directory: ${{github.workspace}}/bootstrap-stage3
run: |
dag pod \
--cpu=30 --ram=100Gi \
--bucket=${BUCKET} \
--src-bucket=${SRC_BUCKET} \
--secret-key \
--arch=arm64
teardown-cluster:
name: Teardown build cluster
runs-on: ubuntu-latest
needs: [build-amd64, build-arm64]
if: always()
permissions:
id-token: write
contents: read
steps:
- uses: google-github-actions/auth@v0
with:
workload_identity_provider: "projects/618116202522/locations/global/workloadIdentityPools/prod-shared-e350/providers/prod-shared-gha"
service_account: ${{env.FQ_SERVICE_ACCOUNT}}
- uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{env.PROJECT}}
- uses: 'google-github-actions/get-gke-credentials@v0'
with:
cluster_name: ${{ env.CLUSTER_NAME }}
location: ${{ env.CLUSTER_ZONE }}
- name: Collect diagnostics
if: always()
run: |
resources="pods daemonsets serviceaccounts namespaces"
for ns in $(kubectl get ns -oname | cut -d'/' -f 2); do
for resource in ${resources}; do
echo --- $ns $resource ---
kubectl get $resource -n${ns}
for x in $(kubectl get $resource -n${ns} -oname || true); do
echo "::group:: describe $resource $x"
# Don't fail if the resource disappears midway.
kubectl describe -n${ns} $x || true
echo '::endgroup::'
done
done
done
- name: Teardown Build Cluster
if: always()
run: |
gcloud container clusters delete "${CLUSTER_NAME}" \
--zone "${CLUSTER_ZONE}" \
--quiet