10 Ways to Implement Self-Healing in DevOps Systems
10 ways to build self-healing DevOps systems: probes, PDBs, autoscaling, automated rollback, GitOps self-heal, systemd, runbook automation, chaos tests.
Self-healing in DevOps means a system detects a failure and returns itself to a healthy state without a human stepping in. You build it from layers: health probes and controllers that restart or replace failed components, autoscaling, automated rollback, GitOps drift correction, process supervisors, alert-driven runbooks and resilient service-to-service calls, then you prove it works with chaos experiments.
This guide covers ten practical ways to implement self-healing, with configuration for Kubernetes, Argo CD, Argo Rollouts, Prometheus, systemd, AWS and Istio. Each example was checked against the project's official documentation in November 2026. If you want the metrics side first, our post on how self-healing systems reduce MTTR explains the impact on recovery time.
Key takeaways
- Self-healing is a loop: detect, decide, act, verify. Every technique below is one version of that loop at a different layer.
- Kubernetes already heals at the pod level through controllers and probes. Most gains come from configuring probes, resources and disruption budgets correctly.
- Automated rollback during canary or blue-green releases stops a bad version before it reaches every user.
- GitOps self-heal reverts manual drift; process supervisors and cloud health checks cover VMs and non-Kubernetes services.
- Automation that restarts things blindly can hide real faults or cause restart storms. Add limits, backoff and alerts on repeated healing.
- Test self-healing deliberately with chaos engineering, or you will find out during an incident whether it works.
The ten techniques at a glance
| # | Technique | Layer | Failure it handles | Example tools |
|---|---|---|---|---|
| 1 | Controllers and desired replicas | Kubernetes workload | Crashed pods, lost nodes | Deployment, StatefulSet, PodDisruptionBudget |
| 2 | Liveness, readiness and startup probes | Container | Hung processes, not-ready instances | Kubernetes probes |
| 3 | Autoscaling | Pod and node | Load spikes, capacity loss | HPA, Cluster Autoscaler, Karpenter |
| 4 | Automated rollback on bad releases | Delivery | Faulty new versions | Argo Rollouts, Flagger, CodeDeploy |
| 5 | GitOps drift correction | Configuration | Manual changes, deleted resources | Argo CD, Flux |
| 6 | Instance replacement and recovery | VM and cloud | Failed instances, hardware faults | EC2 Auto Scaling, Azure VMSS, GCP MIGs |
| 7 | Process supervision | OS | Crashed daemons | systemd |
| 8 | Alert-driven runbook automation | Operations | Known failure patterns (full disk, stuck queue) | Prometheus Alertmanager, AWS Systems Manager Automation |
| 9 | Resilient service calls | Network and application | Failing dependencies, slow endpoints | Istio, Linkerd, retry and circuit breaker libraries |
| 10 | Chaos engineering | Verification | Untested assumptions about healing | Chaos Mesh, LitmusChaos, AWS FIS |
1. Let controllers maintain desired state
Kubernetes controllers compare what you declared with what is running and fix differences. If a pod in a Deployment crashes or its node disappears, the ReplicaSet creates a replacement elsewhere. That is the base layer of self-healing, and it only works well if you give it room:
- Run at least two replicas of anything user-facing.
- Spread replicas across nodes and zones with
topologySpreadConstraintsor pod anti-affinity. - Set a PodDisruptionBudget so voluntary disruptions, such as node drains during upgrades, never take out too many replicas at once.
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: web-pdb
spec:
minAvailable: 2
selector:
matchLabels:
app: web
---
# in the Deployment pod template spec
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app: web
A PodDisruptionBudget protects against voluntary disruptions only. It cannot stop a node from failing, which is why replicas and spreading matter too.
2. Configure liveness, readiness and startup probes
Probes tell Kubernetes when to restart a container and when to send it traffic.
- Liveness probe: if it fails repeatedly, the kubelet restarts the container. Use it for deadlocks and hung processes.
- Readiness probe: if it fails, the pod is removed from Service endpoints until it passes again. Nothing is restarted.
- Startup probe: holds off the other probes until a slow-starting app is up, so it is not killed during boot.
containers:
- name: web
image: example/web:2.3.1
startupProbe:
httpGet:
path: /healthz
port: 8080
failureThreshold: 30
periodSeconds: 5 # up to 150 s to start
livenessProbe:
httpGet:
path: /healthz
port: 8080
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /ready
port: 8080
periodSeconds: 5
Keep the liveness check shallow: it should answer "is this process alive?", not "are the database and every downstream API up?". A liveness probe that checks dependencies can restart every pod at once when a shared database blips, turning a small problem into an outage. Put dependency checks in readiness instead. Our post on liveness and readiness probes covers more patterns.
3. Scale automatically before load becomes failure
Many incidents are capacity problems. Autoscaling heals them by adding resources as demand rises.
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: web
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: web
minReplicas: 3
maxReplicas: 20
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
The Horizontal Pod Autoscaler needs CPU or memory requests on the containers to calculate utilisation, and the metrics server (or another metrics API provider) installed. Pair it with node autoscaling, such as the Kubernetes Cluster Autoscaler or Karpenter, so new pods have somewhere to run. KEDA extends this to event sources like queue length, which suits workers better than CPU.
4. Roll back bad releases automatically
Deployments cause a large share of incidents, so the release process itself should heal. Progressive delivery controllers move traffic to a new version in steps and check metrics at each step. If the metrics fail, they abort and return traffic to the stable version.
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: success-rate
spec:
args:
- name: service-name
metrics:
- name: success-rate
interval: 1m
failureLimit: 2
successCondition: result[0] >= 0.99
provider:
prometheus:
address: http://prometheus.monitoring.svc:9090
query: |
sum(rate(http_requests_total{service="{{args.service-name}}",code!~"5.."}[2m]))
/
sum(rate(http_requests_total{service="{{args.service-name}}"}[2m]))
---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: web
spec:
replicas: 5
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: example/web:2.4.0
strategy:
canary:
steps:
- setWeight: 20
- analysis:
templates:
- templateName: success-rate
args:
- name: service-name
value: web
- setWeight: 50
- pause: { duration: 5m }
According to the Argo Rollouts documentation, a failed analysis aborts the rollout and sets the canary weight back to zero. Flagger offers similar behaviour, and AWS CodeDeploy can roll back automatically when a CloudWatch alarm fires during a deployment. For when this matters most, see who benefits from automated rollbacks and post-deployment validation steps.
5. Correct configuration drift with GitOps
Someone scales a Deployment by hand during an incident, deletes a ConfigMap by mistake or edits a resource in the console. GitOps agents notice that live state no longer matches Git and put it back.
spec:
syncPolicy:
automated:
prune: true
selfHeal: true
With selfHeal: true, Argo CD re-syncs an application when the cluster drifts from Git. Flux does the same on each Kustomization reconciliation interval. Agree on a rule for incidents: either make emergency changes through Git, or pause automated sync first, otherwise the agent will undo your fix. The push and pull trade-offs are explained in push-based vs pull-based deployment models.
6. Replace or recover failed instances
Outside Kubernetes, cloud instance groups do the same job as ReplicaSets.
- Amazon EC2 Auto Scaling replaces instances that fail EC2 status checks, and can use Elastic Load Balancing health checks so that an instance whose application stops responding is also replaced.
- EC2 automatic recovery moves a supported instance to new hardware when an underlying host problem causes a system status check failure, keeping its instance ID and IP addresses.
- Azure Virtual Machine Scale Sets offer automatic instance repairs based on an application health extension or load balancer probe.
- Google Cloud managed instance groups support autohealing with a health check that recreates unhealthy VMs.
# Use load balancer health checks for replacement decisions
aws autoscaling update-auto-scaling-group \
--auto-scaling-group-name web-asg \
--health-check-type ELB \
--health-check-grace-period 300
Set a grace period long enough for the instance to boot and pass its first health check, or the group will keep terminating instances that were still starting.
7. Supervise processes with systemd
On a single Linux host, systemd can restart a crashed service and stop retrying if it keeps failing.
[Unit]
Description=Order worker
After=network-online.target
Wants=network-online.target
StartLimitIntervalSec=300
StartLimitBurst=5
[Service]
ExecStart=/opt/orders/bin/worker
Restart=on-failure
RestartSec=10
User=orders
[Install]
WantedBy=multi-user.target
Restart=on-failure restarts the service after a non-zero exit, a crash signal or a timeout. The start limit settings stop it after five failed starts in five minutes, so a broken release does not loop forever. Alert when a unit enters the failed state; node_exporter's systemd collector can expose unit states to Prometheus.
8. Automate runbooks for known failures
Some failures repeat with a known fix: a disk filling with old logs, a stuck consumer that needs a restart, an expired cache. Turn the runbook into code and trigger it from an alert.
# Prometheus alerting rule
groups:
- name: node
rules:
- alert: NodeDiskAlmostFull
expr: |
(node_filesystem_avail_bytes{mountpoint="/var/log"}
/ node_filesystem_size_bytes{mountpoint="/var/log"}) < 0.10
for: 10m
labels:
severity: warning
remediation: log-cleanup
annotations:
summary: "Less than 10% free on /var/log on {{ $labels.instance }}"
---
# Alertmanager route that sends this alert to an automation webhook
route:
receiver: oncall
routes:
- matchers:
- remediation="log-cleanup"
receiver: auto-remediation
continue: true
receivers:
- name: oncall
# paging integration here
- name: auto-remediation
webhook_configs:
- url: http://remediator.ops.svc:8080/hooks/log-cleanup
The webhook receiver can run an Ansible job, a Kubernetes Job or a cloud automation such as an AWS Systems Manager Automation runbook. The continue: true line means the on-call receiver still gets the alert. Keep a human in the loop for anything destructive, log every automated action, and alert if the same remediation runs repeatedly, because that usually means the root cause needs fixing. Our observability tools guide covers the monitoring side.
9. Make service-to-service calls resilient
In microservices, a slow or failing dependency can drag down every caller. Timeouts, retries with backoff and circuit breaking contain the damage. A service mesh can apply them without code changes.
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: payments
spec:
host: payments.shop.svc.cluster.local
trafficPolicy:
connectionPool:
http:
http1MaxPendingRequests: 100
outlierDetection:
consecutive5xxErrors: 5
interval: 30s
baseEjectionTime: 60s
maxEjectionPercent: 50
---
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
name: payments
spec:
hosts:
- payments.shop.svc.cluster.local
http:
- route:
- destination:
host: payments.shop.svc.cluster.local
timeout: 5s
retries:
attempts: 2
perTryTimeout: 2s
retryOn: 5xx,connect-failure,reset
Outlier detection ejects an endpoint that returns five consecutive 5xx errors, and brings it back after the ejection time. Only retry idempotent operations, and keep retry counts low, or retries will multiply load on a struggling service. Without a mesh, libraries such as Resilience4j (Java) or Polly (.NET) provide the same patterns in code.
10. Prove it with chaos engineering
Self-healing that has never been tested is a guess. Chaos experiments inject failures on purpose and check that the system recovers within your objectives.
apiVersion: chaos-mesh.org/v1alpha1
kind: PodChaos
metadata:
name: kill-one-web-pod
namespace: shop
spec:
action: pod-kill
mode: one
selector:
namespaces:
- shop
labelSelectors:
app: web
Start in staging with small, reversible experiments: kill one pod, drain a node, add latency to one dependency. Measure whether error rates stay within your SLO and how long recovery takes. Then widen the scope. Chaos Mesh and LitmusChaos are CNCF projects for Kubernetes; AWS Fault Injection Service, Azure Chaos Studio and Gremlin cover cloud resources more broadly. Read how chaos engineering improves resilience for a step-by-step approach.
Guardrails: when self-healing makes things worse
- Restart loops hide bugs. A pod in
CrashLoopBackOffthat restarts quietly for days is not healed. Alert on restart counts and repeated remediations. - Synchronised restarts. Deep liveness checks or aggressive thresholds can restart every replica together.
- Retry storms. Retries at several layers multiply. Budget them end to end.
- Scaling cost. Set a sensible
maxReplicasand node limits so a traffic spike or bug does not scale spend without bound. - Fighting humans. GitOps self-heal and on-call engineers must agree on how emergency changes happen.
- No record. Every automated action should leave a log entry and, for significant ones, an event in your incident or chat tool.
What to measure
Track whether self-healing is working with a few numbers: container restart counts per workload, automated rollbacks per month, the number of automated remediations by type, time from detection to recovery, and how often a human still had to step in. A rising remediation count for one alert is a signal to fix the underlying cause rather than celebrate the automation.
A rollout plan
- Define SLOs for key services so you know what "healthy" means.
- Fix the basics: replicas, resource requests, probes, PodDisruptionBudgets.
- Add autoscaling at pod and node level.
- Add progressive delivery with metric-based rollback for the riskiest services.
- Turn on GitOps drift correction once teams deploy through Git.
- Automate the top three repetitive runbooks from your incident history.
- Run chaos experiments quarterly, and after major architecture changes.
SLOs and error budgets come from site reliability engineering; see the role of SREs in DevOps teams.
Learn to build self-healing platforms
Probes, PodDisruptionBudgets, autoscaling and troubleshooting failed workloads are core topics in our CKA training. For the alerting and dashboards that drive automated remediation, see our Prometheus and Grafana training. Both run in Kharadi, Pune and live online.
FAQ
What is a self-healing system in DevOps?
A system that detects failures and restores a healthy state automatically, for example by restarting a crashed container, replacing a failed instance, rolling back a bad release or reverting a manual configuration change.
Is Kubernetes self-healing by default?
Partly. Controllers replace failed pods and reschedule them when nodes fail. Restarting hung containers and routing around unready pods depends on the liveness and readiness probes you configure.
What is the difference between liveness and readiness probes?
A failed liveness probe makes the kubelet restart the container. A failed readiness probe removes the pod from Service endpoints without restarting it, until it passes again.
How does automated rollback work?
A progressive delivery tool shifts a share of traffic to the new version and checks metrics such as error rate. If the checks fail, it aborts and sends traffic back to the stable version without human action.
Does GitOps provide self-healing?
Yes, for configuration. Argo CD with selfHeal: true, or Flux on each reconciliation, reverts live resources that drift from the state stored in Git.
Can self-healing replace on-call engineers?
No. It handles known, repeatable failures and buys time. New failure modes, data problems and decisions with business impact still need people, and repeated automated fixes need a root-cause investigation.
How do I test self-healing?
Use chaos engineering. Kill pods, drain nodes or inject latency in a controlled way with tools such as Chaos Mesh, LitmusChaos or AWS Fault Injection Service, and measure recovery against your SLOs.
Where should a beginner start?
Run multiple replicas, add correct liveness and readiness probes, set resource requests, and configure a Horizontal Pod Autoscaler. These cover the most common failures with little risk.
References
- Configure liveness, readiness and startup probes (kubernetes.io)
- Disruptions and PodDisruptionBudgets (kubernetes.io)
- Horizontal Pod Autoscaling (kubernetes.io)
- Argo Rollouts analysis and progressive delivery
- Argo CD automated sync and self-heal
- Health checks for instances in an Auto Scaling group (AWS)
- systemd.service manual
- Alertmanager configuration (Prometheus)
- Istio DestinationRule reference
- Simulate pod faults (Chaos Mesh)
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0