kubectl apply vs create¶
In Kubernetes, resource management is commonly performed using two primary commands: kubectl apply and kubectl create.^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]
Key Differences¶
The functional distinction between the two lies in their handling of resource states:
kubectl create: This command is strictly used to create resources that do not currently exist.^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]kubectl apply: This command functions as an upsert operation. It can create resources if they are missing, but it also checks for configuration changes in existing resources and updates them accordingly.^[400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md]
Summary¶
While both commands can be used to instantiate a Kubernetes object from a configuration file (typically YAML), apply is generally preferred for managing changes throughout a resource's lifecycle, whereas create is intended for the initial instantiation of strictly new objects.
Sources¶
400-devops__06-Kubernetes__k8s-ithelp__Day6__README.md
Related¶
- Pod
- Kubernetes
- [[Declarative vs Imperative]]