does pulumi offer any functions to generate kubeco...
# typescript
c
does pulumi offer any functions to generate kubeconfig's ? I have an existing kubernetes cluster, and I want to try and connect to it using pulumi + typescript, the provider can accept a kubeconfig (https://www.pulumi.com/docs/reference/pkg/kubernetes/provider/) which is easy if i'd created the cluster using
pulumi-eks
. what am I missing?
b
There’s no built in function, but you can write one fairly easily - do you need some specific functionality
?
c
it's more a quality-of-life thing; currently i just have:
Copy code
const cluster = aws.eks.getCluster({name: "mycluster"})

export const kubeConfig = cluster.then(c => JSON.stringify({
    apiVersion: "v1",
    clusters: [
        {
            cluster: {
                "certificate-authority-data": c.certificateAuthority.data,
                server: c.endpoint,
            },
            name: "kubernetes",
        }
    ],
    contexts: [
        {
            context: {
                cluster: "kubernetes",
                user: "aws",
            },
            name: "aws",
        },
    ],
    "current-context": "aws",
    kind: "Config",
    users: [
        {
            name: "aws",
            user: {
                exec: {
                    apiVersion: "<http://client.authentication.k8s.io/v1alpha1|client.authentication.k8s.io/v1alpha1>",
                    args: [
                        "--region",
                        "us-west-2",
                        "eks",
                        "get-token",
                        "--cluster-name",
                        c.name,
                    ],
                    command: "aws",
                }
            }
        },
    ],
}));

const kubeClient = new k8s.Provider("mycluster", { kubeconfig: kubeConfig })

// do stuff
but it looks goofy 🙂