Skip to content

DigitalOcean.Kubernetes reference

Source: packages/digitalocean/src/Kubernetes/Cluster.ts

A DigitalOcean Kubernetes (DOKS) cluster with its default node pool. Pass cluster.connection to Kubernetes.Deployment, Kubernetes.Manifest and the other @alchemy.run/kubernetes workloads; Alchemy connects with short-lived tokens from the DigitalOcean API. Add more pools with DigitalOcean.Kubernetes.NodePool.

Alchemy tags the cluster with an alchemy: ownership tag and an alchemy:generation: tag, so an interrupted deploy resumes on the cluster it already created. A same-named cluster without the ownership tag is Unowned and needs --adopt. A cluster takes five to ten minutes to come up.

A three-node cluster

const cluster = yield* DigitalOcean.Kubernetes.Cluster("k8s", {
region: "nyc3",
nodePool: { size: "s-2vcpu-4gb", count: 3 },
});

An autoscaling, highly available cluster in a VPC

const network = yield* DigitalOcean.Vpc("network", { region: "nyc3" });
const cluster = yield* DigitalOcean.Kubernetes.Cluster("k8s", {
region: "nyc3",
vpcUuid: network.vpcId,
ha: true,
autoUpgrade: true,
maintenancePolicy: { startTime: "03:00", day: "sunday" },
nodePool: { size: "s-4vcpu-8gb", count: 2, autoScale: true, minNodes: 2, maxNodes: 6 },
});
const cluster = yield* DigitalOcean.Kubernetes.Cluster("k8s", {
region: "nyc3",
nodePool: { size: "s-2vcpu-4gb", count: 2 },
});
yield* Kubernetes.Deployment("web", {
connection: cluster.connection,
image: "nginx:1.27",
replicas: 2,
ports: [{ containerPort: 80 }],
});

Source: packages/digitalocean/src/Kubernetes/NodePool.ts

An extra node pool in a DigitalOcean Kubernetes cluster, for example larger or GPU nodes that only some workloads schedule onto. Count, autoscaling, labels, taints, tags and the name update in place; a new size replaces the pool, creating the new one first.

const cluster = yield* DigitalOcean.Kubernetes.Cluster("k8s", {
region: "nyc3",
nodePool: { size: "s-2vcpu-4gb", count: 2 },
});
yield* DigitalOcean.Kubernetes.NodePool("batch", {
clusterId: cluster.clusterId,
size: "c-8",
count: 1,
autoScale: true,
minNodes: 0,
maxNodes: 5,
labels: { workload: "batch" },
taints: [{ key: "workload", value: "batch", effect: "NoSchedule" }],
});