zuke.tools.kubectl

← Python API reference

@zuke/kubectl 1.2.1: @zuke/kubectl — typed kubectl CLI task wrappers for Zuke builds, for deploying to and managing Kubernetes from a pipeline.

Symbols

#

KubectlAnnotateSettings

class
class KubectlAnnotateSettings(KubectlSettings)

Settings for kubectl annotate.

  • resource(*tokens: str) -> Self

    Resource tokens, e.g. ("deploy", "api") or ("pods", "-l", "app=web"); repeatable.

  • annotation(key: str, value: str) -> Self

    Set an annotation as a key=value token; repeatable.

  • remove(key: str) -> Self

    Remove an annotation, rendered as kubectl's key- syntax; repeatable.

  • overwrite() -> Self

    Overwrite existing annotations (--overwrite).

  • all() -> Self

    Apply to all resources of the given type (--all).

  • selector(query: str) -> Self

    Restrict to resources matching a label selector (-l).

#

KubectlApiResourcesSettings

class
class KubectlApiResourcesSettings(KubectlSettings)

Settings for kubectl api-resources.

  • api_group(name: str) -> Self

    Only resources in this API group (--api-group).

  • namespaced(value: bool | None=None) -> Self

    Whether to list namespaced resources (--namespaced); kubectl's default is true, so pass false for the cluster-scoped ones.

  • verbs(*names: str) -> Self

    Only resources supporting these verbs (--verbs).

  • categories(*names: str) -> Self

    Only resources in these categories (--categories).

  • sort_by(field: Literal['name', 'kind']) -> Self

    Sort by name or kind (--sort-by).

  • output(format: str) -> Self

    The output format (-o), e.g. name or wide.

  • no_headers() -> Self

    Leave the header row out (--no-headers).

  • cached() -> Self

    Use the discovery cache rather than asking the server (--cached).

#

KubectlApiVersionsSettings

class
class KubectlApiVersionsSettings(KubectlSettings)

Settings for kubectl api-versions.

#

KubectlApplySettings

class
class KubectlApplySettings(KubectlSettings)

Settings for kubectl apply.

  • file(path: str) -> Self

    Apply a manifest file, directory, or URL (-f); repeatable.

  • kustomize(dir: str) -> Self

    Apply a kustomization directory (-k).

  • recursive() -> Self

    Recurse into directories given to -f (-R).

  • prune() -> Self

    Prune resources not present in the applied set (--prune).

  • server_side() -> Self

    Apply server-side (--server-side).

  • dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> Self

    Preview without persisting (--dry-run=; defaults to client).

  • selector(query: str) -> Self

    Restrict to resources matching a label selector (-l).

  • force() -> Self

    Force apply by delete-and-recreate when needed (--force).

#

KubectlAuthCanISettings

class
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) -> Self

    The API verb to check, e.g. create (required unless list).

  • resource(name: str) -> Self

    The resource, e.g. deployments or deployments/api.

  • subresource(name: str) -> Self

    A subresource, e.g. log or scale (--subresource).

  • all_namespaces() -> Self

    Check across every namespace (--all-namespaces).

  • list() -> Self

    Print every allowed action instead of checking one (--list).

  • quiet_answer() -> Self

    Print 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.

#

KubectlClusterInfoSettings

class
class KubectlClusterInfoSettings(KubectlSettings)

Settings for kubectl cluster-info.

#

KubectlConfigCurrentContextSettings

class
class KubectlConfigCurrentContextSettings(KubectlSettings)

Settings for kubectl config current-context.

#

KubectlConfigGetContextsSettings

class
class KubectlConfigGetContextsSettings(KubectlSettings)

Settings for kubectl config get-contexts.

  • names_only() -> Self

    Print only the names (-o name), the one output format gh accepts here.

  • no_headers() -> Self

    Leave the header row out (--no-headers).

#

KubectlConfigSetContextSettings

class
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) -> Self

    The context to write (required unless current is set).

  • current() -> Self

    Modify the current context rather than a named one (--current).

  • cluster(name: str) -> Self

    The cluster the context points at (--cluster).

  • user(name: str) -> Self

    The user the context authenticates as (--user).

#

KubectlConfigUseContextSettings

class
class KubectlConfigUseContextSettings(KubectlSettings)

Settings for kubectl config use-context.

  • context_name(name: str) -> Self

    The context to switch to (required).

#

KubectlConfigViewSettings

class
class KubectlConfigViewSettings(KubectlSettings)

Settings for kubectl config view.

  • minify() -> Self

    Keep only what the current context uses (--minify).

  • flatten() -> Self

    Inline the referenced files, for a portable kubeconfig (--flatten).

  • raw() -> Self

    Print the credentials in the clear (--raw). kubectl redacts them by default; anything this prints belongs in a parameter().secret(), not in a build's log.

  • output(format: str) -> Self

    The output format (-o), e.g. json; kubectl's default is yaml.

#

KubectlCordonSettings

class
class KubectlCordonSettings(KubectlSettings)

Settings for kubectl cordon and kubectl uncordon — marking a node unschedulable, and letting it take pods again.

  • node(name: str) -> Self

    The node to act on; required unless a selector picks them.

  • uncordon() -> Self

    Make the node schedulable again instead — kubectl uncordon.

  • selector(query: str) -> Self

    Act on every node matching a label selector (-l).

  • dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> Self

    Preview without persisting (--dry-run=; defaults to client).

#

KubectlCpSettings

class
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) -> Self

    Where to copy from: a local path, or pod:path / namespace/pod:path.

  • to(spec: str) -> Self

    Where to copy to, in the same two forms.

  • container(name: str) -> Self

    Which container of the pod (-c).

  • no_preserve() -> Self

    Do not carry ownership and permissions across (--no-preserve).

  • retries(count: float) -> Self

    Retry a copy out of a container this many times (--retries).

#

KubectlCreateSettings

class
class KubectlCreateSettings(KubectlSettings)

Settings for kubectl create.

  • file(path: str) -> Self

    Create from a manifest file, directory, or URL (-f); repeatable. For resource-form creation (create secret …), use the base .args(...).

  • recursive() -> Self

    Recurse into directories given to -f (-R).

  • dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> Self

    Preview without persisting (--dry-run=; defaults to client).

  • output(format: str) -> Self

    Output format, e.g. yaml or json (-o).

  • save_config() -> Self

    Record the current resource in its annotation (--save-config).

#

KubectlDeleteSettings

class
class KubectlDeleteSettings(KubectlSettings)

Settings for kubectl delete.

  • file(path: str) -> Self

    Delete from a manifest file or directory (-f); repeatable.

  • resource(*tokens: str) -> Self

    Resource tokens, e.g. ("pod", "web") or ("deployment/api"); repeatable.

  • selector(query: str) -> Self

    Restrict to resources matching a label selector (-l).

  • all() -> Self

    Delete all resources of the given type (--all).

  • ignore_not_found() -> Self

    Treat "not found" as a success (--ignore-not-found).

  • force() -> Self

    Force immediate deletion (--force).

  • grace_period(seconds: float) -> Self

    Seconds to wait before forceful termination (--grace-period).

  • recursive() -> Self

    Recurse into directories given to -f (-R).

#

KubectlDescribeSettings

class
class KubectlDescribeSettings(KubectlSettings)

Settings for kubectl describe.

  • resource(*tokens: str) -> Self

    Resource tokens, e.g. ("pod", "web") or ("deployment/api"); repeatable.

  • selector(query: str) -> Self

    Restrict to resources matching a label selector (-l).

#

KubectlDiffSettings

class
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) -> Self

    Diff a manifest file, directory, or URL (-f); repeatable.

  • kustomize(dir: str) -> Self

    Diff a kustomization directory (-k).

  • recursive() -> Self

    Recurse into directories given to -f (-R).

  • server_side() -> Self

    Diff the server-side apply (--server-side).

  • force_conflicts() -> Self

    Take ownership of conflicting fields (--force-conflicts).

  • prune() -> Self

    Include what a prune would delete (--prune).

  • selector(query: str) -> Self

    Restrict to resources matching a label selector (-l).

  • show_managed_fields() -> Self

    Include the managed fields, which are otherwise hidden (--show-managed-fields).

  • concurrency(count: float) -> Self

    How many objects to diff in parallel (--concurrency).

#

KubectlDrainSettings

class
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) -> Self

    The node to drain; required unless a selector picks them.

  • force() -> Self

    Evict pods no controller manages, which nothing will recreate (--force).

  • ignore_daemon_sets() -> Self

    Proceed past DaemonSet-managed pods, which drain never deletes (--ignore-daemonsets).

  • delete_empty_dir_data() -> Self

    Proceed past pods using emptyDir, destroying that data (--delete-emptydir-data).

  • disable_eviction() -> Self

    Delete rather than evict (--disable-eviction), which bypasses every PodDisruptionBudget — the guardrail an operator wrote down on purpose.

  • grace_period(seconds: float) -> Self

    Seconds each pod gets to terminate (--grace-period).

  • timeout(duration: str) -> Self

    How long to wait for the drain overall, e.g. 5m (--timeout).

  • pod_selector(query: str) -> Self

    Only drain pods matching this label selector (--pod-selector).

  • selector(query: str) -> Self

    Drain every node matching this label selector (-l).

  • skip_wait_for_delete_timeout(seconds: float) -> Self

    Stop waiting on pods already deleting this long (--skip-wait-for-delete-timeout).

  • dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> Self

    Preview without persisting (--dry-run=; defaults to client).

#

KubectlEventsSettings

class
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) -> Self

    Only events about this resource, as TYPE/NAME (--for).

  • types(*names: str) -> Self

    Only events of these types, e.g. Warning (--types).

  • all_namespaces() -> Self

    Across every namespace (-A).

  • watch() -> Self

    Keep 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() -> Self

    Leave the header row out (--no-headers).

  • output(format: str) -> Self

    The output format (-o), e.g. json.

#

KubectlExecSettings

class
class KubectlExecSettings(KubectlSettings)

Settings for kubectl exec.

  • resource(name: str) -> Self

    The pod (or type/name) to exec into (required).

  • container(name: str) -> Self

    Target a specific container (-c).

  • stdin() -> Self

    Keep STDIN open (-i).

  • tty() -> Self

    Allocate a TTY (-t).

  • command(*args: str | float) -> Self

    The command and arguments to run in the container (required).

#

KubectlExplainSettings

class
class KubectlExplainSettings(KubectlSettings)

Settings for kubectl explain — the schema of a resource type.

  • type_(name: str) -> Self

    The type to explain, e.g. pods or deployments.spec.replicas.

  • recursive() -> Self

    Print nested fields too (-R).

  • max_depth(depth: float) -> Self

    Cap how deep recursive goes (--max-depth).

  • api_version(value: str) -> Self

    Explain a particular API group/version (--api-version).

  • output(format: str) -> Self

    How to render the schema (-o): plaintext or plaintext-openapiv2.

#

KubectlExposeSettings

class
class KubectlExposeSettings(KubectlSettings)

Settings for kubectl expose — a service in front of an existing workload.

  • resource(reference: str) -> Self

    The workload to expose, e.g. deployment/api.

  • file(path: str) -> Self

    Expose the workload a manifest identifies instead (-f); repeatable.

  • port(value: str | float) -> Self

    The port the service serves on (--port).

  • target_port(value: str | float) -> Self

    The container port traffic goes to (--target-port).

  • type_(value: str) -> Self

    The service type (--type), e.g. LoadBalancer.

  • name(value: str) -> Self

    The new service's name (--name).

  • protocol(value: str) -> Self

    The protocol (--protocol), e.g. TCP.

  • selector(query: str) -> Self

    The 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) -> Self

    Labels for the created service (--labels), comma-separated.

  • session_affinity(value: Literal['None', 'ClientIP']) -> Self

    Session affinity (--session-affinity): None or ClientIP.

  • dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> Self

    Preview without persisting (--dry-run=; defaults to client).

#

KubectlGetSettings

class
class KubectlGetSettings(KubectlSettings)

Settings for kubectl get.

  • resource(*tokens: str) -> Self

    Resource tokens, e.g. ("pods") or ("pod", "web"); repeatable.

  • output(format: str) -> Self

    Output format, e.g. wide, yaml, json, jsonpath=… (-o).

  • selector(query: str) -> Self

    Restrict to resources matching a label selector (-l).

  • field_selector(query: str) -> Self

    Restrict by field selector (--field-selector).

  • all_namespaces() -> Self

    List across all namespaces (-A).

  • watch(on: bool | None=None) -> Self

    Watch for changes instead of returning once (-w); pass false to disable.

  • show_labels() -> Self

    Include resource labels as columns (--show-labels).

#

KubectlKustomizeSettings

class
class KubectlKustomizeSettings(KubectlSettings)

Settings for kubectl kustomize — rendering a kustomization to stdout.

  • dir(path: str) -> Self

    The kustomization directory or repository URL; kubectl assumes ..

  • output(path: str) -> Self

    Write the rendered output to a file instead of stdout (-o).

  • enable_helm() -> Self

    Allow the Helm chart inflator generator (--enable-helm).

  • load_restrictor(value: str) -> Self

    Relax where a kustomization may load files from (--load-restrictor).

#

KubectlLabelSettings

class
class KubectlLabelSettings(KubectlSettings)

Settings for kubectl label.

  • resource(*tokens: str) -> Self

    Resource tokens, e.g. ("deploy", "api") or ("pods", "-l", "app=web"); repeatable.

  • label(key: str, value: str) -> Self

    Set a label as a key=value token; repeatable.

  • remove(key: str) -> Self

    Remove a label, rendered as kubectl's key- syntax; repeatable.

  • overwrite() -> Self

    Overwrite existing labels (--overwrite).

  • all() -> Self

    Apply to all resources of the given type (--all).

  • selector(query: str) -> Self

    Restrict to resources matching a label selector (-l).

#

KubectlLogsSettings

class
class KubectlLogsSettings(KubectlSettings)

Settings for kubectl logs.

  • resource(name: str) -> Self

    The pod (or type/name) to read logs from.

  • container(name: str) -> Self

    Read from a specific container (-c).

  • selector(query: str) -> Self

    Select pods by label instead of naming one (-l).

  • follow() -> Self

    Stream new log output (-f).

  • previous() -> Self

    Read the previous container instance's logs (--previous).

  • tail(lines: float) -> Self

    Show only the last N lines (--tail).

  • since(duration: str) -> Self

    Only logs newer than a duration, e.g. 5m (--since).

  • all_containers() -> Self

    Include all containers in the pod (--all-containers).

  • timestamps() -> Self

    Prefix each line with a timestamp (--timestamps).

#

KubectlPatchSettings

class
class KubectlPatchSettings(KubectlSettings)

Settings for kubectl patch.

  • resource(name: str) -> Self

    The resource to patch, e.g. deployment/api (required).

  • patch(content: str) -> Self

    The patch document (-p, required).

  • type_(strategy: Literal['strategic', 'merge', 'json']) -> Self

    The patch strategy (--type).

#

KubectlPortForwardSettings

class
class KubectlPortForwardSettings(KubectlSettings)

Settings for kubectl port-forward.

  • resource(name: str) -> Self

    The pod or service, e.g. svc/api (required).

  • port(mapping: str) -> Self

    A port mapping, e.g. 8080:80 or 8080; repeatable, at least one.

  • address(value: str) -> Self

    The local address(es) to bind (--address).

#

KubectlReplaceSettings

class
class KubectlReplaceSettings(KubectlSettings)

Settings for kubectl replace.

  • file(path: str) -> Self

    Replace from a manifest file, directory, or URL (-f); repeatable.

  • kustomize(dir: str) -> Self

    Replace from a kustomization directory (-k).

  • recursive() -> Self

    Recurse into directories given to -f (-R).

  • force() -> Self

    Delete 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) -> Self

    Seconds each object gets to terminate (--grace-period).

  • timeout(duration: str) -> Self

    How long to wait on the delete half, e.g. 60s (--timeout).

  • cascade(strategy: Literal['background', 'orphan', 'foreground']) -> Self

    The cascading strategy for dependents (--cascade).

  • wait() -> Self

    Wait for the resources to be gone before returning (--wait).

  • dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> Self

    Preview without persisting (--dry-run=; defaults to client).

#

KubectlRolloutSettings

class
class KubectlRolloutSettings(KubectlSettings)

Settings for kubectl rollout.

  • status() -> Self

    Show rollout status (rollout status).

  • restart() -> Self

    Restart a rollout (rollout restart).

  • undo() -> Self

    Roll back to the previous revision (rollout undo).

  • history() -> Self

    Show rollout history (rollout history).

  • pause() -> Self

    Stop the rollout where it is (rollout pause) — half of a canary. A paused workload takes no further updates until resume.

  • resume() -> Self

    Let a paused rollout continue (rollout resume).

  • resource(name: str) -> Self

    The resource, e.g. deployment/api (required).

  • to_revision(revision: float) -> Self

    With undo, the revision to roll back to (--to-revision).

  • timeout(duration: str) -> Self

    With status, how long to wait, e.g. 60s (--timeout).

#

KubectlRunSettings

class
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) -> Self

    The pod's name (required).

  • image(reference: str) -> Self

    The image to run (--image, required).

  • restart(policy: Literal['Always', 'OnFailure', 'Never']) -> Self

    The restart policy (--restart).

  • env_var(key: str, value: str) -> Self

    An environment variable for the container (--env KEY=VALUE); repeatable. Named apart from the inherited .env(...), which sets the environment kubectl itself runs in.

  • labels(value: str) -> Self

    Labels for the pod (--labels), comma-separated.

  • port(value: str | float) -> Self

    The port the container exposes (--port).

  • overrides(json: str) -> Self

    An inline JSON override for the generated pod (--overrides).

  • expose() -> Self

    Also create a ClusterIP service (--expose), which needs port.

  • command(first: str, *rest: str) -> Self

    The 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) -> Self

    Preview without persisting (--dry-run=; defaults to client).

#

KubectlScaleSettings

class
class KubectlScaleSettings(KubectlSettings)

Settings for kubectl scale.

  • replicas(count: float) -> Self

    Desired replica count (--replicas, required).

  • resource(name: str) -> Self

    The resource to scale, e.g. deployment/api.

  • file(path: str) -> Self

    Scale a resource defined in a file (-f).

  • current_replicas(count: float) -> Self

    Only scale if the current replica count matches (--current-replicas).

  • selector(query: str) -> Self

    Restrict to resources matching a label selector (-l).

  • all() -> Self

    Scale all resources of the given type (--all).

#

KubectlSetEnvSettings

class
class KubectlSetEnvSettings(KubectlSetSettings)

Settings for kubectl set env.

  • set(key: str, value: str) -> Self

    Set a variable (-e KEY=VALUE); repeatable.

  • remove(key: str) -> Self

    Remove a variable, which kubectl spells KEY- (-e KEY-); repeatable.

  • from_(reference: str) -> Self

    Inject every key of a ConfigMap or Secret (--from), e.g. secret/db.

  • keys(*names: str) -> Self

    Only these keys of the from resource (--keys).

  • prefix(value: str) -> Self

    Prefix the injected variable names (--prefix).

  • list() -> Self

    Print the environment instead of changing it (--list).

  • resolve() -> Self

    Show what the references resolve to when listing (--resolve).

  • overwrite(value: bool | None=None) -> Self

    Whether an existing variable may be replaced (--overwrite).

#

KubectlSetImageSettings

class
class KubectlSetImageSettings(KubectlSettings)

Settings for kubectl set image.

  • resource(name: str) -> Self

    The resource to update, e.g. deployment/api (required).

  • image(container: str, reference: str) -> Self

    Set a container's image (container=image); repeatable, at least one.

  • selector(query: str) -> Self

    Restrict to resources matching a label selector (-l).

  • all() -> Self

    Apply to all resources of the given type (--all).

#

KubectlSetResourcesSettings

class
class KubectlSetResourcesSettings(KubectlSetSettings)

Settings for kubectl set resources.

  • limit(resource: str, quantity: str) -> Self

    A resource limit, e.g. .limit("cpu", "500m"); repeatable.

  • request(resource: str, quantity: str) -> Self

    A resource request, e.g. .request("memory", "256Mi"); repeatable.

#

KubectlSetSettings

class
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) -> Self

    The resource to change, e.g. deployment/api; repeatable.

  • file(path: str) -> Self

    Change the resource identified by a manifest instead (-f); repeatable.

  • all() -> Self

    Change every resource of the named types in the namespace (--all).

  • containers(pattern: str) -> Self

    Which containers to change (-c); kubectl's default is every one.

  • selector(query: str) -> Self

    Restrict to resources matching a label selector (-l).

  • local() -> Self

    Rewrite the local manifest without contacting the server (--local).

  • dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> Self

    Preview without persisting (--dry-run=; defaults to client).

#

KubectlSettings

class
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) -> Self

    Target a namespace (--namespace).

  • context(name: str) -> Self

    Use a named kubeconfig context (--context).

  • kubeconfig(path: str) -> Self

    Use an explicit kubeconfig file (--kubeconfig).

#

KubectlTaintSettings

class
class KubectlTaintSettings(KubectlSettings)

Settings for kubectl taint.

  • node(*names: str) -> Self

    A node to taint; repeatable.

  • taint(key: str, value: str, effect: Literal['NoSchedule', 'PreferNoSchedule', 'NoExecute']) -> Self

    Add a taint, as key=value:effect; repeatable.

  • remove_taint(key: str, effect: Literal['NoSchedule', 'PreferNoSchedule', 'NoExecute'] | None=None) -> Self

    Remove a taint, which kubectl spells with a trailing -; repeatable.

  • all() -> Self

    Taint every node in the cluster (--all).

  • overwrite() -> Self

    Replace a taint of the same key rather than failing (--overwrite).

  • selector(query: str) -> Self

    Taint every node matching a label selector (-l).

  • dry_run(mode: Literal['none', 'client', 'server'] | None=None) -> Self

    Preview without persisting (--dry-run=; defaults to client).

#

KubectlTasks

class
class KubectlTasks

Typed task functions for the kubectl CLI.

  • static async apply(ctx: ServiceContext, configure: Callable[[KubectlApplySettings], KubectlApplySettings] | None=None) -> ExecResult

    Apply manifests: kubectl apply.

  • static async create(ctx: ServiceContext, configure: Callable[[KubectlCreateSettings], KubectlCreateSettings] | None=None) -> ExecResult

    Create resources: kubectl create.

  • static async delete(ctx: ServiceContext, configure: Callable[[KubectlDeleteSettings], KubectlDeleteSettings] | None=None) -> ExecResult

    Delete resources: kubectl delete.

  • static async get(ctx: ServiceContext, configure: Callable[[KubectlGetSettings], KubectlGetSettings] | None=None) -> ExecResult

    List resources: kubectl get.

  • static async get_namespaces(ctx: ServiceContext, configure: Callable[[KubectlGetSettings], KubectlGetSettings] | None=None) -> object

    List 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) -> ExecResult

    Describe resources: kubectl describe.

  • static async logs(ctx: ServiceContext, configure: Callable[[KubectlLogsSettings], KubectlLogsSettings] | None=None) -> ExecResult

    Read logs: kubectl logs.

  • static async exec(ctx: ServiceContext, configure: Callable[[KubectlExecSettings], KubectlExecSettings] | None=None) -> ExecResult

    Exec into a container: kubectl exec.

  • static async rollout(ctx: ServiceContext, configure: Callable[[KubectlRolloutSettings], KubectlRolloutSettings] | None=None) -> ExecResult

    Manage rollouts: kubectl rollout.

  • static async scale(ctx: ServiceContext, configure: Callable[[KubectlScaleSettings], KubectlScaleSettings] | None=None) -> ExecResult

    Scale a workload: kubectl scale.

  • static async set_image(ctx: ServiceContext, configure: Callable[[KubectlSetImageSettings], KubectlSetImageSettings] | None=None) -> ExecResult

    Update a container image: kubectl set image.

  • static async annotate(ctx: ServiceContext, configure: Callable[[KubectlAnnotateSettings], KubectlAnnotateSettings] | None=None) -> ExecResult

    Annotate resources: kubectl annotate.

  • static async label(ctx: ServiceContext, configure: Callable[[KubectlLabelSettings], KubectlLabelSettings] | None=None) -> ExecResult

    Label resources: kubectl label.

  • static async patch(ctx: ServiceContext, configure: Callable[[KubectlPatchSettings], KubectlPatchSettings] | None=None) -> ExecResult

    Patch a resource: kubectl patch.

  • static async port_forward(ctx: ServiceContext, configure: Callable[[KubectlPortForwardSettings], KubectlPortForwardSettings] | None=None) -> ExecResult

    Forward local ports: kubectl port-forward.

  • static async wait(ctx: ServiceContext, configure: Callable[[KubectlWaitSettings], KubectlWaitSettings] | None=None) -> ExecResult

    Wait for a condition: kubectl wait.

  • static async top(ctx: ServiceContext, configure: Callable[[KubectlTopSettings], KubectlTopSettings] | None=None) -> ExecResult

    Show resource usage: kubectl top.

  • static async diff(ctx: ServiceContext, configure: Callable[[KubectlDiffSettings], KubectlDiffSettings] | None=None) -> ExecResult

    Show 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) -> object

    Whether an apply would change anything: true when kubectl diff reports differences, false when 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) -> ExecResult

    Replace a resource wholesale: kubectl replace.

  • static async get_entries(ctx: ServiceContext, configure: Callable[[KubectlGetSettings], KubectlGetSettings] | None=None) -> object

    Every matching resource as typed KubernetesResource records: runs kubectl get … -o json and parses the common metadata, whatever the kind.

  • static async explain(ctx: ServiceContext, configure: Callable[[KubectlExplainSettings], KubectlExplainSettings] | None=None) -> ExecResult

    Show a resource type's schema: kubectl explain.

  • static async set_env(ctx: ServiceContext, configure: Callable[[KubectlSetEnvSettings], KubectlSetEnvSettings] | None=None) -> ExecResult

    Change environment variables on a pod template: kubectl set env.

  • static async set_resources(ctx: ServiceContext, configure: Callable[[KubectlSetResourcesSettings], KubectlSetResourcesSettings] | None=None) -> ExecResult

    Change requests and limits on a pod template: kubectl set resources.

  • static async run(ctx: ServiceContext, configure: Callable[[KubectlRunSettings], KubectlRunSettings] | None=None) -> ExecResult

    Run one pod imperatively: kubectl run.

  • static async expose(ctx: ServiceContext, configure: Callable[[KubectlExposeSettings], KubectlExposeSettings] | None=None) -> ExecResult

    Put a service in front of a workload: kubectl expose.

  • static async cp(ctx: ServiceContext, configure: Callable[[KubectlCpSettings], KubectlCpSettings] | None=None) -> ExecResult

    Copy files into or out of a container: kubectl cp.

  • static async events(ctx: ServiceContext, configure: Callable[[KubectlEventsSettings], KubectlEventsSettings] | None=None) -> ExecResult

    Report cluster events: kubectl events.

  • static async event_entries(ctx: ServiceContext, configure: Callable[[KubectlEventsSettings], KubectlEventsSettings] | None=None) -> object

    The events as typed KubernetesEvent records — what a build reads when a rollout stalls and rollout status will not say why.

  • static async current_context(ctx: ServiceContext, configure: Callable[[KubectlConfigCurrentContextSettings], KubectlConfigCurrentContextSettings] | None=None) -> object

    The name of the current kubeconfig context: kubectl config current-context.

  • static async contexts(ctx: ServiceContext, configure: Callable[[KubectlConfigGetContextsSettings], KubectlConfigGetContextsSettings] | None=None) -> object

    The available context names: kubectl config get-contexts -o name.

  • static async use_context(ctx: ServiceContext, configure: Callable[[KubectlConfigUseContextSettings], KubectlConfigUseContextSettings] | None=None) -> ExecResult

    Switch the current context: kubectl config use-context.

  • static async set_context(ctx: ServiceContext, configure: Callable[[KubectlConfigSetContextSettings], KubectlConfigSetContextSettings] | None=None) -> ExecResult

    Write a context entry: kubectl config set-context.

  • static async config_view(ctx: ServiceContext, configure: Callable[[KubectlConfigViewSettings], KubectlConfigViewSettings] | None=None) -> ExecResult

    Show the merged kubeconfig: kubectl config view.

  • static async version(ctx: ServiceContext, configure: Callable[[KubectlVersionSettings], KubectlVersionSettings] | None=None) -> ExecResult

    Print the client and server versions: kubectl version.

  • static async version_info(ctx: ServiceContext, configure: Callable[[KubectlVersionSettings], KubectlVersionSettings] | None=None) -> object

    The client and server versions, parsed from kubectl version -o json.

  • static async cluster_info(ctx: ServiceContext, configure: Callable[[KubectlClusterInfoSettings], KubectlClusterInfoSettings] | None=None) -> ExecResult

    Show where the cluster's services live: kubectl cluster-info.

  • static async api_resources(ctx: ServiceContext, configure: Callable[[KubectlApiResourcesSettings], KubectlApiResourcesSettings] | None=None) -> ExecResult

    List the server's API resources: kubectl api-resources.

  • static async api_versions(ctx: ServiceContext, configure: Callable[[KubectlApiVersionsSettings], KubectlApiVersionsSettings] | None=None) -> ExecResult

    List the server's API versions: kubectl api-versions.

  • static async auth_can_i(ctx: ServiceContext, configure: Callable[[KubectlAuthCanISettings], KubectlAuthCanISettings] | None=None) -> ExecResult

    Check a permission: kubectl auth can-i.

  • static async can_i(ctx: ServiceContext, configure: Callable[[KubectlAuthCanISettings], KubectlAuthCanISettings] | None=None) -> object

    Whether the action is allowed. kubectl auth can-i answers 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) -> ExecResult

    Render a kustomization to stdout: kubectl kustomize.

  • static async cordon(ctx: ServiceContext, configure: Callable[[KubectlCordonSettings], KubectlCordonSettings] | None=None) -> ExecResult

    Mark a node unschedulable, or schedulable again: kubectl cordon/uncordon.

  • static async drain(ctx: ServiceContext, configure: Callable[[KubectlDrainSettings], KubectlDrainSettings] | None=None) -> ExecResult

    Evict a node's pods before maintenance: kubectl drain.

  • static async taint(ctx: ServiceContext, configure: Callable[[KubectlTaintSettings], KubectlTaintSettings] | None=None) -> ExecResult

    Add or remove node taints: kubectl taint.

#

KubectlTopSettings

class
class KubectlTopSettings(KubectlSettings)

Settings for kubectl top.

  • pods() -> Self

    Report pod usage (top pods).

  • nodes() -> Self

    Report node usage (top nodes).

  • name(value: str) -> Self

    Limit to a single named pod or node.

  • selector(query: str) -> Self

    Restrict to resources matching a label selector (-l).

  • containers() -> Self

    Break pod usage down by container (--containers).

  • all_namespaces() -> Self

    Report across all namespaces (-A).

#

KubectlVersionSettings

class
class KubectlVersionSettings(KubectlSettings)

Settings for kubectl version.

  • client_only() -> Self

    Report the client's version without reaching a cluster (--client).

  • output(format: Literal['json', 'yaml']) -> Self

    The output format (-o): json or yaml.

#

KubectlWaitSettings

class
class KubectlWaitSettings(KubectlSettings)

Settings for kubectl wait.

  • file(path: str) -> Self

    Wait on resources defined in a file (-f); repeatable.

  • resource(*tokens: str) -> Self

    Resource tokens, e.g. ("pod/web") or ("pods"); repeatable.

  • for_condition(condition: str) -> Self

    The condition to wait for, e.g. condition=Available or delete.

  • timeout(duration: str) -> Self

    How long to wait, e.g. 60s (--timeout).

  • selector(query: str) -> Self

    Restrict to resources matching a label selector (-l).

  • all() -> Self

    Wait on all resources of the given type (--all).