LinuxCommandLibrary

kubectl-apply

TLDR

Apply manifest

$ kubectl apply -f [manifest.yaml]
copy
Apply directory
$ kubectl apply -f [manifests/]
copy
Apply from URL
$ kubectl apply -f [https://example.com/manifest.yaml]
copy
Apply with kustomization
$ kubectl apply -k [directory/]
copy
Dry run
$ kubectl apply -f [manifest.yaml] --dry-run=client
copy
Server-side apply
$ kubectl apply -f [manifest.yaml] --server-side
copy

SYNOPSIS

kubectl apply [options] -f filename

DESCRIPTION

kubectl apply creates or updates Kubernetes resources. It uses declarative configuration to manage resources.
The command compares desired state with current state. It's the recommended way to manage Kubernetes resources.
kubectl apply manages resources declaratively.

PARAMETERS

-f FILE

File, directory, or URL.
-k DIR
Kustomization directory.
--dry-run MODE
client, server, or none.
--server-side
Server-side apply.
--force-conflicts
Force apply on conflicts.
-n NAMESPACE
Target namespace.
--help
Display help information.

CAVEATS

Subcommand of kubectl. Last-applied annotation used. Prefer over create for management.

HISTORY

kubectl apply implements declarative resource management for Kubernetes, enabling GitOps workflows.

SEE ALSO

Copied to clipboard