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

busy-umbrella-36067

12/18/2019, 4:52 PM
Would it possible to not allow implicit providers for k8s resources somehow? Maybe a config value
kubernetes:allowImplicitProvider
We've started distributing an abstracted API for deploying onto k8s clusters but in some cases developers have been deploying to whatever their
KUBECONFIG
env var is set to
i

important-leather-28796

12/18/2019, 4:57 PM
My kubeconfig is exported from my
infrastructure
, so I use that stack output. I believe the pulumi guides have something similar to this.
Copy code
import { stackPath } from '@alienfast/pulumi-common'
import { StackReference } from '@pulumi/pulumi'

// how about now or now
export const identity: StackReference = new StackReference(stackPath('identity'))
export const infrastructure: StackReference = new StackReference(stackPath('infrastructure'))
export const infrastructurePath = stackPath('infrastructure')
Copy code
import { getStack, Config } from '@pulumi/pulumi'
import { productNameFromProject } from './productNameFromProject'

/**
 * Given the dirName, construct the fully qualified stack path from the current
 * project/stack.
 *
 * @param dirName e.g. `infrastructure`
 */
export const stackPath = (dirName: string) => {
  const config = new Config('pulumi')
  const organization = config.require('organization') // e.g. rosskevin || alienfast
  const stack = getStack() // => "development"
  const product = productNameFromProject()
  return `${organization}/${product}-${dirName}/${stack}`
}
Provider is then created by:
Copy code
export const kubernetes = new k8s.Provider(stack.infrastructurePath, {
  kubeconfig: stack.infrastructure.requireOutput('cluster').apply(cluster => cluster.kubeconfig),
})
s

stocky-island-3676

12/18/2019, 5:05 PM
@busy-umbrella-36067 You’re not alone with this request. Please raise your hand and add the use-case here: https://github.com/pulumi/pulumi/issues/3383
b

busy-umbrella-36067

12/18/2019, 5:06 PM
@important-leather-28796 we have an exported function to get an output from our main
infrastructure
stack, but we don't want to hide the
opts
from developers in case they want to deploy to multiple clusters
w

white-balloon-205

12/18/2019, 5:09 PM
Left a note clarifying the current best solution I'm aware of on https://github.com/pulumi/pulumi/issues/3383#issuecomment-567124447. Definitely want to make this easier. Please do add any notes or uipvotes on that issue.
i

important-leather-28796

12/18/2019, 5:09 PM
Oh I see, sorry, it didn't land in my brain the first time. We also never use implicit, always explicit providers as we had the same issue.
s

stocky-island-3676

12/18/2019, 5:19 PM
@important-leather-28796 Then don’t forget to raise your hand in that issue, please. 🙂
i

important-leather-28796

12/18/2019, 5:20 PM
already done 😉