Deploying workloads#
This guide deploys into a cluster from a builtin:kubernetes step. See Kubernetes clusters to add one.
Prerequisites#
kubectl, andhelmfor Helm charts, on yourPATH.
Apply manifests#
Add a builtin:kubectl step that reads the cluster’s kubeconfig:
app: {
uses: "builtin:kubectl"
needs: ["cluster"]
with: {
kubeconfig: "${needs.cluster.out.kubeconfig}"
context: "${needs.cluster.out.context}"
path: "k8s/app.yaml"
}
}Set one of:
manifest: YAML in the environment file.path: a manifest file or directory.kustomize: a kustomization directory.
A relative path resolves against the project directory.
Install a Helm chart#
Add a builtin:helm step:
db: {
uses: "builtin:helm"
needs: ["cluster"]
with: {
kubeconfig: "${needs.cluster.out.kubeconfig}"
context: "${needs.cluster.out.context}"
release: "db"
chart: "oci://registry-1.docker.io/bitnamicharts/postgresql"
}
}chart is a local path, an oci:// reference, or a chart name in repo. By default, the step waits up to 5 minutes for the release to become ready.
Wait until a workload is ready#
kubectl apply does not wait. Add a builtin:wait step, and put it in the needs of the steps that use the workload:
app_ready: {
uses: "builtin:wait"
needs: ["cluster", "app"]
with: {
timeout: "2m"
kubectl: {
kubeconfig: "${needs.cluster.out.kubeconfig}"
context: "${needs.cluster.out.context}"
resource: "deployment/app"
rollout: true
}
}
}The check retries until the resource exists and is ready. builtin:wait also has tcp, http, and exec checks.
Keep resources after teardown#
By default, teardown deletes what kubectl applied and uninstalls what helm installed. To keep them, set keep: true in the step’s with block.
Related#
examples/kind: akubectlstep and ahelmstep, each with awaitstep.