zuke.tools.kubectl
@zuke/kubectl 1.2.1: @zuke/kubectl — typed kubectl CLI task wrappers for Zuke builds, for deploying to and managing Kubernetes from a pipeline.
zuke on PyPI ↗ 42 symbols
Symbols
class KubectlAnnotateSettings(KubectlSettings) Settings for kubectl annotate.
-
resource(*tokens: str) -> SelfResource tokens, e.g.
("deploy", "api")or("pods", "-l", "app=web"); repeatable. -
annotation(key: str, value: str) -> SelfSet an annotation as a
key=valuetoken; repeatable. -
remove(key: str) -> SelfRemove an annotation, rendered as kubectl's
key-syntax; repeatable. -
overwrite() -> SelfOverwrite existing annotations (
--overwrite). -
all() -> SelfApply to all resources of the given type (
--all). -
selector(query: str) -> SelfRestrict to resources matching a label selector (
-l).
class KubectlApiResourcesSettings(KubectlSettings) Settings for kubectl api-resources.
-
api_group(name: str) -> SelfOnly resources in this API group (
--api-group). -
namespaced(value: bool | None=None) -> SelfWhether to list namespaced resources (
--namespaced); kubectl's default istrue, so passfalsefor the cluster-scoped ones. -
verbs(*names: str) -> SelfOnly resources supporting these verbs (
--verbs). -
categories(*names: str) -> SelfOnly resources in these categories (
--categories). -
sort_by(field: Literal['name', 'kind']) -> SelfSort by
nameorkind(--sort-by). -
output(format: str) -> SelfThe output format (
-o), e.g.nameorwide. -
no_headers() -> SelfLeave the header row out (
--no-headers). -
cached() -> SelfUse the discovery cache rather than asking the server (
--cached).
class KubectlApiVersionsSettings(KubectlSettings) Settings for kubectl api-versions.
class KubectlApplySettings(KubectlSettings) Settings for kubectl apply.
-
file(path: str) -> SelfApply a manifest file, directory, or URL (
-f); repeatable. -
kustomize(dir: str) -> SelfApply a kustomization directory (
-k). -
recursive() -> SelfRecurse into directories given to
-f(-R). -
prune() -> SelfPrune resources not present in the applied set (
--prune). -
server_side() -> SelfApply server-side (
--server-side). -
dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> SelfPreview without persisting (
--dry-run=; defaults toclient). -
selector(query: str) -> SelfRestrict to resources matching a label selector (
-l). -
force() -> SelfForce apply by delete-and-recreate when needed (
--force).
class KubectlAuthCanISettings(KubectlSettings) Settings for kubectl auth can-i.
The command answers through its exit status — 0 when the action is allowed and non-zero when it is not — so "./kubectl.ts".KubectlTasksApi.canI reads the code into a boolean rather than failing the build on a routine "no".
-
verb(name: str) -> SelfThe API verb to check, e.g.
create(required unless list). -
resource(name: str) -> SelfThe resource, e.g.
deploymentsordeployments/api. -
subresource(name: str) -> SelfA subresource, e.g.
logorscale(--subresource). -
all_namespaces() -> SelfCheck across every namespace (
--all-namespaces). -
list() -> SelfPrint every allowed action instead of checking one (
--list). -
quiet_answer() -> SelfPrint nothing and answer only through the exit code (kubectl's
--quiet). Named apart from the inherited.quiet(), which suppresses Zuke's own echo of the command rather than kubectl's output.
class KubectlClusterInfoSettings(KubectlSettings) Settings for kubectl cluster-info.
class KubectlConfigCurrentContextSettings(KubectlSettings) Settings for kubectl config current-context.
class KubectlConfigGetContextsSettings(KubectlSettings) Settings for kubectl config get-contexts.
-
names_only() -> SelfPrint only the names (
-o name), the one output format gh accepts here. -
no_headers() -> SelfLeave the header row out (
--no-headers).
class KubectlConfigSetContextSettings(KubectlSettings) Settings for kubectl config set-context.
Note that set-context has its own --namespace, which sets the namespace recorded in the context entry rather than scoping one command. The inherited .namespace(...) renders that same flag, which is what a caller of this command wants.
-
context_name(name: str) -> SelfThe context to write (required unless current is set).
-
current() -> SelfModify the current context rather than a named one (
--current). -
cluster(name: str) -> SelfThe cluster the context points at (
--cluster). -
user(name: str) -> SelfThe user the context authenticates as (
--user).
class KubectlConfigUseContextSettings(KubectlSettings) Settings for kubectl config use-context.
-
context_name(name: str) -> SelfThe context to switch to (required).
class KubectlConfigViewSettings(KubectlSettings) Settings for kubectl config view.
-
minify() -> SelfKeep only what the current context uses (
--minify). -
flatten() -> SelfInline the referenced files, for a portable kubeconfig (
--flatten). -
raw() -> SelfPrint the credentials in the clear (
--raw). kubectl redacts them by default; anything this prints belongs in aparameter().secret(), not in a build's log. -
output(format: str) -> SelfThe output format (
-o), e.g.json; kubectl's default isyaml.
class KubectlCordonSettings(KubectlSettings) Settings for kubectl cordon and kubectl uncordon — marking a node unschedulable, and letting it take pods again.
-
node(name: str) -> SelfThe node to act on; required unless a selector picks them.
-
uncordon() -> SelfMake the node schedulable again instead —
kubectl uncordon. -
selector(query: str) -> SelfAct on every node matching a label selector (
-l). -
dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> SelfPreview without persisting (
--dry-run=; defaults toclient).
class KubectlCpSettings(KubectlSettings) Settings for kubectl cp — copying files into and out of a container.
This is how a build gets a report out of a pod that produced it. Each side is either a local path or a [namespace/]pod:path spec, and kubectl takes exactly one of each.
-
from_(spec: str) -> SelfWhere to copy from: a local path, or
pod:path/namespace/pod:path. -
to(spec: str) -> SelfWhere to copy to, in the same two forms.
-
container(name: str) -> SelfWhich container of the pod (
-c). -
no_preserve() -> SelfDo not carry ownership and permissions across (
--no-preserve). -
retries(count: float) -> SelfRetry a copy out of a container this many times (
--retries).
class KubectlCreateSettings(KubectlSettings) Settings for kubectl create.
-
file(path: str) -> SelfCreate from a manifest file, directory, or URL (
-f); repeatable. For resource-form creation (create secret …), use the base.args(...). -
recursive() -> SelfRecurse into directories given to
-f(-R). -
dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> SelfPreview without persisting (
--dry-run=; defaults toclient). -
output(format: str) -> SelfOutput format, e.g.
yamlorjson(-o). -
save_config() -> SelfRecord the current resource in its annotation (
--save-config).
class KubectlDeleteSettings(KubectlSettings) Settings for kubectl delete.
-
file(path: str) -> SelfDelete from a manifest file or directory (
-f); repeatable. -
resource(*tokens: str) -> SelfResource tokens, e.g.
("pod", "web")or("deployment/api"); repeatable. -
selector(query: str) -> SelfRestrict to resources matching a label selector (
-l). -
all() -> SelfDelete all resources of the given type (
--all). -
ignore_not_found() -> SelfTreat "not found" as a success (
--ignore-not-found). -
force() -> SelfForce immediate deletion (
--force). -
grace_period(seconds: float) -> SelfSeconds to wait before forceful termination (
--grace-period). -
recursive() -> SelfRecurse into directories given to
-f(-R).
class KubectlDescribeSettings(KubectlSettings) Settings for kubectl describe.
-
resource(*tokens: str) -> SelfResource tokens, e.g.
("pod", "web")or("deployment/api"); repeatable. -
selector(query: str) -> SelfRestrict to resources matching a label selector (
-l).
class KubectlDiffSettings(KubectlSettings) Settings for kubectl diff — what an apply would change, without changing it.
diff reports its answer through the exit status: 0 when there is no difference and 1 when there is, with anything above 1 meaning kubectl or the differ failed. "./kubectl.ts".KubectlTasksApi.diff keeps the ordinary contract, so a build that wants the printed diff and a failed target on drift gets both; "./kubectl.ts".KubectlTasksApi.diffHasChanges is the reader that turns the code into a boolean.
-
file(path: str) -> SelfDiff a manifest file, directory, or URL (
-f); repeatable. -
kustomize(dir: str) -> SelfDiff a kustomization directory (
-k). -
recursive() -> SelfRecurse into directories given to
-f(-R). -
server_side() -> SelfDiff the server-side apply (
--server-side). -
force_conflicts() -> SelfTake ownership of conflicting fields (
--force-conflicts). -
prune() -> SelfInclude what a prune would delete (
--prune). -
selector(query: str) -> SelfRestrict to resources matching a label selector (
-l). -
show_managed_fields() -> SelfInclude the managed fields, which are otherwise hidden (
--show-managed-fields). -
concurrency(count: float) -> SelfHow many objects to diff in parallel (
--concurrency).
class KubectlDrainSettings(KubectlSettings) Settings for kubectl drain.
kubectl refuses to drain a node whose pods it cannot safely move, and the two flags that override that refusal are exactly the ones worth being deliberate about: --ignore-daemonsets and --delete-emptydir-data, the second of which destroys local data. Neither is defaulted here.
-
node(name: str) -> SelfThe node to drain; required unless a selector picks them.
-
force() -> SelfEvict pods no controller manages, which nothing will recreate (
--force). -
ignore_daemon_sets() -> SelfProceed past DaemonSet-managed pods, which drain never deletes (
--ignore-daemonsets). -
delete_empty_dir_data() -> SelfProceed past pods using emptyDir, destroying that data (
--delete-emptydir-data). -
disable_eviction() -> SelfDelete rather than evict (
--disable-eviction), which bypasses every PodDisruptionBudget — the guardrail an operator wrote down on purpose. -
grace_period(seconds: float) -> SelfSeconds each pod gets to terminate (
--grace-period). -
timeout(duration: str) -> SelfHow long to wait for the drain overall, e.g.
5m(--timeout). -
pod_selector(query: str) -> SelfOnly drain pods matching this label selector (
--pod-selector). -
selector(query: str) -> SelfDrain every node matching this label selector (
-l). -
skip_wait_for_delete_timeout(seconds: float) -> SelfStop waiting on pods already deleting this long (
--skip-wait-for-delete-timeout). -
dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> SelfPreview without persisting (
--dry-run=; defaults toclient).
class KubectlEventsSettings(KubectlSettings) Settings for kubectl events — the first thing to read when a rollout stalls and rollout status will not say why.
-
for_resource(reference: str) -> SelfOnly events about this resource, as
TYPE/NAME(--for). -
types(*names: str) -> SelfOnly events of these types, e.g.
Warning(--types). -
all_namespaces() -> SelfAcross every namespace (
-A). -
watch() -> SelfKeep watching after the listing (
--watch). A target that watches blocks until something stops it, so pair it with.killAfter(...)unless the wait is the point. -
no_headers() -> SelfLeave the header row out (
--no-headers). -
output(format: str) -> SelfThe output format (
-o), e.g.json.
class KubectlExecSettings(KubectlSettings) Settings for kubectl exec.
-
resource(name: str) -> SelfThe pod (or
type/name) to exec into (required). -
container(name: str) -> SelfTarget a specific container (
-c). -
stdin() -> SelfKeep STDIN open (
-i). -
tty() -> SelfAllocate a TTY (
-t). -
command(*args: str | float) -> SelfThe command and arguments to run in the container (required).
class KubectlExplainSettings(KubectlSettings) Settings for kubectl explain — the schema of a resource type.
-
type_(name: str) -> SelfThe type to explain, e.g.
podsordeployments.spec.replicas. -
recursive() -> SelfPrint nested fields too (
-R). -
max_depth(depth: float) -> SelfCap how deep recursive goes (
--max-depth). -
api_version(value: str) -> SelfExplain a particular API group/version (
--api-version). -
output(format: str) -> SelfHow to render the schema (
-o):plaintextorplaintext-openapiv2.
class KubectlExposeSettings(KubectlSettings) Settings for kubectl expose — a service in front of an existing workload.
-
resource(reference: str) -> SelfThe workload to expose, e.g.
deployment/api. -
file(path: str) -> SelfExpose the workload a manifest identifies instead (
-f); repeatable. -
port(value: str | float) -> SelfThe port the service serves on (
--port). -
target_port(value: str | float) -> SelfThe container port traffic goes to (
--target-port). -
type_(value: str) -> SelfThe service type (
--type), e.g.LoadBalancer. -
name(value: str) -> SelfThe new service's name (
--name). -
protocol(value: str) -> SelfThe protocol (
--protocol), e.g.TCP. -
selector(query: str) -> SelfThe selector the service routes by (
--selector). kubectl infers it from the exposed resource when it is omitted, and only equality-based requirements are supported here. -
labels(value: str) -> SelfLabels for the created service (
--labels), comma-separated. -
session_affinity(value: Literal['None', 'ClientIP']) -> SelfSession affinity (
--session-affinity):NoneorClientIP. -
dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> SelfPreview without persisting (
--dry-run=; defaults toclient).
class KubectlGetSettings(KubectlSettings) Settings for kubectl get.
-
resource(*tokens: str) -> SelfResource tokens, e.g.
("pods")or("pod", "web"); repeatable. -
output(format: str) -> SelfOutput format, e.g.
wide,yaml,json,jsonpath=…(-o). -
selector(query: str) -> SelfRestrict to resources matching a label selector (
-l). -
field_selector(query: str) -> SelfRestrict by field selector (
--field-selector). -
all_namespaces() -> SelfList across all namespaces (
-A). -
watch(on: bool | None=None) -> SelfWatch for changes instead of returning once (
-w); passfalseto disable. -
show_labels() -> SelfInclude resource labels as columns (
--show-labels).
class KubectlKustomizeSettings(KubectlSettings) Settings for kubectl kustomize — rendering a kustomization to stdout.
-
dir(path: str) -> SelfThe kustomization directory or repository URL; kubectl assumes
.. -
output(path: str) -> SelfWrite the rendered output to a file instead of stdout (
-o). -
enable_helm() -> SelfAllow the Helm chart inflator generator (
--enable-helm). -
load_restrictor(value: str) -> SelfRelax where a kustomization may load files from (
--load-restrictor).
class KubectlLabelSettings(KubectlSettings) Settings for kubectl label.
-
resource(*tokens: str) -> SelfResource tokens, e.g.
("deploy", "api")or("pods", "-l", "app=web"); repeatable. -
label(key: str, value: str) -> SelfSet a label as a
key=valuetoken; repeatable. -
remove(key: str) -> SelfRemove a label, rendered as kubectl's
key-syntax; repeatable. -
overwrite() -> SelfOverwrite existing labels (
--overwrite). -
all() -> SelfApply to all resources of the given type (
--all). -
selector(query: str) -> SelfRestrict to resources matching a label selector (
-l).
class KubectlLogsSettings(KubectlSettings) Settings for kubectl logs.
-
resource(name: str) -> SelfThe pod (or
type/name) to read logs from. -
container(name: str) -> SelfRead from a specific container (
-c). -
selector(query: str) -> SelfSelect pods by label instead of naming one (
-l). -
follow() -> SelfStream new log output (
-f). -
previous() -> SelfRead the previous container instance's logs (
--previous). -
tail(lines: float) -> SelfShow only the last N lines (
--tail). -
since(duration: str) -> SelfOnly logs newer than a duration, e.g.
5m(--since). -
all_containers() -> SelfInclude all containers in the pod (
--all-containers). -
timestamps() -> SelfPrefix each line with a timestamp (
--timestamps).
class KubectlPatchSettings(KubectlSettings) Settings for kubectl patch.
-
resource(name: str) -> SelfThe resource to patch, e.g.
deployment/api(required). -
patch(content: str) -> SelfThe patch document (
-p, required). -
type_(strategy: Literal['strategic', 'merge', 'json']) -> SelfThe patch strategy (
--type).
class KubectlPortForwardSettings(KubectlSettings) Settings for kubectl port-forward.
-
resource(name: str) -> SelfThe pod or service, e.g.
svc/api(required). -
port(mapping: str) -> SelfA port mapping, e.g.
8080:80or8080; repeatable, at least one. -
address(value: str) -> SelfThe local address(es) to bind (
--address).
class KubectlReplaceSettings(KubectlSettings) Settings for kubectl replace.
-
file(path: str) -> SelfReplace from a manifest file, directory, or URL (
-f); repeatable. -
kustomize(dir: str) -> SelfReplace from a kustomization directory (
-k). -
recursive() -> SelfRecurse into directories given to
-f(-R). -
force() -> SelfDelete and recreate rather than update (
--force). This is not a retry knob: the resource genuinely goes away first, so anything depending on it sees it missing. -
grace_period(seconds: float) -> SelfSeconds each object gets to terminate (
--grace-period). -
timeout(duration: str) -> SelfHow long to wait on the delete half, e.g.
60s(--timeout). -
cascade(strategy: Literal['background', 'orphan', 'foreground']) -> SelfThe cascading strategy for dependents (
--cascade). -
wait() -> SelfWait for the resources to be gone before returning (
--wait). -
dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> SelfPreview without persisting (
--dry-run=; defaults toclient).
class KubectlRolloutSettings(KubectlSettings) Settings for kubectl rollout.
-
status() -> SelfShow rollout status (
rollout status). -
restart() -> SelfRestart a rollout (
rollout restart). -
undo() -> SelfRoll back to the previous revision (
rollout undo). -
history() -> SelfShow rollout history (
rollout history). -
pause() -> SelfStop the rollout where it is (
rollout pause) — half of a canary. A paused workload takes no further updates until resume. -
resume() -> SelfLet a paused rollout continue (
rollout resume). -
resource(name: str) -> SelfThe resource, e.g.
deployment/api(required). -
to_revision(revision: float) -> SelfWith
undo, the revision to roll back to (--to-revision). -
timeout(duration: str) -> SelfWith
status, how long to wait, e.g.60s(--timeout).
class KubectlRunSettings(KubectlSettings) Settings for kubectl run — one pod, imperatively.
This is for a one-off: a migration job, a debug shell. A workload a build owns belongs in a manifest and goes through "./manifests.ts".KubectlApplySettings, which is declarative and can be diffed.
-
name(value: str) -> SelfThe pod's name (required).
-
image(reference: str) -> SelfThe image to run (
--image, required). -
restart(policy: Literal['Always', 'OnFailure', 'Never']) -> SelfThe restart policy (
--restart). -
env_var(key: str, value: str) -> SelfAn environment variable for the container (
--env KEY=VALUE); repeatable. Named apart from the inherited.env(...), which sets the environmentkubectlitself runs in. -
labels(value: str) -> SelfLabels for the pod (
--labels), comma-separated. -
port(value: str | float) -> SelfThe port the container exposes (
--port). -
overrides(json: str) -> SelfAn inline JSON override for the generated pod (
--overrides). -
expose() -> SelfAlso create a ClusterIP service (
--expose), which needs port. -
command(first: str, *rest: str) -> SelfThe command and arguments to run, after kubectl's
--separator. Passing any also sets--command, so they replace the image's entrypoint rather than being appended to it. -
dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> SelfPreview without persisting (
--dry-run=; defaults toclient).
class KubectlScaleSettings(KubectlSettings) Settings for kubectl scale.
-
replicas(count: float) -> SelfDesired replica count (
--replicas, required). -
resource(name: str) -> SelfThe resource to scale, e.g.
deployment/api. -
file(path: str) -> SelfScale a resource defined in a file (
-f). -
current_replicas(count: float) -> SelfOnly scale if the current replica count matches (
--current-replicas). -
selector(query: str) -> SelfRestrict to resources matching a label selector (
-l). -
all() -> SelfScale all resources of the given type (
--all).
class KubectlSetEnvSettings(KubectlSetSettings) Settings for kubectl set env.
-
set(key: str, value: str) -> SelfSet a variable (
-e KEY=VALUE); repeatable. -
remove(key: str) -> SelfRemove a variable, which kubectl spells
KEY-(-e KEY-); repeatable. -
from_(reference: str) -> SelfInject every key of a ConfigMap or Secret (
--from), e.g.secret/db. -
keys(*names: str) -> SelfOnly these keys of the from resource (
--keys). -
prefix(value: str) -> SelfPrefix the injected variable names (
--prefix). -
list() -> SelfPrint the environment instead of changing it (
--list). -
resolve() -> SelfShow what the references resolve to when listing (
--resolve). -
overwrite(value: bool | None=None) -> SelfWhether an existing variable may be replaced (
--overwrite).
class KubectlSetImageSettings(KubectlSettings) Settings for kubectl set image.
-
resource(name: str) -> SelfThe resource to update, e.g.
deployment/api(required). -
image(container: str, reference: str) -> SelfSet a container's image (
container=image); repeatable, at least one. -
selector(query: str) -> SelfRestrict to resources matching a label selector (
-l). -
all() -> SelfApply to all resources of the given type (
--all).
class KubectlSetResourcesSettings(KubectlSetSettings) Settings for kubectl set resources.
-
limit(resource: str, quantity: str) -> SelfA resource limit, e.g.
.limit("cpu", "500m"); repeatable. -
request(resource: str, quantity: str) -> SelfA resource request, e.g.
.request("memory", "256Mi"); repeatable.
class KubectlSetSettings(KubectlSettings) Base for the kubectl set subcommands that change a pod template in place: they share the target (a resource, a manifest, or everything in the namespace) and the container selection.
-
resource(*names: str) -> SelfThe resource to change, e.g.
deployment/api; repeatable. -
file(path: str) -> SelfChange the resource identified by a manifest instead (
-f); repeatable. -
all() -> SelfChange every resource of the named types in the namespace (
--all). -
containers(pattern: str) -> SelfWhich containers to change (
-c); kubectl's default is every one. -
selector(query: str) -> SelfRestrict to resources matching a label selector (
-l). -
local() -> SelfRewrite the local manifest without contacting the server (
--local). -
dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> SelfPreview without persisting (
--dry-run=; defaults toclient).
class KubectlSettings(ToolSettings) Base for all kubectl subcommand settings: the binary is kubectl, and the cluster-targeting flags (--namespace, --context, --kubeconfig) are shared by every subcommand.
-
namespace(name: str) -> SelfTarget a namespace (
--namespace). -
context(name: str) -> SelfUse a named kubeconfig context (
--context). -
kubeconfig(path: str) -> SelfUse an explicit kubeconfig file (
--kubeconfig).
class KubectlTaintSettings(KubectlSettings) Settings for kubectl taint.
-
node(*names: str) -> SelfA node to taint; repeatable.
-
taint(key: str, value: str, effect: Literal['NoSchedule', 'PreferNoSchedule', 'NoExecute']) -> SelfAdd a taint, as
key=value:effect; repeatable. -
remove_taint(key: str, effect: Literal['NoSchedule', 'PreferNoSchedule', 'NoExecute'] | None=None) -> SelfRemove a taint, which kubectl spells with a trailing
-; repeatable. -
all() -> SelfTaint every node in the cluster (
--all). -
overwrite() -> SelfReplace a taint of the same key rather than failing (
--overwrite). -
selector(query: str) -> SelfTaint every node matching a label selector (
-l). -
dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> SelfPreview without persisting (
--dry-run=; defaults toclient).
class KubectlTasks Typed task functions for the kubectl CLI.
-
static async apply(ctx: ServiceContext, configure: Callable[[KubectlApplySettings], KubectlApplySettings] | None=None) -> ExecResultApply manifests:
kubectl apply. -
static async create(ctx: ServiceContext, configure: Callable[[KubectlCreateSettings], KubectlCreateSettings] | None=None) -> ExecResultCreate resources:
kubectl create. -
static async delete(ctx: ServiceContext, configure: Callable[[KubectlDeleteSettings], KubectlDeleteSettings] | None=None) -> ExecResultDelete resources:
kubectl delete. -
static async get(ctx: ServiceContext, configure: Callable[[KubectlGetSettings], KubectlGetSettings] | None=None) -> ExecResultList resources:
kubectl get. -
static async get_namespaces(ctx: ServiceContext, configure: Callable[[KubectlGetSettings], KubectlGetSettings] | None=None) -> objectList namespaces as typed KubernetesNamespace records: runs
kubectl get namespaces -o json(forcing JSON output, quietly) and parses the result. Use the lambda for cluster flags or a label.selector(...). -
static async describe(ctx: ServiceContext, configure: Callable[[KubectlDescribeSettings], KubectlDescribeSettings] | None=None) -> ExecResultDescribe resources:
kubectl describe. -
static async logs(ctx: ServiceContext, configure: Callable[[KubectlLogsSettings], KubectlLogsSettings] | None=None) -> ExecResultRead logs:
kubectl logs. -
static async exec(ctx: ServiceContext, configure: Callable[[KubectlExecSettings], KubectlExecSettings] | None=None) -> ExecResultExec into a container:
kubectl exec. -
static async rollout(ctx: ServiceContext, configure: Callable[[KubectlRolloutSettings], KubectlRolloutSettings] | None=None) -> ExecResultManage rollouts:
kubectl rollout. -
static async scale(ctx: ServiceContext, configure: Callable[[KubectlScaleSettings], KubectlScaleSettings] | None=None) -> ExecResultScale a workload:
kubectl scale. -
static async set_image(ctx: ServiceContext, configure: Callable[[KubectlSetImageSettings], KubectlSetImageSettings] | None=None) -> ExecResultUpdate a container image:
kubectl set image. -
static async annotate(ctx: ServiceContext, configure: Callable[[KubectlAnnotateSettings], KubectlAnnotateSettings] | None=None) -> ExecResultAnnotate resources:
kubectl annotate. -
static async label(ctx: ServiceContext, configure: Callable[[KubectlLabelSettings], KubectlLabelSettings] | None=None) -> ExecResultLabel resources:
kubectl label. -
static async patch(ctx: ServiceContext, configure: Callable[[KubectlPatchSettings], KubectlPatchSettings] | None=None) -> ExecResultPatch a resource:
kubectl patch. -
static async port_forward(ctx: ServiceContext, configure: Callable[[KubectlPortForwardSettings], KubectlPortForwardSettings] | None=None) -> ExecResultForward local ports:
kubectl port-forward. -
static async wait(ctx: ServiceContext, configure: Callable[[KubectlWaitSettings], KubectlWaitSettings] | None=None) -> ExecResultWait for a condition:
kubectl wait. -
static async top(ctx: ServiceContext, configure: Callable[[KubectlTopSettings], KubectlTopSettings] | None=None) -> ExecResultShow resource usage:
kubectl top. -
static async diff(ctx: ServiceContext, configure: Callable[[KubectlDiffSettings], KubectlDiffSettings] | None=None) -> ExecResultShow what an apply would change:
kubectl diff. The command exits 1 when it finds differences, so this task fails the target on drift — which is what a gate wants. Use KubectlTasksApi.diffHasChanges to read the answer as a value instead. -
static async diff_has_changes(ctx: ServiceContext, configure: Callable[[KubectlDiffSettings], KubectlDiffSettings] | None=None) -> objectWhether an apply would change anything:
truewhenkubectl diffreports differences,falsewhen it reports none. An exit code above 1 means kubectl or its differ failed and still fails the build. -
static async replace(ctx: ServiceContext, configure: Callable[[KubectlReplaceSettings], KubectlReplaceSettings] | None=None) -> ExecResultReplace a resource wholesale:
kubectl replace. -
static async get_entries(ctx: ServiceContext, configure: Callable[[KubectlGetSettings], KubectlGetSettings] | None=None) -> objectEvery matching resource as typed KubernetesResource records: runs
kubectl get … -o jsonand parses the common metadata, whatever the kind. -
static async explain(ctx: ServiceContext, configure: Callable[[KubectlExplainSettings], KubectlExplainSettings] | None=None) -> ExecResultShow a resource type's schema:
kubectl explain. -
static async set_env(ctx: ServiceContext, configure: Callable[[KubectlSetEnvSettings], KubectlSetEnvSettings] | None=None) -> ExecResultChange environment variables on a pod template:
kubectl set env. -
static async set_resources(ctx: ServiceContext, configure: Callable[[KubectlSetResourcesSettings], KubectlSetResourcesSettings] | None=None) -> ExecResultChange requests and limits on a pod template:
kubectl set resources. -
static async run(ctx: ServiceContext, configure: Callable[[KubectlRunSettings], KubectlRunSettings] | None=None) -> ExecResultRun one pod imperatively:
kubectl run. -
static async expose(ctx: ServiceContext, configure: Callable[[KubectlExposeSettings], KubectlExposeSettings] | None=None) -> ExecResultPut a service in front of a workload:
kubectl expose. -
static async cp(ctx: ServiceContext, configure: Callable[[KubectlCpSettings], KubectlCpSettings] | None=None) -> ExecResultCopy files into or out of a container:
kubectl cp. -
static async events(ctx: ServiceContext, configure: Callable[[KubectlEventsSettings], KubectlEventsSettings] | None=None) -> ExecResultReport cluster events:
kubectl events. -
static async event_entries(ctx: ServiceContext, configure: Callable[[KubectlEventsSettings], KubectlEventsSettings] | None=None) -> objectThe events as typed KubernetesEvent records — what a build reads when a rollout stalls and
rollout statuswill not say why. -
static async current_context(ctx: ServiceContext, configure: Callable[[KubectlConfigCurrentContextSettings], KubectlConfigCurrentContextSettings] | None=None) -> objectThe name of the current kubeconfig context:
kubectl config current-context. -
static async contexts(ctx: ServiceContext, configure: Callable[[KubectlConfigGetContextsSettings], KubectlConfigGetContextsSettings] | None=None) -> objectThe available context names:
kubectl config get-contexts -o name. -
static async use_context(ctx: ServiceContext, configure: Callable[[KubectlConfigUseContextSettings], KubectlConfigUseContextSettings] | None=None) -> ExecResultSwitch the current context:
kubectl config use-context. -
static async set_context(ctx: ServiceContext, configure: Callable[[KubectlConfigSetContextSettings], KubectlConfigSetContextSettings] | None=None) -> ExecResultWrite a context entry:
kubectl config set-context. -
static async config_view(ctx: ServiceContext, configure: Callable[[KubectlConfigViewSettings], KubectlConfigViewSettings] | None=None) -> ExecResultShow the merged kubeconfig:
kubectl config view. -
static async version(ctx: ServiceContext, configure: Callable[[KubectlVersionSettings], KubectlVersionSettings] | None=None) -> ExecResultPrint the client and server versions:
kubectl version. -
static async version_info(ctx: ServiceContext, configure: Callable[[KubectlVersionSettings], KubectlVersionSettings] | None=None) -> objectThe client and server versions, parsed from
kubectl version -o json. -
static async cluster_info(ctx: ServiceContext, configure: Callable[[KubectlClusterInfoSettings], KubectlClusterInfoSettings] | None=None) -> ExecResultShow where the cluster's services live:
kubectl cluster-info. -
static async api_resources(ctx: ServiceContext, configure: Callable[[KubectlApiResourcesSettings], KubectlApiResourcesSettings] | None=None) -> ExecResultList the server's API resources:
kubectl api-resources. -
static async api_versions(ctx: ServiceContext, configure: Callable[[KubectlApiVersionsSettings], KubectlApiVersionsSettings] | None=None) -> ExecResultList the server's API versions:
kubectl api-versions. -
static async auth_can_i(ctx: ServiceContext, configure: Callable[[KubectlAuthCanISettings], KubectlAuthCanISettings] | None=None) -> ExecResultCheck a permission:
kubectl auth can-i. -
static async can_i(ctx: ServiceContext, configure: Callable[[KubectlAuthCanISettings], KubectlAuthCanISettings] | None=None) -> objectWhether the action is allowed.
kubectl auth can-ianswers through its exit status, so this reads the code rather than failing the build on a routine "no". -
static async kustomize(ctx: ServiceContext, configure: Callable[[KubectlKustomizeSettings], KubectlKustomizeSettings] | None=None) -> ExecResultRender a kustomization to stdout:
kubectl kustomize. -
static async cordon(ctx: ServiceContext, configure: Callable[[KubectlCordonSettings], KubectlCordonSettings] | None=None) -> ExecResultMark a node unschedulable, or schedulable again:
kubectl cordon/uncordon. -
static async drain(ctx: ServiceContext, configure: Callable[[KubectlDrainSettings], KubectlDrainSettings] | None=None) -> ExecResultEvict a node's pods before maintenance:
kubectl drain. -
static async taint(ctx: ServiceContext, configure: Callable[[KubectlTaintSettings], KubectlTaintSettings] | None=None) -> ExecResultAdd or remove node taints:
kubectl taint.
class KubectlTopSettings(KubectlSettings) Settings for kubectl top.
-
pods() -> SelfReport pod usage (
top pods). -
nodes() -> SelfReport node usage (
top nodes). -
name(value: str) -> SelfLimit to a single named pod or node.
-
selector(query: str) -> SelfRestrict to resources matching a label selector (
-l). -
containers() -> SelfBreak pod usage down by container (
--containers). -
all_namespaces() -> SelfReport across all namespaces (
-A).
class KubectlVersionSettings(KubectlSettings) Settings for kubectl version.
-
client_only() -> SelfReport the client's version without reaching a cluster (
--client). -
output(format: Literal['json', 'yaml']) -> SelfThe output format (
-o):jsonoryaml.
class KubectlWaitSettings(KubectlSettings) Settings for kubectl wait.
-
file(path: str) -> SelfWait on resources defined in a file (
-f); repeatable. -
resource(*tokens: str) -> SelfResource tokens, e.g.
("pod/web")or("pods"); repeatable. -
for_condition(condition: str) -> SelfThe condition to wait for, e.g.
condition=Availableordelete. -
timeout(duration: str) -> SelfHow long to wait, e.g.
60s(--timeout). -
selector(query: str) -> SelfRestrict to resources matching a label selector (
-l). -
all() -> SelfWait on all resources of the given type (
--all).