How does a deployment in Kubernetes dynamically create and destroy pods using Rancher?

If you use a Deployment to run your app, that Deployment can create and destroy Pods dynamically

Deployment overview A deployment in Kubernetes manages the lifecycle of pods.
It dynamically creates and destroys pods to maintain the desired number of replicas, perform updates, and handle failures.
Rancher provides an interface for easy interaction with deployments through its UI and API.
Pod creation When a deployment is created in Rancher, it defines the number of replicas (pods) required.
The Kubernetes control plane ensures that the desired number of pods are running.
If there are fewer pods than specified, Kubernetes automatically creates new pods to meet the defined state.
Scaling Rancher integrates with Kubernetes' scaling features.
You can adjust the number of replicas manually through the Rancher interface or automatically based on resource metrics.
When scaling up, Kubernetes creates additional pods to match the new replica count.
When scaling down, Kubernetes dynamically destroys the excess pods.
Rolling updates Rancher simplifies managing rolling updates for applications deployed via deployments.
When a new version of an application is rolled out, the deployment gradually replaces old pods with new ones, ensuring minimal downtime.
Old pods are destroyed as new pods are created to maintain the desired state during the update process.
Self-healing Rancher leverages Kubernetes’ self-healing mechanisms.
If a pod crashes or becomes unhealthy, Kubernetes automatically destroys the failed pod and creates a new one, maintaining the desired number of replicas.
Pod destruction Pods are dynamically destroyed during scaling down, rolling updates, or if they become unhealthy.
The deployment controller ensures that the number of pods matches the desired state by removing excess or outdated pods.