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

brief-vr-24049

06/10/2022, 5:33 AM
f

flat-laptop-90489

06/10/2022, 2:10 PM
I just hit something similar in Go, where I had to essentially get the kubeconfig out of the cluster as a string using an Apply I think this issue helped me a bit - https://github.com/pulumi/pulumi-eks/issues/602
In Go, this ended up looking like:
Copy code
// Save a kube provider for later use
	kubeconfig := cluster.Kubeconfig.ApplyT(func(k interface{}) (string, error) {
		data, err := json.Marshal(k)
		if err != nil {
			return "", fmt.Errorf("kubeconfig is not a string")
		}
		return string(data), nil
	}).(pulumi.StringOutput)

	kubeProvider, err := kubernetes.NewProvider(ctx, awsCluster.Name, &kubernetes.ProviderArgs{
		Kubeconfig: kubeconfig,
	})
b

brief-vr-24049

06/10/2022, 6:12 PM
It looks like this is what I'm doing (although in TypeScript) but what I get is a kubeProvider that is somewhat 'poisoned', in that it appears to work, but if I create a resource with it, I get that odd error from inside Pulumi
It does seem like that linked issue might clear things up when it's fixed? Since I could use apply to turn the Output<string> of the kubeconfig into an Output<KubernetesProvider> and use that
f

flat-laptop-90489

06/10/2022, 6:13 PM
Interesting. That sounds right, but it also seems like that might be a long while (they link another blocking issue in there). It's a bit beyond my full understanding though
p

prehistoric-london-9917

06/12/2022, 8:00 PM
@brief-vr-24049: What kind of cluster are you creating? (EKS, GKS, AKS? Something else?) Not sure about the others, but if you’re dealing with EKS and use the
@pulumi/eks
package, you get a
provider
output you can use as a resource option for future K8S operations like:
Copy code
cluster = new eks.Cluster(...);

k8sThing = new k8s.core.v1...({args}, {provider: cluster.provider});
b

brief-vr-24049

06/13/2022, 12:06 AM
It's kops, unfortunately, which doesn't seem to have an implementation out of the box. I'm making the cluster itself with a dynamic resource and then using an
.apply
on the output of that dynamic resource to look up the information to make a
kubeconfig
, which is how I'm getting the
Output<string>
that is the kubeconfig.
This all works great if the cluster is already up. I'm guessing because even though it's an
Output<string>
, it already has a valid value
6 Views