https://pulumi.com logo
#general
Title
# general
e

early-musician-41645

10/30/2018, 6:37 PM
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

creamy-potato-29402

10/30/2018, 6:38 PM
@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

early-musician-41645

10/30/2018, 6:49 PM
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

creamy-potato-29402

10/30/2018, 11:42 PM
@early-musician-41645 try
cluster.kubeconfig.apply(kc => fs.writeFileSync(...))
e

early-musician-41645

10/31/2018, 8:24 PM
For posterity: working code is:
Copy code
cluster.kubeconfig.apply(kc => fs.writeFileSync("./config-"+environment+".kubeconfig.json", JSON.stringify(kc)))
Thanks!
2 Views