This message was deleted.
# general
s
This message was deleted.
b
Hey @better-actor-92669 Great question here
So first question from me is is there any significant setup on the provider that needs to be passed around? Or is it for config only?
b
@broad-dog-22463, no, there is no extra setup, just a templated kube_config
Copy code
k8s_provider = Provider('gke_k8s', kubeconfig=k8s_mixed_config)
Provider is being referenced in helm deployments and ConfigFile deployments. I think it can be easily moved, but the cluster itself has a lot of resources it depends on in the stack, like vpc/subnetwork/ etc.
b
So how I’ve handled this before is to export only the kubeconfig and then in each of the consuming stacks, create a specific provider with that stack exported value
b
Understood, thanks a lot. Basically, I template my kube config in the same way that was shown in pulumi examples, so the only problem that I see is when the cluster changes, for instance, it is a staging environment and we roll out cluster very often, I will have to do the import again. It would be good to be able to stick to the cluster resource in another stack so to say
Copy code
k8s_mixed_info = Output.all(
    k8s_cluster_mixed.name,
    k8s_cluster_mixed.endpoint,
    k8s_cluster_mixed.master_auth
)
k8s_mixed_config = k8s_mixed_info.apply(
    lambda info: """apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: {0}
    server: https://{1}
  name: {2}
contexts:
- context:
    cluster: {2}
    user: {2}
  name: {2}
current-context: {2}
kind: Config
preferences: {{}}
users:
- name: {2}
  user:
    auth-provider:
      config:
        cmd-args: config config-helper --format=json
        cmd-path: gcloud
        expiry-key: '{{.credential.token_expiry}}'
        token-key: '{{.credential.access_token}}'
      name: gcp
""".format(info[2]['clusterCaCertificate'], info[1], '{0}_{1}_{2}'.
           format(project, MASTER_ZONE, info[0])))

# Make a Kubernetes provider instance that uses our cluster from above.
k8s_provider = Provider('gke_k8s', kubeconfig=k8s_mixed_config)
https://www.pulumi.com/docs/intro/concepts/stack/#stackreferences, it actually shows an example of kubeconfig 🙂
b
I definitely do a lot of things this way where I pass only the outputs needed to reconstruct what I need in upper projects
Then when I need to make changes at the lower level, I can orchestrate the rollout
b
thanks a lot @broad-dog-22463
b
Any time!