Skip to content

Commit

Permalink
Improve the DigitalOcean k8s examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lblackstone committed Jan 27, 2020
1 parent d66aee1 commit 250f462
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions digitalocean-ts-k8s/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,26 @@ const domainName = config.get("domainName");
// kubeconfig to make it easy to access from the kubectl command line.
const cluster = new digitalocean.KubernetesCluster("do-cluster", {
region: digitalocean.Regions.SFO2,
version: "latest",
nodePool: {
version: digitalocean.getKubernetesVersions({versionPrefix: "1.16"}).then(p => p.latestVersion),
nodePool: {
name: "default",
size: digitalocean.DropletSlugs.DropletS2VCPU2GB,
nodeCount: nodeCount,
},
});
export const kubeconfig = cluster.kubeConfigs[0].rawConfig;

// The DigitalOcean Kubernetes cluster periodically gets a new certificate,
// so we look up the cluster by name and get the current kubeconfig after
// initial provisioning. You'll notice that the `certificate-authority-data`
// field changes on every `pulumi update`.
const kubeconfig = cluster.status.apply(status => {
if (status === 'running') {
const clusterDataSource = cluster.name.apply(name => digitalocean.getKubernetesCluster({name}));
return clusterDataSource.kubeConfigs[0].rawConfig;
} else {
return cluster.kubeConfigs[0].rawConfig;
}
});

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

0 comments on commit 250f462

Please sign in to comment.