What happens if you run kubectl create on a resource that already exists in the cluster?
Think about whether kubectl create is designed to add new resources or modify existing ones.
kubectl create is used to add new resources. If the resource already exists, it will not update it but instead return an error.
What does kubectl apply do when the resource already exists in the cluster?
Consider how kubectl apply helps keep resources in sync with configuration files.
kubectl apply updates existing resources by applying the changes from the configuration file, allowing incremental updates.
What is the output when you run kubectl create -f pod.yaml if the pod already exists?
kubectl create -f pod.yamlRemember that kubectl create does not update existing resources.
When the resource exists, kubectl create returns an error indicating the resource already exists.
What is the output when you run kubectl apply -f deployment.yaml if the deployment already exists and is updated?
kubectl apply -f deployment.yamlThink about how kubectl apply reports changes.
kubectl apply reports configured when it updates an existing resource.
In a continuous deployment pipeline, which command is best to use to ensure the cluster matches the desired state defined in configuration files?
Consider which command helps keep resources in sync with config files automatically.
kubectl apply is preferred in CI/CD because it can create new resources or update existing ones, ensuring the cluster matches the desired state.