https://pulumi.com logo
Title
b

brash-country-7541

04/26/2021, 12:13 PM
How do I ekport the kubernetes config file descibed in the Cluster.ts to the .kubeconfig file
i

incalculable-engineer-92975

04/26/2021, 12:49 PM
It looks like you're using gcp so I can't be specific. But for AWS there's a
kubeconfig
parameter on the Cluster object. Assuming gcp is the same, after the cluster is created you
export
it. Then you can reference the
kubeconfig
in the stack. If you want it output in the same pulumi run, you'll have to have the export code run after pulumi finishes, e.g., something like this if you're using Typescript.
process.once('beforeExit', (code): void => {
    if (code == 0) {
        // export the kubeconfig
    }
});
In general, if you want to use the values set by pulumi in the same script execution, then you have to somehow wait for pulumi to finish running first. You can mess with
awat
as well but it's easier to wait for everything to finish executing. It's also the best time to run unit tests.