8000 gcp: support projects with no default permissions by 3u13r · Pull Request #3656 · edgelesssys/constellation · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

gcp: support projects with no default permissions #3656

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

Merged
merged 6 commits into from
Mar 25, 2025

Conversation

3u13r
Copy link
Contributor
@3u13r 3u13r commented Feb 20, 2025

Context

When creating VMs we used to rely on the following points:

  1. The default project service account is automatically attached to every VM in the project, which doesn't override it
  2. The default service account used to have many permissions due having the Editor role attached by default (see: https://cloud.google.com/iam/docs/service-account-types#default)
  3. Though, the scopes added to the VM filtered how this service account could be used

Since GCP now doesn't give the project service account Editor by default, we need to create our own service account with minimal permissions. Note that the filtering over scopes is deprecated, one should simply attach a service account with minimal permissions and maximum scope.

Not only the Bootstrapper on the VM but also the constellation-operator and join-service automatically used the project service account per default, since we didn't explicitly set the service account already create for (and used by) other cluster components.
Since we want the VMs permissions to be as narrow as possible, we need to pass the in-cluster service account to also the constellation-operator and join-service.

Proposed change(s)

  • Create a second very narrow, read-only service account and attach it to VMs
  • Don't filter via scope anymore
  • Attach the in-cluster service account to the constellation-operator and join-service

Checklist

How to test:

  • Create/upgrade your gcp iam credentials
  • Successfully start a cluster, neither the bootstrapper, operator or the joinservice should error

@3u13r 3u13r added the feature This introduces new functionality label Feb 20, 2025
@3u13r 3u13r added this to the v2.21.0 milestone Feb 20, 2025
Copy link
netlify bot commented Feb 20, 2025

Deploy Preview for constellation-docs ready!

Name Link
🔨 Latest commit 760bbea
🔍 Latest deploy log https://app.netlify.com/sites/constellation-docs/deploys/67e2a67a7a53e60009fac6bf
😎 Deploy Preview https://deploy-preview-3656--constellation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@3u13r 3u13r added the breaking change Change breaks existing API or configuration. label Feb 20, 2025
@3u13r 3u13r force-pushed the euler/feat/gcp/vm-serviceaccount branch 2 times, most recently from b1b1b65 to 29cab93 Compare March 10, 2025 10:08
@3u13r 3u13r added the iam upgrade Indicate that a cluster upgrade requires `iam upgrade apply` label Mar 10, 2025
@3u13r 3u13r force-pushed the euler/feat/gcp/vm-serviceaccount branch 3 times, most recently from 8c8587b to ce22bed Compare March 10, 2025 13:14
@3u13r 3u13r marked this pull request as ready for review March 10, 2025 13:21
Copy link
Member
@daniel-weisse daniel-weisse left a comment

Choose a reason for hiding this comment

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

Does the new service account attached to the VMs have sufficient permissions for the GCP CSI driver?

Copy link
Contributor
@elchead elchead left a comment

Choose a reason for hiding this comment

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

owned files lgtm

@3u13r 3u13r force-pushed the euler/feat/gcp/vm-serviceaccount branch from ce22bed to 6b0ae20 Compare March 12, 2025 14:17
@3u13r 3u13r requested review from daniel-weisse and msanft March 12, 2025 14:18
@3u13r 3u13r force-pushed the euler/feat/gcp/vm-serviceaccount branch from 6b0ae20 to e1175a7 Compare March 12, 2025 14:47
Copy link
Member
@daniel-weisse daniel-weisse left a comment

Choose a reason for hiding this comment

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

Getting an error when running e2e tests during constellation iam create:

 An error occurred: terraform apply: exit status 1
Error: "account_id" ("e2e-13852850608-1-fe70a4d4-sa-vm") must be between 6 and 30 characters long
  with google_service_account.service_account_vm,
  on main.tf line 22, in resource "google_service_account" "service_account_vm":
  22:   account_id   = local.sa_vm_name
Attempting to roll back.
Rollback succeeded.
Error: terraform apply: exit status 1
Error: "account_id" ("e2e-13852850608-1-fe70a4d4-sa-vm") must be between 6 and 30 characters long
  with google_service_account.service_account_vm,
  on main.tf line 22, in resource "google_service_account" "service_account_vm":
  22:   account_id   = local.sa_vm_name

https://github.com/edgelesssys/constellation/actions/runs/13852850608/job/38763459800

@3u13r 3u13r force-pushed the euler/feat/gcp/vm-serviceaccount branch 2 times, most recently from 26ffa8d to f778d4e Compare March 14, 2025 13:56
@3u13r
Copy link
Contributor Author
3u13r commented Mar 14, 2025

@3u13r 3u13r force-pushed the euler/feat/gcp/vm-serviceaccount branch 2 times, most recently from 64d6c30 to 697a986 Compare March 23, 2025 20:21
@3u13r 3u13r force-pushed the euler/feat/gcp/vm-serviceaccount branch from 697a986 to 34b62f6 Compare March 25, 2025 00:07
Copy link
Contributor
@msanft msanft left a comment

Choose a reason for hiding this comment

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

Ignored all the nits for now so we can get this PR through with.

My only observation is that we seem to (partly) attach the roles on K8s resource level now. Wouldn't it be enough to just attach the accounts to the VMs on Terraform level?
Just for my understanding.

Otherwise, good to merge for me.

@3u13r 3u13r force-pushed the euler/feat/gcp/vm-serviceaccount branch from 34b62f6 to 76170d4 Compare March 25, 2025 09:38
@3u13r 3u13r force-pushed the euler/feat/gcp/vm-serviceaccount branch from 76170d4 to 8924d24 Compare March 25, 2025 12:41
@3u13r 3u13r modified the milestones: v2.21.0, v2.22.0 Mar 25, 2025
Copy link
Contributor

Coverage report

Package Old New Trend
cli/internal/cloudcmd 63.90% 63.70% ↘️
cli/internal/cmd 57.90% 57.80% ↘️
cli/internal/terraform 69.60% 69.80% ↗️
internal/config 77.10% 77.20% ↗️

1 similar comment
Copy link
Contributor

Coverage report

Package Old New Trend
cli/internal/cloudcmd 63.90% 63.70% ↘️
cli/internal/cmd 57.90% 57.80% ↘️
cli/internal/terraform 69.60% 69.80% ↗️
internal/config 77.10% 77.20% ↗️

@3u13r 3u13r merged commit 66815a4 into main Mar 25, 2025
13 checks passed
@3u13r 3u13r deleted the euler/feat/gcp/vm-serviceaccount branch March 25, 2025 13:13
@msanft msanft mentioned this pull request Apr 22, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Change breaks existing API or configuration. feature This introduces new functionality iam upgrade Indicate that a cluster upgrade requires `iam upgrade apply`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0