e.g. the cluster kubeconfig created with `new eks....
# general
e
e.g. the cluster kubeconfig created with
new eks.Cluster
in
@pulumi/eks
returns a json response when I do
pulumi stack output kubeconfig
c
@early-musician-41645 the stack output is just text — if you want kubeconfig to be YAML, you can just convert it to YAML when you
export
the variable.
so like,
export const kubeconfig = convertToYaml(eks.kubeConfig)
or whatever
e
good point. thanks!
I'm trying to write the kubeconfig to a file but failing somewhere. Can you see what I'm doing wrong? The output works fine but
fs.writeFileSync
doesn't do what I expect:
Copy code
// Create the Kubernetes cluster and all associated artifacts and resources
const cluster = new eks.Cluster(environment+"-eks-cluster", {
    vpcId             : config.require("vpc-id"),
    subnetIds         : vpcSubnetIds,
    instanceType      : "m4.4xlarge",
    nodePublicKey     : config.require("worker-ssh-key"),
    nodeRootVolumeSize: 250,
    desiredCapacity   : 3,
    maxSize           : 10,
    minSize           : 1,
    nodeUserData      : userData,
    deployDashboard   : false,
});

export const kubeconfig = cluster.kubeconfig;
// Write out the kubeconfig file
fs.writeFileSync("./config-"+environment+".kubeconfig.json", JSON.stringify(kubeconfig));
Here's what gets written:
Copy code
$ cat config-online-vnext-10az-pulumi.kubeconfig.json
{"__pulumiOutput":true,"isKnown":{}}
c
@early-musician-41645 try
cluster.kubeconfig.apply(kc => fs.writeFileSync(...))
e
For posterity: working code is:
Copy code
cluster.kubeconfig.apply(kc => fs.writeFileSync("./config-"+environment+".kubeconfig.json", JSON.stringify(kc)))
Thanks!