Kubernetes
Pods
Deployment
DevOps
Container Management

How to deploy in kubernetes without any changes, just to get pods to cycle

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

Sometimes the code and image have not changed, but you still need Kubernetes to replace the running pods. Common reasons include rotated secrets, stuck connections, memory growth, or simply forcing a clean process restart during maintenance. The safest way to do that is usually a controlled rollout, not manual pod deletion.

For a Deployment, the standard command is kubectl rollout restart. It tells the controller to start a new rollout while still respecting the strategy, readiness probes, and availability rules already defined for the workload.

Restart a Deployment the Kubernetes Way

For a Deployment named my-app in the prod namespace, the usual command is:

bash
kubectl rollout restart deployment/my-app -n prod
kubectl rollout status deployment/my-app -n prod

The first command triggers a new rollout. The second waits for Kubernetes to report that the rollout completed. This is better than treating the restart as successful the moment the first command returns.

You can also restart several Deployments by selector:

bash
kubectl rollout restart deployment -n prod -l app.kubernetes.io/part-of=checkout

That is useful when one logical service is spread across multiple Deployments and you want a coordinated refresh.

Why This Is Better Than Deleting Pods

A Deployment already knows how to replace its pods safely. If the rollout strategy says only one pod may be unavailable at a time, that rule still applies during a restart. If the readiness probe says a new pod is not ready yet, the controller waits before moving further.

Manual pod deletion does not communicate intent as clearly, and it is easier to create avoidable downtime. Compare these two patterns:

bash
1# Preferred for planned cycling
2kubectl rollout restart deployment/my-app -n prod
3
4# Rougher fallback
5kubectl delete pod -n prod -l app=my-app

Deleting pods can still work because the Deployment controller recreates them, but it is a cruder tool. For normal operations, use the rollout mechanism first.

Watch the Rollout Instead of Guessing

A restart is only useful if the replacement pods actually become healthy. Watch the pod set while the rollout happens:

bash
kubectl get pods -n prod -l app=my-app -w

When something looks wrong, inspect events and controller state:

bash
kubectl describe deployment my-app -n prod
kubectl get events -n prod --sort-by=.lastTimestamp

This helps you distinguish a routine restart from a real release-health problem. If pods are stuck in CrashLoopBackOff, the restart did not solve anything; it just exposed a deeper issue.

Know the Strategy Before Restarting Production

The safety of a restart depends on the rollout settings already attached to the workload. Before restarting an important service, inspect the Deployment:

bash
kubectl get deployment my-app -n prod -o yaml

Pay attention to these fields:

  • 'strategy.rollingUpdate.maxUnavailable'
  • 'strategy.rollingUpdate.maxSurge'
  • readiness probes
  • 'minReadySeconds'
  • any PodDisruptionBudget protecting the pods

If maxUnavailable is too high, a “simple restart” may remove more capacity than expected. If readiness is poorly defined, Kubernetes may route traffic to pods that only look alive but are not truly ready.

Restart Other Workload Controllers

The same pattern also applies to other controller-managed workloads.

bash
kubectl rollout restart statefulset/orders-db -n prod
kubectl rollout restart daemonset/log-agent -n infra

The controller semantics differ, but the operating principle is the same: let the controller replace pods according to its own rules. For StatefulSets, remember that ordered replacement can make the restart slower by design.

If you need an explicit marker in audit history, you can patch an annotation on the pod template:

bash
kubectl patch deployment my-app -n prod \
  -p '{"spec":{"template":{"metadata":{"annotations":{"restartedAt":"2026-03-11T12:00:00Z"}}}}}'

A pod-template change causes a new rollout and makes the restart reason visible in the manifest history.

Validate the Service After Pods Cycle

A finished rollout is not the same as a healthy application. After the pods are replaced, check what actually matters for the service:

bash
kubectl logs deployment/my-app -n prod --tail=100
kubectl get endpoints my-service -n prod

Then verify the external signals that your users care about, such as request success rate, latency, or background job throughput. Kubernetes only tells you that the controller reached the desired state, not that the business function is healthy.

Common Pitfalls

The most common mistake is deleting pods directly and assuming that is identical to a managed restart. It is often close, but it is not the cleanest or safest default.

Another mistake is restarting the wrong namespace or cluster because the current context was not checked first. Always confirm kubectl config current-context before touching production.

A third problem is assuming a completed rollout guarantees application health. A pod can become Ready and still fail under real traffic a few seconds later.

Summary

  • Use kubectl rollout restart as the default way to cycle pods without a functional config change.
  • Follow it with kubectl rollout status and live pod observation.
  • Let rollout strategy, readiness probes, and disruption controls do their job.
  • Use manual pod deletion only as a rough fallback, not the normal operating path.
  • Validate service-level health after the controller finishes replacing pods.

Course illustration
Course illustration

All Rights Reserved.