VirtuslabRnD/pulumi-kotlin

Defaulting to a k8s provider if enabled

kylepl opened this issue · 0 comments

kylepl commented

I have a rough flow in my Pulumi config of:

  1. Configure a k8s cluster
  2. Set up several things (deployments, configmaps) in it.

To do this, I get the kubeConfig like:

val k8sProvider = kubernetesProvider("k8sprovider") {
  args {
    kubeconfig(cluster.kubeConfigs.applyValue { kubeConfigs -> kubeConfigs.get(0).rawConfig })
  }
}

and then later on reference it like:

serviceAccount("my-service-account") {
  opts {
    // Specifies which cluster to apply it to.
    provider(k8sProvider)
  }
}

so that it uses those credentials.

If I forget, it uses the kubectl last-used properties, which is not ideal.

I'm wondering if there is some way to "install" or put the k8s provider as the default for a scope? For instance:

using(k8sProvider) {
  serviceAccount("my-service-account") {}
  deployment("some-deployment") {...}
}

I'm new to Kotlin, so not just trying to ask a language question - perhaps this needs library support?