|
| 1 | +--- |
| 2 | +title: Kubernetes Self-Healing |
| 3 | +content_type: concept |
| 4 | +Weight: 50 |
| 5 | +--- |
| 6 | +<!-- overview --> |
| 7 | + |
| 8 | +Kubernetes is designed with self-healing capabilities that help maintain the health and availability of workloads. |
| 9 | +It automatically replaces failed containers, reschedules workloads when nodes become unavailable, and ensures that the desired state of the system is maintained. |
| 10 | + |
| 11 | +<!-- body --> |
| 12 | + |
| 13 | +## Self-Healing capabilities {#self-healing-capabilities} |
| 14 | + |
| 15 | +- **Container-level restarts:** If a container inside a Pod fails, Kubernetes restarts it based on the [`restartPolicy`](/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy)`. |
| 16 | + |
| 17 | +- **Replica replacement:** If a Pod in a [Deployment](/docs/concepts/workloads/controllers/deployment/) or [StatefulSet](/docs/concepts/workloads/controllers/statefulset/) fails, Kubernetes creates a replacement Pod to maintain the specified number of replicas. |
| 18 | + If a Pod fails that is part of a [DaemonSet](/docs/concepts/workloads/controllers/daemonset/) fails, the control plane |
| 19 | + creates a replacement Pod to run on the same node. |
| 20 | + |
| 21 | +- **Persistent storage recovery:** If a node is running a Pod with a PersistentVolume (PV) attached, and the node fails, Kubernetes can reattach the volume to a new Pod on a different node. |
| 22 | + |
| 23 | +- **Load balancing for Services:** If a Pod behind a [Service](/docs/concepts/services-networking/service/) fails, Kubernetes automatically removes it from the Service's endpoints to route traffic only to healthy Pods. |
| 24 | + |
| 25 | +Here are some of the key components that provide Kubernetes self-healing: |
| 26 | + |
| 27 | +- **[kubelet](/docs/concepts/architecture/#kubelet):** Ensures that containers are running, and restarts those that fail. |
| 28 | + |
| 29 | +- **ReplicaSet, StatefulSet and DaemonSet controller:** Maintains the desired number of Pod replicas. |
| 30 | + |
| 31 | +- **PersistentVolume controller:** Manages volume attachment and detachment for stateful workloads. |
| 32 | + |
| 33 | +## Considerations {#considerations} |
| 34 | + |
| 35 | +- **Storage Failures:** If a persistent volume becomes unavailable, recovery steps may be required. |
| 36 | + |
| 37 | +- **Application Errors:** Kubernetes can restart containers, but underlying application issues must be addressed separately. |
| 38 | + |
| 39 | +## {{% heading "whatsnext" %}} |
| 40 | + |
| 41 | +- Read more about [Pods](/docs/concepts/workloads/pods/) |
| 42 | +- Learn about [Kubernetes Controllers](/docs/concepts/architecture/controller/) |
| 43 | +- Explore [PersistentVolumes](/docs/concepts/storage/persistent-volumes/) |
| 44 | +- Read about [node autoscaling](/docs/concepts/cluster-administration/node-autoscaling/). Node autoscaling |
| 45 | + also provides automatic healing if or when nodes fail in your cluster. |
0 commit comments