kubernetes/kubernetes · error
unexpected deployment strategy type: %s
Error message
unexpected deployment strategy type: %s
What it means
From syncDeployment (deployment_controller.go:659). After handling Recreate and RollingUpdate, the switch on spec.strategy.type falls through to the default, meaning the type is neither of the two supported values. The API server should reject any other type at admission, so reaching this line implies a corrupt, hand-crafted, or bypass-admission Deployment object.
Source
Thrown at pkg/controller/deployment/deployment_controller.go:659
return err
}
if scalingEvent {
return dc.sync(ctx, d, rsList)
}
switch d.Spec.Strategy.Type {
case apps.RecreateDeploymentStrategyType:
// List all Pods owned by this Deployment, grouped by their ReplicaSet, to
// check that no old Pods are running in the middle of a Recreate rollout.
podMap, err := dc.getPodMapForDeployment(d, rsList)
if err != nil {
return err
}
return dc.rolloutRecreate(ctx, d, rsList, podMap)
case apps.RollingUpdateDeploymentStrategyType:
return dc.rolloutRolling(ctx, d, rsList)
}
return fmt.Errorf("unexpected deployment strategy type: %s", d.Spec.Strategy.Type)
}
View on GitHub (pinned to b882c60b40)
Solutions
- kubectl get deploy <ns>/<name> -o yaml and check spec.strategy.type.
- Set it to RollingUpdate (default) or Recreate and re-apply.
- Ensure all writes go through the API server so the strategy enum is validated at admission.
Example fix
// before
spec:
strategy:
type: "Rolling" # typo, not a valid value
// after
spec:
strategy:
type: RollingUpdate Defensive patterns
Strategy: validation
Validate before calling
func validStrategyType(t apps.DeploymentStrategyType) bool {
return t == apps.RecreateDeploymentStrategyType || t == apps.RollingUpdateDeploymentStrategyType
} Try / catch
switch d.Spec.Strategy.Type {
case apps.RecreateDeploymentStrategyType, apps.RollingUpdateDeploymentStrategyType:
// handle
default:
dc.eventRecorder.Eventf(d, v1.EventTypeWarning, "InvalidStrategy", string(d.Spec.Strategy.Type))
return reconcile.Result{RequeueAfter: 30 * time.Second}, nil
} Prevention
- Rely on API admission to enforce the strategy-type enum; never write Deployments directly to etcd.
- If forking to add a strategy type, update both syncDeployment and NewRSNewReplicas.
When it happens
Trigger: A Deployment whose spec.strategy.type is something other than Recreate/RollingUpdate (e.g. empty string, a typo, or a custom value). Possible if the object was written directly to etcd or by a buggy controller that set an invalid enum.
Common situations: Direct etcd writes; a CR/operator that constructed a Deployment struct with an unset/typo strategy type; version skew where a new strategy type was read by an older controller that doesn't know it.
Related errors
- deployment type %v isn't supported
- deployment %s/%s has invalid label selector: %v
- cannot use --certificate-key without --print-join-command
- empty manifest path
- unable to add a new control plane instance to a cluster that
AI-assisted analysis of kubernetes/kubernetes@b882c60b40 (2026-08-07).
Data as JSON: /api/errors/84a0883bd36864ce.
Report an issue: GitHub.