Skip to content

Commit 506cf5b

Browse files
authored
Merge pull request pulumi#528 from pulumi/lblackstone/update-do-k8s
Improve the DigitalOcean k8s examples
2 parents 0d00854 + 35daced commit 506cf5b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

digitalocean-ts-k8s/index.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,26 @@ const domainName = config.get("domainName");
1414
// kubeconfig to make it easy to access from the kubectl command line.
1515
const cluster = new digitalocean.KubernetesCluster("do-cluster", {
1616
region: digitalocean.Regions.SFO2,
17-
version: "latest",
17+
version: digitalocean.getKubernetesVersions({versionPrefix: "1.16"}).then(p => p.latestVersion),
1818
nodePool: {
1919
name: "default",
2020
size: digitalocean.DropletSlugs.DropletS2VCPU2GB,
2121
nodeCount: nodeCount,
2222
},
2323
});
24-
export const kubeconfig = cluster.kubeConfigs[0].rawConfig;
24+
25+
// The DigitalOcean Kubernetes cluster periodically gets a new certificate,
26+
// so we look up the cluster by name and get the current kubeconfig after
27+
// initial provisioning. You'll notice that the `certificate-authority-data`
28+
// field changes on every `pulumi update`.
29+
const kubeconfig = cluster.status.apply(status => {
30+
if (status === "running") {
31+
const clusterDataSource = cluster.name.apply(name => digitalocean.getKubernetesCluster({name}));
32+
return clusterDataSource.kubeConfigs[0].rawConfig;
33+
} else {
34+
return cluster.kubeConfigs[0].rawConfig;
35+
}
36+
});
2537

2638
// Now lets actually deploy an application to our new cluster. We begin
2739
// by creating a new "Provider" object that uses our kubeconfig above,

0 commit comments

Comments
 (0)