Skip to content

kubectl create vs kubectl apply

kubectl create and kubectl apply are both commands used to manage Kubernetes resources, but they differ in their approach to object creation and updates^[400-devops__06-Kubernetes__k8s-ithelp__Day18__README.md].

Core Differences

The fundamental distinction lies in how the commands interpret the resource definition:

  • kubectl create: This command explicitly instructs Kubernetes to build a new resource object.^[400-devops__06-Kubernetes__k8s-ithelp__Day18__README.md]
  • kubectl apply: This command is typically used with YAML configuration files to define what the object should look like (declarative state).^[400-devops__06-Kubernetes__k8s-ithelp__Day18__README.md]

Usage Patterns

While both commands can result in a running resource, kubectl create is often used for imperative actions (such as creating a resource directly from a command-line flag or file), whereas kubectl apply is the standard for applying configuration files stored in source control^[400-devops__06-Kubernetes__k8s-ithelp__Day18__README.md].

For example, you might use kubectl create configmap to quickly import a file, but use kubectl apply -f when deploying a manifest that includes a ConfigMap definition^[400-devops__06-Kubernetes__k8s-ithelp__Day18__README.md].

Sources

^[400-devops__06-Kubernetes__k8s-ithelp__Day18__README.md]