-
Notifications
You must be signed in to change notification settings - Fork 841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
infra/gcp: disable containerscanning and test-infra-trusted prow access for staging and release projects #2016
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: spiffxp The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
#2067 is starting to pick up the results of me running some of these scripts while developing/testing this
I'm going to kick off a run of ensure-staging-storage.sh as I'm confident based on testing, but will refrain from running the rest until review. |
color 6 "Ensuring k8s-prow / test-infra-trusted can no longer use GCB in project: ${PROJECT}" | ||
ensure_removed_google_prow_bindings "${PROJECT}" "${GCB_BUCKET}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure but this part is applied once. Why do it ever time the script is used ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is to remove this in a follow-up PR. I was starting to get lazy by this point so I didn't go as far as making a "bindings to remove" array like I did in ensure-organizations.
#2067 now reflects all changes for release and staging projects |
/hold |
Describe the reason includes are sourced in the way they are Pull more constants into lib.sh and organize them by "purpose" and then alphabetically within. The following were added to lib, or scripts were modified to use these: - RELEASE_ADMINS, RELEASE_WRITERS, RELEASE_VIEWERS - PROW_GOOGLE_TRUSTED_SERVICE_ACCOUNT (formerly PROW_SVCACCT) - PROW_BUILD_SERVICE_ACCOUNT - PROW_TRUSTED_BUILD_CLUSTER_PROJECTS - PROW_UNTRUSTED_BUILD_CLUSTER_PROJECTS Shellcheck complains that some of these aren't used within lib.sh and should be exported if they're used elsewhere. Going to intentially hold off on that for now, it may turn out not all of these need to be "global", or that there's a better place to store these.
This was broken by a missing PROJECT_ID variable (probably by me in a previous attempt to refactor into functions) Fixed that, and did some other misc fixes: - move services to a readonly constant up top - use `project` instead of `project_id` - fix shellcheck nits - avoid funcname hardcode on args checks
Planning to overhaul ensure_services_only, so move service-related functions into their own lib_service.sh Moved the following over: - enable_api - _plan_enabled_services - ensure_only_services
specifically: - write the .jq file used by ensure_only_services only once - fix shellcheck nits - enable_api now supports N services; will rename in later commit
Since the gcloud command is `gcloud services` let's drop the API nomenclature, and pluralize to reflect that N services can be enabled at once now. Add a corresponding ensure_disabled_services function with a scary warning. While following the the rename, I also refactored to use lists of services if relevant, for: - ensure-prod-storage.sh - ensure-prod-storage-gclb.sh - ensure-env-cip-auditor.sh
Following a pattern that I've used for ensure-main-project.sh and ensure-organization.sh that involves moving everything into functions or readonly constants, and then an entrypoint at the bottom. So the entrypoint is no longer a massive for loop and blocks of code, but instead ensure_staging_projects, which calls: - ensure_staging_project for each repo, which calls: - ensure_staging_gcs_bucket - ensure_staging_gcr_repo - ensure_staging_gcb - staging_special_case__k8s_staging_foo (if it exists) - ensure_release_manager_special_cases I commented functions heavily, and dropped comments if the logging statement was basically saying the same thing. Other changes: - Stop using empower_prow, prep for using service-account per-project - Change ensure_staging_gcb_builder_service_account to also grant write access to GCS and GCR directly from that service account
There are no longer any jobs that run in test-infra-trusted using the deployer serviceaccount. Revoke that serviceaccount's access to any of the k8s-staging* or k8s-release* projects
Since I still don't trust ensure_only_services to do the right thing by default, and I know we want to disable the containerscanning service, add support for explicitly disabling services.
Well, I did more than fix the typo. Tried to rebase changes to make a little more sense. But I'm done adding anything more to this PR for real. The summary up top is still correct. |
Here's what I have run from HEAD of this PR so far
|
/hold cancel |
/lgtm |
late /lgtm |
Related to : #516 |
This is an attempt at making some progress on the audit followup issue to ensure we don't have random services enabled #1887
It's also more directly motivated by ensuring that containerscanning is disabled for #1963
EDIT: I'm going to cap this off before it gets too sprawling. See individual commits for details.
Brief summary:
lib_services.sh
, renameensure_api
toensure_services
lib.sh
ensure-staging-storage.sh
into functions, as has been done forensure-organization.sh
andensure-main-project.sh
ensure_disabled_services
deployer@k8s-prow
bindings from staging/release projects,test-infra-trusted
no longer runs jobs hereensure_staging_gcb_builder_service_account
toward something that will be used by default for all staging projects, to implement the "gcb account per staging project" approach described in Mitigate image-pushing jobs hitting GetRequestsPerMinutePerProject quota for prow build cluster project test-infra#20652 (comment) (which should also address cloudbuild job failed to access k8s-artifacts-csi #1544)