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

glamorous-printer-66548

10/15/2018, 12:10 AM
Hi, is there a way to programmatically set a global default provider or (programmatically set a root resource which contains this provider)?? The concrete issue is the following: Currently in my stacks I’m programmatically creating a k8s provider that should be used as the deployment target for all resources in that stack (using https://gist.github.com/geekflyer/b78adab2667d8526a1dd593bc5c844bf#file-gke-ts). In order to use this dynamically created provider, however, I have pass it explicitly to each k8s resource that is created in that stack OR I have to explicitly set a common parent on each resource in that stack and set the k8s provider on that parent. If I accidentally forget to explicitly set the provider or parent on one of the resources, pulumi seems to create an implicit k8s provider based on my local kubectl config / context. Depending on what my current local kubectl context contains, pulumi may end up silently deploying resources to a different cluster than what I actually want. It would be very helpful if I could disable or override this “implicit default provider” programmatically in the entrypoint of my program.
w

white-balloon-205

10/15/2018, 4:22 AM
Currently there is not a mechanism to set the default. The closest available option today is to put all resources inside a component (and pass
parent: this
) - though as you rightly note this can be error prone. We definitely want to improve this - I can imagine a couple ways we might be able to do it; - expose the stack object (the implicit parent of unparented resources), and allow changing its default providers - allow overriding the kuberenetes packages default provider directly via
kubernetes.setDefaultProvider
or similar. These would both require being careful about timing, as they modify glove state and subtle changes to module loading order could potentially cause this switch to happen at a different time. I’ll open an issue on this tomorrow when I’m back at my laptop so we can nail down an approach to take for this.
👍 2
c

creamy-potato-29402

10/15/2018, 5:16 AM
@white-balloon-205 @big-piano-35669 this is an issue that pretty much everyone writing kube apps runs into sooner or later. I’ve hit it, Joe hit it, Pat hit it — and when you do it’s very confusing. We should think about fixing this next milestone.
s

sparse-insurance-40223

10/15/2018, 9:31 AM
I've also hit it... it bunged a load of pods onto a production cluster 😮
🤯 1
w

white-balloon-205

10/15/2018, 2:10 PM
Yep - we definitely want to fix this. Opened https://github.com/pulumi/pulumi/issues/2059 to track.
7 Views