What is the difference between `kubectl apply` and `kubectl create`, and which do you use in pipelines?
BeginnerScenarioDeployments and rollouts
Answer
Situation read → A pipeline step failed with "AlreadyExists".
What I'd do →
- Use
kubectl apply -f(declarative) in pipelines - Use
createonly for imperative one-offs, which errors if the object exists - Use
kubectl diffbefore apply to preview - Prefer server-side apply with
--server-sidefor large objects such as CRDs
Why → apply stores the desired state and merges changes, so it is idempotent. create is a single imperative action.
Interview tip → Mention annotation size limits (262144 bytes) that break client-side apply on large CRDs.
More on Deployments and rollouts
You applied a new image tag and the rollout seems stuck at "1 out of 3 new replicas have been updated". What do you check first?BeginnerHow do you roll back a bad release and verify you are back on the previous version?BeginnerA rollout must never reduce capacity below current replicas. How do you configure the strategy?IntermediateYou need a blue/green deployment without a service mesh. How do you do it with plain Kubernetes?IntermediateHow would you do a canary release with only Deployments and a Service?IntermediateWhat is the difference between Recreate and RollingUpdate strategies and when would you pick Recreate?Beginner