fix: fix pod eviction issue in the Kubernetes service
What
- Set
maxUnavailableinstead ofminAvailablein the PodDisruptionBudget, add amax_unavailablefield for it in the service schema. - Remove unneeded and harmful
replicasfrom the Deployment manifest.
Why
With minAvailable: 1, pods from single-replica deployments can never be evicted. This results in node pool updates and version upgrades taking too long or even aborting. Setting maxUnavailable is preferable. This does mean single-replica services will be offline while their single pod is evicted and restarted, and minReplicas should be set to at least 2 to avoid this.
Setting replicas in the Deployment manifest is unnecessary when a HPA is also configured, and actually harmful because this results in each apply resetting the number of replicas to the minimum (until the HPA brings it back to the desired count 2 seconds later).