Skip to content

maxSurge parameter

maxSurge is a configuration option used within the Kubernetes Deployment strategy, specifically when the type is set to RollingUpdate^[400-devops-06-kubernetes-k8s-ithelp-day13-readme.md]. It defines the maximum number of Pods that can be created above the desired number of replicas during an update^[400-devops-06-kubernetes-k8s-ithelp-day13-readme.md].

Configuration

The parameter is set via the spec.strategy.rollingUpdate.maxSurge field^[400-devops-06-kubernetes-k8s-ithelp-day13-readme.md].

  • Purpose: It controls the rate at which new Pods are created and brought online during a rolling update^[400-devops-06-kubernetes-k8s-ithelp-day13-readme.md].
  • Behavior: When set, it allows the Deployment to temporarily exceed the configured replicas count to ensure stability while rolling out the new version^[400-devops-06-kubernetes-k8s-ithelp-day13-readme.md].

Example

In a Deployment manifest, maxSurge is often used in conjunction with maxUnavailable:

spec:
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0

In this configuration, the update process will create one new Pod at a time (surge of 1) before terminating an old one, ensuring there is always capacity to handle traffic^[400-devops-06-kubernetes-k8s-ithelp-day13-readme.md].

Sources

  • 400-devops-06-kubernetes-k8s-ithelp-day13-readme.md