Skip to content
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

Replace GCP_ADC_FILE with a service account key #14893

Merged
merged 1 commit into from
Nov 28, 2022
Merged

Conversation

mads-hartmann
Copy link
Contributor

@mads-hartmann mads-hartmann commented Nov 23, 2022

Description

The PR removes the use of the Gitpod User Environment Variable GCP_ADC_FILE in favour of a much more tightly scoped service account key which is controlled as a Gitpod Project Environment Variable PREVIEW_ENV_DEV_SA_KEY.

PREVIEW_ENV_DEV_SA_KEY is configured centrally which means that it's much easier for us to rotate. The service account has a limited set of roles assigned and only has access to the gitpod-core-dev GCP project which means that the blast radius is much smaller if it is ever leaked. For more information about this see our internal RFC Removing GCP_ADC_FILE.

By using a Project Environment variable we get the benefit that it will be accessible during prebuild execution. This means that when we build previewctl it will be able to use the remote leeway cache rather than build it every time. Unfortunately there's a bug in Leeway that means we don't populate the cache at the moment, so we don't see this improvement yet: gitpod-io/leeway#137 ➡️ Writing the service account key to disk means it would be part of the prebuild - and while it was in /home/gitpod/.config which isn't part of prebuilds today (only files in /workspace are) that might change in the future, so to be safe we no longer use the key during prebuilds.

Using this service account also eliminate the current manual step of gcloud auth login --no-launch-browser which was needed to get access to the leeway caches - this means that leeway run dev:prevew will no longer require that you sign in to GCP.

Related Issue(s)

Part of https://github.com/gitpod-io/security/issues/79
Fixes #13714

How to test

Test that dev:preview still works

leeway run dev:preview

Test that the Werft job still works

werft job run github -a with-preview=true

Release Notes

NONE

Documentation

N/A

Werft options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh

- name: build
description: Build all packages needed to deploy Gitpod to preview environments
script: ./workflow/preview/build.sh

- name: get-credentials
Copy link
Contributor Author

@mads-hartmann mads-hartmann Nov 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was only used one place which I got rid of in this PR so I'm removing the script.

@mads-hartmann
Copy link
Contributor Author

Converted back to draft as it turns out prebuilds are repo-global so we shouldn't write the service key to disk as part of the "before" step. We're currently writing it to /home/gitpod/.config/gcloud/preview-environment-dev-sa.json which isn't part of /workspace so it won't be part of the prebuild anyway at the moment - however this might change if/when we switch to full workspace backups - so it would be best IMO to only write it to disk as part of "command" and in "init" only make the key temporarily available.

@mads-hartmann mads-hartmann force-pushed the mads/remove-adc branch 4 times, most recently from 7904879 to 72fdc35 Compare November 25, 2022 10:59
@@ -27,8 +28,7 @@ fi

ensure_gcloud_auth

leeway run dev/preview:get-credentials
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now part of the workspace configuration instead

@github-actions
Copy link
Contributor

⚠️ Hey reviewer! BE CAREFUL ⚠️
Review the code before opening in your Gitpod. .gitpod.yml was changed and it might be harmful.

@mads-hartmann mads-hartmann marked this pull request as ready for review November 25, 2022 12:10
@mads-hartmann mads-hartmann requested review from a team November 25, 2022 12:10
Copy link
Contributor

@Pothulapati Pothulapati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preview Environments worked for me as expected! Always 💯 for reducing 💣 radius!

@roboquat roboquat merged commit a0a88cd into main Nov 28, 2022
@roboquat roboquat deleted the mads/remove-adc branch November 28, 2022 12:15
@mads-hartmann mads-hartmann mentioned this pull request Nov 28, 2022
4 tasks
@roboquat roboquat added the deployed: IDE IDE change is running in production label Nov 28, 2022
@roboquat roboquat added the deployed: workspace Workspace team change is running in production label Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: IDE IDE change is running in production deployed: workspace Workspace team change is running in production release-note-none size/L team: devx team: IDE team: SID team: workspace Issue belongs to the Workspace team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Leeway: Use branch build cache by default without requiring gcloud auth login
6 participants