-
Notifications
You must be signed in to change notification settings - Fork 53
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
gcp: support projects with no default permissions #3656
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for constellation-docs canceled.
|
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.
For the sake of not further complicating the iam create command, should we make it default to use the serviceAccountID
for the serviceAccountVMID
if the latter is not present? (i.e. the current behavior)
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.
Yeah, was also not sure about that. I think we can go with not having a flag at all and just appending "-vm" to the other one. Though of course something like "my-in-cluster-service-account-vm" is also weird. In a ideal goal scenario, we'd just have a given prefix as for the cluster creation and we can just derive everything from there.
Though, I'm interested about hearing opinions about what to implement in this PR. If we get one more vote for falling back to the other flag, then I'll go with that.
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.
Just making it a prefix is a great idea. Would also resemble what we currently have on AWS.
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 guess then I add a prefix flag to the command. While this is counter-intuitive behavior: should we make it have precedence over the serviceAccountID
if both are set, so we can set both in the CI and deprecate the old one slowly?
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.
Id not have both but remove serviceAccountID directly. (we can have breaking changes)
Having both would indeed be counter-intuitive. Or what was your point for that?
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 don't think we should have such breaking changes. One example is the upgrade CI e2e test. If you specify too many flags during iam create
it just fails, therefore, I think we need to have a migration plan (In my opinion not only for the e2e test but also for users).
b1b1b65
to
29cab93
Compare
29cab93
to
e152be0
Compare
This service account is used in the following commits and is attached to the VMs
e152be0
to
8c8587b
Compare
8c8587b
to
ce22bed
Compare
Coverage report
|
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.
Does the new service account attached to the VMs have sufficient permissions for the GCP CSI driver?
case cloudprovider.GCP: | ||
return true |
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.
Please add a TODO to remove this after the next release (just in case)
cmd.Flags().String("serviceAccountID", "", "[Deprecated use \"--prefix\"]ID for the service account that will be created (required)\n"+ | ||
"Must be 6 to 30 lowercase letters, digits, or hyphens. This flag is mutually exclusive with --prefix.") |
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.
cmd.Flags().String("serviceAccountID", "", "[Deprecated use \"--prefix\"]ID for the service account that will be created (required)\n"+ | |
"Must be 6 to 30 lowercase letters, digits, or hyphens. This flag is mutually exclusive with --prefix.") | |
cmd.Flags().String("serviceAccountID", "", "ID for the service account that will be created\n"+ | |
"Must be 6 to 30 lowercase letters, digits, or hyphens. This flag is mutually exclusive with --prefix.") | |
must(cmd.Flags().MarkDeprecated("serviceAccountID", "use \"--prefix\" instead"] |
Use MarkDeprecated
instead of manually adding a deprecation note.
This will cause the flag to not show up when running the command with --help
and will print Flag --serviceAccountID has been deprecated, use "--prefix" instead
when using it.
}, | ||
} | ||
} | ||
|
||
func (c *gcpIAMCreator) printConfirmValues(cmd *cobra.Command) { | ||
cmd.Printf("Project ID:\t\t%s\n", c.flags.projectID) | ||
cmd.Printf("Name Prefix:\t\t%s\n", c.flags.namePrefix) | ||
cmd.Printf("Service Account ID:\t%s\n", c.flags.serviceAccountID) |
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.
cmd.Printf("Service Account ID:\t%s\n", c.flags.serviceAccountID) | |
if c.flags.serviceAccountID != "" { | |
cmd.Printf("Service Account ID:\t%s\n", c.flags.serviceAccountID) | |
} |
Should now only be printed when the --prefix
flag wasn't set
Similarly, we might want to omit the output for name prefix if only --serviceAccountID
was set
@@ -102,7 +102,7 @@ If you encounter any problem with the following steps, make sure to use the [lat | |||
<TabItem value="gcp" label="GCP"> | |||
|
|||
```bash | |||
constellation iam create gcp --projectID=yourproject-12345 --zone=europe-west2-a --serviceAccountID=constell-test --update-config | |||
constellation iam create gcp --projectID=yourproject-12345 --zone=europe-west2-a --serviceAccountVMID=constell-test-vm --serviceAccountID=constell-test --update-config |
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.
constellation iam create gcp --projectID=yourproject-12345 --zone=europe-west2-a --serviceAccountVMID=constell-test-vm --serviceAccountID=constell-test --update-config | |
constellation iam create gcp --projectID=yourproject-12345 --zone=europe-west2-a --prefix=constell-test --update-config |
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.
owned files lgtm
zone = local.zone | ||
region = local.region | ||
source = "https://github.com/edgelesssys/constellation/releases/download/$VERSION/terraform-module.zip//terraform-module/iam/gcp" | ||
sproject_id = local.project_id |
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.
sproject_id = local.project_id | |
project_id = local.project_id |
Context
When creating VMs we used to rely on the following points:
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)
Checklist
e2e upgrade. gcp, snp: https://github.com/edgelesssys/constellation/actions/runs/13443379097e2e upgrade. gcp, snp: https://github.com/edgelesssys/constellation/actions/runs/13755459817https://github.com/edgelesssys/constellation/actions/runs/13762021363How to test: