What is the recommended way to create a k8s provid...
# kubernetes
h
What is the recommended way to create a k8s provider with a kubeconfig for an AWS EKS where the cluster is managed by pulumi? I'm currently dynamically generating the kubeconfig based on Outputs from the aws-native.eks.Cluster but that causes pulumi preview to be basically worthless any time anything about the cluster changes (even a tag). I've tried generating the kubeconfig in an Output.apply, but that just seems to kick the can down the road. I've tried migrating to a pulumi_eks.Cluster, but that has a whole separate set of problems. I'm about at the point where I'm just going to statically define the kubeconfig and deal with the downsides of that when I need to create new clusters (which is generally rare). Any help would be appreciated.
q
What does your current function for generating the kubeconfig look like?
h
roughly like this
Copy code
def create_kubernetes_provider(eks_cluster: eks.Cluster):
    kubeconfig = pulumi.Output.json_dumps(
        {
            "apiVersion": "v1",
            "clusters": [
                {
                    "cluster": {
                        "server": eks_cluster.endpoint,
                        "certificate-authority-data": eks_cluster.certificate_authority_data,
                    },
                    "name": eks_cluster.arn,
                }
            ],
        }
    )

    return k8s.Provider(
        resource_name=f"k8s-provider-{eks_cluster.name}",
        cluster=eks_cluster.arn,
        kubeconfig=kubeconfig,        
    )
m
I think if you create it with the eks provider you can use the kubeconfig output of the cluster object
h
Yeah, I went down that road. There were a few issues I ran into that lead me to give up on it. The last was that I have all default providers disabled and it appears to have issues with that as I was unable to specify providers for the child resources it tries to create.
🤔 1
m
I would raise an issue if there's an obvious bug
q
You should be able to do that with the EKS provider, if not then that is indeed a bug. Please file a bug here If you do not want to adopt pulumi-eks, you can also copy the way it's creating the kubeconfig internally: https://github.com/pulumi/pulumi-eks/blob/7b72ddc25b20791d4b1436510fc5cead26e86554/nodejs/eks/cluster/cluster.ts#L203-L277
h
Yeah, related to that though is that the EKS package Cluster tries to create dependencies that I've already got created (these are primarily existing clusters). It didn't feel like the right answer for what I'm doing. I'll take a look at how its creating kubeconfig though. Thanks