kubectl apply
New
Syntax
kubectl apply -f <filename|url|directory> [flags]
Parameters
| Parameters | Description | Examples | Level |
|---|---|---|---|
-f --filename |
kubectl apply -f deployment.yaml |
Common | |
-k --kustomize |
Kustomize | kubectl apply -k overlays/production/ |
Advanced |
--dry-run=client |
, | kubectl apply -f pod.yaml --dry-run=client |
Common |
--dry-run=server |
, | kubectl apply -f pod.yaml --dry-run=server |
Advanced |
-R --recursive |
kubectl apply -f configs/ -R |
Common | |
--prune |
kubectl apply -f dir/ --prune -l app=web |
Examples
kubectl apply -f deployment.yaml
New Deployment
kubectl apply -f ./k8s/
YAML
URL
kubectl apply -f https://raw.githubusercontent.com/org/repo/main/deploy.yaml
kubectl apply -f deployment.yaml --dry-run=server -o yaml
,
Common Errors
error validating dataYAML, --dry-run=server
The Job is invalid: field is immutable,
Tips
- apply create, New
- --dry-run=server
- Git YAML GitOps