https://pulumi.com logo
#general
Title
# general
g

gorgeous-minister-41131

05/28/2021, 1:07 AM
Anyone have any suggestions or best practices for having pulumi edit an existing resource in an k8s/EKS cluster? Example: I want to tweak something about the default
kube-proxy
daemonset that gets deployed to fresh EKS clusters… would I use a get? I presume I’d have to import the resource first…
l

little-cartoon-10569

05/28/2021, 1:13 AM
You would have to import the resource in order to change it. Resources loaded via get are not modifyable.
g

gorgeous-minister-41131

05/28/2021, 1:15 AM
Yeah.. that’s fine, if pulumi had a nice way to import all the diffs of the target object without me having to define all of them.. Is there a nice way to do this?
Copy code
pulumi:pulumi:Stack              eks-py-cute-krill
 =   └─ kubernetes:apps/v1:DaemonSet  kube-proxy         import     [diff: -metadata,spec]; 1 warning

Diagnostics:
  kubernetes:apps/v1:DaemonSet (kube-proxy):
    warning: inputs to import do not match the existing resource; importing this resource will fail
I mean I expect that since they don’t, but maybe what I’m trying to accomplish would be better suited for a simpel kubectl patch directive anyway
I don’t need/want to manage the entire DS just patch it
l

little-cartoon-10569

05/28/2021, 1:22 AM
If you use
pulumi import
rather than writing your own code, then Pulumi should populate all the required fields.
🤞 1
The general point to remember is that Pulumi is a desired-state configuration tool, rather than an imperative state-changing tool. In order to change a cloud resource, you need to describe the (entire) correct new state.
g

gorgeous-minister-41131

05/28/2021, 1:27 AM
Yeah I’m familiar with that, I’ve been using Pulumi for awhile, and terraform for about 5 years. I guess I wasn’t aware that pulumi import would actually work like the terraform one, so I’ll try it out
Copy code
⟩ p import kubernetes:apps/v1:DaemonSet kube-proxy kube-system/kube-proxy
Creating pulumi_pulumi_run ... done

     Type                             Name               Plan
     pulumi:pulumi:Stack              eks-py-cute-krill
 =   └─ kubernetes:apps/v1:DaemonSet  kube-proxy         import

Resources:
    = 1 to import
    8 unchanged

... then produced code output
that’s amazing!
That’s something terraform wasn’t able to do easily (generate the boilerplate for you)
saves me a ton of time.. which is what I was looking for thanks @little-cartoon-10569
Is there a way to mark a resource as ‘autoimport’ some how? another topic I think
l

little-cartoon-10569

05/28/2021, 2:09 AM
What would autoimport mean?
I think refresh is the Pulumi equivalent: update the in-state version of a resource from the provider. Unfortunately (or maybe, fortunately...?) that doesn't update the code.
g

gorgeous-egg-16927

05/28/2021, 4:02 PM
Anyone have any suggestions or best practices for having pulumi edit an existing resource in an k8s/EKS cluster?
This feature is tracked in https://github.com/pulumi/pulumi-kubernetes/issues/264
g

gorgeous-minister-41131

05/28/2021, 6:26 PM
@gorgeous-egg-16927 that’s it! thanks
👍 1