-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #434 from justaugustus/grant-releng
releng: Enable elevated privileges for Release Managers on SIG Release GCP projects
- Loading branch information
Showing
3 changed files
with
233 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright 2019 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# This script is used to ensure Release Managers have the appropriate access | ||
# to SIG Release GCP projects. | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}") | ||
. "${SCRIPT_DIR}/lib.sh" | ||
|
||
function usage() { | ||
echo "usage: $0 [project...]" > /dev/stderr | ||
echo "example:" > /dev/stderr | ||
echo " $0 # do all release projects" > /dev/stderr | ||
echo " $0 k8s-staging-release-test # just do one" > /dev/stderr | ||
echo > /dev/stderr | ||
} | ||
|
||
# NB: Please keep this sorted. | ||
PROJECTS=( | ||
k8s-staging-release-test | ||
k8s-release-test-prod | ||
) | ||
|
||
if [ $# = 0 ]; then | ||
# default to all release projects | ||
set -- "${PROJECTS[@]}" | ||
fi | ||
|
||
ADMINS="k8s-infra-release-admins@kubernetes.io" | ||
WRITERS="k8s-infra-release-editors@kubernetes.io" | ||
VIEWERS="k8s-infra-release-viewers@kubernetes.io" | ||
|
||
for PROJECT; do | ||
color 3 "Configuring: ${REPO}" | ||
|
||
# The names of the buckets | ||
STAGING_BUCKET="gs://${PROJECT}" # used by humans | ||
GCB_BUCKET="gs://${PROJECT}-gcb" # used by GCB | ||
ALL_BUCKETS=("${STAGING_BUCKET}" "${GCB_BUCKET}") | ||
|
||
# Make the project, if needed | ||
color 6 "Ensuring project exists: ${PROJECT}" | ||
ensure_project "${PROJECT}" | ||
|
||
for group in ${ADMINS} ${WRITERS} ${VIEWERS}; do | ||
# Enable admins to use the UI | ||
color 6 "Empowering ${group} as project viewers" | ||
empower_group_as_viewer "${PROJECT}" "${group}" | ||
done | ||
|
||
# Every project gets a GCR repo | ||
|
||
# Enable container registry APIs | ||
color 6 "Enabling the container registry API" | ||
enable_api "${PROJECT}" containerregistry.googleapis.com | ||
|
||
# Push an image to trigger the bucket to be created | ||
color 6 "Ensuring the registry exists and is readable" | ||
ensure_gcr_repo "${PROJECT}" | ||
|
||
# Enable GCR admins | ||
color 6 "Empowering GCR admins" | ||
empower_gcr_admins "${PROJECT}" | ||
|
||
# Enable GCR writers | ||
for group in ${ADMINS} ${WRITERS}; do | ||
color 6 "Empowering ${group} to GCR" | ||
empower_group_to_gcr "${PROJECT}" "${group}" | ||
done | ||
|
||
# Every project gets some GCS buckets | ||
|
||
# Enable GCS APIs | ||
color 6 "Enabling the GCS API" | ||
enable_api "${PROJECT}" storage-component.googleapis.com | ||
|
||
for BUCKET in "${ALL_BUCKETS[@]}"; do | ||
color 3 "Configuring bucket: ${BUCKET}" | ||
|
||
# Create the bucket | ||
color 6 "Ensuring the bucket exists and is world readable" | ||
ensure_public_gcs_bucket "${PROJECT}" "${BUCKET}" | ||
|
||
# Enable admins on the bucket | ||
color 6 "Empowering GCS admins" | ||
empower_gcs_admins "${PROJECT}" "${BUCKET}" | ||
|
||
# Enable writers on the bucket | ||
for group in ${ADMINS} ${WRITERS}; do | ||
color 6 "Empowering ${group} to GCS" | ||
empower_group_to_gcs_bucket "${group}" "${BUCKET}" | ||
done | ||
done | ||
|
||
# Enable GCB and Prow to build and push images. | ||
|
||
# Enable GCB APIs | ||
color 6 "Enabling the GCB API" | ||
enable_api "${PROJECT}" cloudbuild.googleapis.com | ||
|
||
# Let project writers use GCB. | ||
for group in ${ADMINS} ${WRITERS}; do | ||
color 6 "Empowering ${group} as GCB editors" | ||
empower_group_for_gcb "${PROJECT}" "${group}" | ||
done | ||
|
||
# Let prow trigger builds and access the scratch bucket | ||
color 6 "Empowering Prow" | ||
empower_prow "${PROJECT}" "${GCB_BUCKET}" | ||
|
||
# Enable KMS APIs | ||
color 6 "Enabling the KMS API" | ||
enable_api "${PROJECT}" cloudkms.googleapis.com | ||
|
||
# Let project admins use KMS. | ||
color 6 "Empowering ${ADMINS} as KMS admins" | ||
empower_group_for_kms "${PROJECT}" "${ADMINS}" | ||
|
||
color 6 "Done" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters