-
Notifications
You must be signed in to change notification settings - Fork 116
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
"pulumi preview" needs 'patch' permission when SSA is enabled #2213
Comments
Hi @antifuchs, thanks for the report. I want to clarify that the preview step does not modify any resources. The Server-Side Apply feature uses the Patch API, but it's using the dry-run mode. The permissions you listed,
To disable the Server-Side Apply feature, you have the following options to set Provider configuration:
|
Thanks for the clarification! I'd argue that the dry-run distinction is pretty meaningless if there exists no set of k8s permissions exists that allows preview but doesn't allow untrusted code to create resources via a pull request (: Anyway, I have tried the workarounds that you list:
I'm not sure why scenario two doesn't help - here's our diff from each our stack config files (forgive the imprecise comment please, it's verbatim from us trying this change before you posted): diff --git a/Pulumi.personal.yaml b/Pulumi.personal.yaml
index 45a5ed54..81f49816 100644
--- a/Pulumi.personal.yaml
+++ b/Pulumi.personal.yaml
@@ -23,6 +23,7 @@ config:
# Kubernetes provider configuration.
kubernetes:kubeconfig: invalid
+ kubernetes:enableServerSideApply: false
# ==> Materialize Cloud-specific configuration.
mzcloud:admin_sso_role: arn:aws:iam::725780499770:role/AWSReservedSSO_Administrator_b08b525ab43925ee
diff --git a/Pulumi.production.yaml b/Pulumi.production.yaml
index b719b2ef..0b9c732b 100644
--- a/Pulumi.production.yaml
+++ b/Pulumi.production.yaml
@@ -39,6 +39,14 @@ config:
# See: https://github.com/pulumi/pulumi/issues/3383
kubernetes:kubeconfig: invalid
+ # Disable kubernetes server-side apply (SSA), which is buggy; Some
+ # providers like pulumi-eks pull in the "latest" version of the
+ # provider and create their own k8s providers with default values
+ # (https://github.com/pulumi/pulumi-eks/issues/800), which turns on
+ # SSA for their own operations, and that causes things like "pulumi
+ # preview" to attempt to modify resources on the server.
+ kubernetes:enableServerSideApply: false
+
# ==> Materialize Cloud-specific configuration.
# The role created for admins who sign in via SSO. We'll be able to fetch
# this more dynamically when pulumi/pulumi-aws#1460 is resolved.
diff --git a/Pulumi.staging.yaml b/Pulumi.staging.yaml
index 661ab04c..6aad0f51 100644
--- a/Pulumi.staging.yaml
+++ b/Pulumi.staging.yaml
@@ -39,6 +39,14 @@ config:
# See: https://github.com/pulumi/pulumi/issues/3383
kubernetes:kubeconfig: invalid
+ # Disable kubernetes server-side apply (SSA), which is buggy; Some
+ # providers like pulumi-eks pull in the "latest" version of the
+ # provider and create their own k8s providers with default values
+ # (https://github.com/pulumi/pulumi-eks/issues/800), which turns on
+ # SSA for their own operations, and that causes things like "pulumi
+ # preview" to attempt to modify resources on the server.
+ kubernetes:enableServerSideApply: false
+
# ==> Materialize Cloud-specific configuration.
# The role created for admins who sign in via SSO. We'll be able to fetch
# this more dynamically when pulumi/pulumi-aws#1460 is resolved. |
I agree that this seems like an unfortunate side effect of the Kubernetes API design here. I'll have to look and see if there are any open issues upstream about that. Edit: I found some related discussions upstream:
I just double-checked the stack configuration locally and confirmed that the setting you indicated disables SSA mode for me. We'll need to do some more investigation to see if we can find out why that didn't work for you. |
After discussion with @ringods, it sounds like this is due to the way pulumi-eks interacts with pulumi-kubernetes: It disregards the |
NB @pulumi/kubernetes v3.22.1 reverts to SSA being disabled by default. It sounds from the above like this will make the symptom go away -- pulumi-eks will use the most recent version of pulumi-kubernetes, with server-side apply disabled (again). The problem of SSA needing elevated permissions for preview still remains (though largely out of our hands?), so I'll leave this issue open. |
It is arguable, that is certain :-) Assuming (or pretending) that there's an account with write permissions that you use for deployments: if there were some objects in your stack that that account couldn't update, you would want preview to tell you, wouldn't you? |
What we'd really need from the Kubernetes API is a verb something like "impersonate-for-dry-run", which lets you impersonate another account, but restricts your requests to only those marked as dry-run. |
I spent some more time reading through the upstream discussion about this, and it looks like Given that information, I see the following alternatives:
Unfortunately, both of these approaches have significant drawbacks. Fundamentally, the only way to get an accurate preview of changes with the current Kubernetes API is to allow |
Any recommendations on how to safely do previews from a non-protected branch? Our current workflow uses the Pulumi GitLab integration to add comments to the MR with the results of the preview. When using server side apply, I believe this will fail unless that preview jobs have patch permissions which would not be secure to allow on a non-protected branch. |
Yeah, it's unfortunate that the upstream design here lumps the different types of operations together into the same verb. It seems like the least disruptive change for us may be to use some form of client-side preview as a fallback option. Unfortunately, client-side support is based on the Can you open a new issue with details on your requirements? I think the client-side fallback idea warrants further investigation, and would also be open to suggestions if you have ideas about this. |
What happened?
Thanks to pulumi/pulumi-eks#800 we got a preview of what enabling SSA via pulumi-k8s 3.22.0 does to our infra-as-code config (we pin 3.21.4):
pulumi preview
with kubernetes credentials that only allow read, list, watch of all resources (never create/modify).aws-auth
configmap in the cluster.This results in the following error message:
Steps to reproduce
pulumi preview
with those read-only credentialsExpected Behavior
pulumi preview
should never attempt to modify any data.Actual Behavior
pulumi preview
attempts to modify data and is (thankfully!) not permitted to.Output of
pulumi about
Additional context
We're attempting to "pin" the pulumi-kubernetes provider at 3.21.4 while we figure out how to live without SSA for the time being - ineffectively. I'm going to post about our problems in pulumi/pulumi#10758 to hopefully get us a solution for opting into our own upgrade cadence.
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
The text was updated successfully, but these errors were encountered: