Skip to content

Commit c72a701

Browse files
authored
Merge pull request #553 from thockin/gcs-for-cni
Create a GCS bucket for CNI artifacts
2 parents 9be75de + 41ca3df commit c72a701

File tree

5 files changed

+51
-26
lines changed

5 files changed

+51
-26
lines changed

groups/groups.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,17 @@ groups:
287287
- spiffxp@google.com
288288
- thockin@google.com
289289

290+
- email-id: k8s-infra-push-cni@kubernetes.io
291+
name: k8s-infra-push-cni
292+
description: |-
293+
ACL for pushing CNI artifacts
294+
settings:
295+
ReconcileMembers: "true"
296+
members:
297+
- dcbw@redhat.com
298+
- stephen.k8s@agst.us
299+
- thockin@google.com
300+
290301
- email-id: k8s-infra-rbac-cert-manager@kubernetes.io
291302
name: k8s-infra-rbac-cert-manager
292303
description: |-

infra/gcp/ensure-prod-storage.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ ALL_PROD_PROJECTS=(
9090
# Regions for prod.
9191
PROD_REGIONS=(us eu asia)
9292

93+
# Minimum time we expect to keep prod artifacts.
94+
PROD_RETENTION="10y"
95+
9396
# Make the projects, if needed
9497
for prj in "${ALL_PROD_PROJECTS[@]}"; do
9598
color 6 "Ensuring project exists: ${prj}"
@@ -126,8 +129,7 @@ for prj in "${ALL_PROD_PROJECTS[@]}"; do
126129
ensure_public_gcs_bucket "${prj}" "gs://${prj}"
127130

128131
color 6 "Ensuring the GCS bucket retention policy is set: ${prj}"
129-
RETENTION="10y"
130-
ensure_gcs_bucket_retention "gs://${prj}" "${RETENTION}"
132+
ensure_gcs_bucket_retention "gs://${prj}" "${PROD_RETENTION}"
131133

132134
color 6 "Empowering GCS admins: ${prj}"
133135
empower_gcs_admins "${prj}" "gs://${prj}"
@@ -143,6 +145,20 @@ upload_gcs_static_content \
143145
"gs://${PROD_PROJECT}" \
144146
"${SCRIPT_DIR}/static/prod-storage"
145147

148+
# Special case: grant the push groups access to their buckets.
149+
# This is for serving CNI artifacts. We need a new bucket for this because
150+
# there's no concept of permissions on a "subdirectory" of a bucket. So until we
151+
# have a promoter for k8s-artifacts-prod, we do this.
152+
CNI_BUCKET="k8s-artifacts-cni"
153+
CNI_GROUP="k8s-infra-push-cni@kubernetes.io"
154+
color 6 "Ensuring the CNI GCS bucket exists and is readable"
155+
ensure_public_gcs_bucket "${PROD_PROJECT}" "gs://${CNI_BUCKET}"
156+
color 6 "Ensuring the CNI GCS bucket retention policy is set"
157+
ensure_gcs_bucket_retention "gs://${CNI_BUCKET}" "${PROD_RETENTION}"
158+
color 6 "Empowering GCS admins to CNI"
159+
empower_gcs_admins "${PROD_PROJECT}" "gs://${CNI_BUCKET}"
160+
empower_group_to_write_gcs_bucket "${CNI_GROUP}" "gs://${CNI_BUCKET}"
161+
146162
# Special case: grant the image promoter testing group access to their fake
147163
# prod projects.
148164
empower_group_to_fake_prod \

infra/gcp/ensure-release-projects.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ for PROJECT; do
105105
# Enable writers on the bucket
106106
for group in ${ADMINS} ${WRITERS}; do
107107
color 6 "Empowering ${group} to GCS"
108-
empower_group_to_gcs_bucket "${group}" "${BUCKET}"
108+
empower_group_to_write_gcs_bucket "${group}" "${BUCKET}"
109109
done
110110
done
111111

infra/gcp/ensure-staging-storage.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ for REPO; do
141141

142142
# Enable writers on the bucket
143143
color 6 "Empowering ${WRITERS} to GCS"
144-
empower_group_to_gcs_bucket "${WRITERS}" "${BUCKET}"
144+
empower_group_to_write_gcs_bucket "${WRITERS}" "${BUCKET}"
145145
done
146146

147147
# Enable GCB and Prow to build and push images.

infra/gcp/lib.sh

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -347,16 +347,8 @@ function empower_gcr_admins() {
347347
region="${2:-}"
348348
bucket=$(gcs_bucket_for_gcr "${project}" "${region}")
349349

350-
# Grant project viewer so the UI will work.
351350
empower_group_as_viewer "${project}" "${GCR_ADMINS}"
352-
353-
# Grant admins access to do admin stuff.
354-
gsutil iam ch \
355-
"group:${GCR_ADMINS}:objectAdmin" \
356-
"${bucket}"
357-
gsutil iam ch \
358-
"group:${GCR_ADMINS}:legacyBucketOwner" \
359-
"${bucket}"
351+
empower_group_to_admin_gcs_bucket "${GCR_ADMINS}" "${bucket}"
360352
}
361353

362354
# Grant full privileges to GCS admins
@@ -370,16 +362,8 @@ function empower_gcs_admins() {
370362
project="${1}"
371363
bucket="${2}"
372364

373-
# Grant project viewer so the UI will work.
374365
empower_group_as_viewer "${project}" "${GCS_ADMINS}"
375-
376-
# Grant admins access to do admin stuff.
377-
gsutil iam ch \
378-
"group:${GCS_ADMINS}:objectAdmin" \
379-
"${bucket}"
380-
gsutil iam ch \
381-
"group:${GCS_ADMINS}:legacyBucketOwner" \
382-
"${bucket}"
366+
empower_group_to_admin_gcs_bucket "${GCS_ADMINS}" "${bucket}"
383367
}
384368

385369
# Grant GCR write privileges to a group
@@ -396,6 +380,20 @@ function empower_group_to_gcr() {
396380
region="${3:-}"
397381
bucket=$(gcs_bucket_for_gcr "${project}" "${region}")
398382

383+
empower_group_to_write_gcs_bucket "${group}" "${bucket}"
384+
}
385+
386+
# Grant write privileges on a bucket to a group
387+
# $1: The googlegroups group
388+
# $2: The bucket
389+
function empower_group_to_write_gcs_bucket() {
390+
if [ $# -lt 2 -o -z "$1" -o -z "$2" ]; then
391+
echo "empower_group_to_write_gcs_bucket(group_name, bucket) requires 2 arguments" >&2
392+
return 1
393+
fi
394+
group="$1"
395+
bucket="$2"
396+
399397
gsutil iam ch \
400398
"group:${group}:objectAdmin" \
401399
"${bucket}"
@@ -404,12 +402,12 @@ function empower_group_to_gcr() {
404402
"${bucket}"
405403
}
406404

407-
# Grant write privileges on a bucket to a group
405+
# Grant admin privileges on a bucket to a group
408406
# $1: The googlegroups group
409407
# $2: The bucket
410-
function empower_group_to_gcs_bucket() {
408+
function empower_group_to_admin_gcs_bucket() {
411409
if [ $# -lt 2 -o -z "$1" -o -z "$2" ]; then
412-
echo "empower_group_to_gcs_bucket(group_name, bucket) requires 2 arguments" >&2
410+
echo "empower_group_to_admin_gcs_bucket(group_name, bucket) requires 2 arguments" >&2
413411
return 1
414412
fi
415413
group="$1"
@@ -419,7 +417,7 @@ function empower_group_to_gcs_bucket() {
419417
"group:${group}:objectAdmin" \
420418
"${bucket}"
421419
gsutil iam ch \
422-
"group:${group}:legacyBucketReader" \
420+
"group:${group}:legacyBucketOwner" \
423421
"${bucket}"
424422
}
425423

0 commit comments

Comments
 (0)