quarkusio/quarkus · error · IllegalStateException
A previous Deployment with a conflicting label %s=%s was fou
Error message
A previous Deployment with a conflicting label %s=%s was found in the label selector (current is %s=%s). As the label selector is immutable, you need to either align versions or manually delete previous deployment.
What it means
The Kubernetes deployer compares the version label (app.kubernetes.io/version or the configured VERSION_LABEL) in the label selector of an existing Deployment with the version requested by the current build. Kubernetes label selectors are immutable, so a mismatch means the new Deployment cannot replace the old one. Quarkus fails fast with this error instead of letting the Kubernetes API reject the apply.
Source
Thrown at extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesDeployer.java:419
Boolean.TRUE) == null;
}
private static void checkLabelSelectorVersions(DeploymentTargetEntry deploymnetTarget, HasMetadata resource,
Optional<HasMetadata> existing) {
if (existing.isEmpty()) {
return;
}
if (resource instanceof Deployment deployment) {
Optional<String> version = getLabelSelectorVersion(deployment);
final var hasMetadata = existing.get();
Optional<String> existingVersion = Optional.empty();
if (hasMetadata instanceof Deployment existingDeployment) {
existingVersion = getLabelSelectorVersion(existingDeployment);
}
if (version.isPresent() && existingVersion.isPresent()) {
if (!version.get().equals(existingVersion.get())) {
throw new IllegalStateException(String.format(
"A previous Deployment with a conflicting label %s=%s was found in the label selector (current is %s=%s). As the label selector is immutable, you need to either align versions or manually delete previous deployment.",
VERSION_LABEL, existingVersion.get(), VERSION_LABEL, version.get()));
}
} else if (version.isPresent()) {
throw new IllegalStateException(String.format(
"A Deployment with a conflicting label %s=%s was in the label selector was requested (previous had no such label). As the label selector is immutable, you need to either manually delete previous deployment, or remove the label (consider using quarkus.%s.add-version-to-label-selectors=false).",
VERSION_LABEL, version.get(), deploymnetTarget.getName().toLowerCase()));
} else if (existingVersion.isPresent()) {
throw new IllegalStateException(String.format(
"A Deployment with no label in the label selector was requested (previous includes %s=%s). As the label selector is immutable, you need to either manually delete previous deployment, or ensure the %s label is present (consider using quarkus.%s.add-version-to-label-selectors=true).",
VERSION_LABEL, existingVersion.get(), VERSION_LABEL, deploymnetTarget.getName().toLowerCase()));
}
}
}
private static Optional<String> getLabelSelectorVersion(Deployment deployment) {
final var spec = deployment.getSpec();
if (spec != null) {View on GitHub (pinned to e1c734241f)
Solutions
- Align the version: redeploy with the same version label as the existing Deployment (restore the previous quarkus.kubernetes.version / project version).
- Delete the previous Deployment from the cluster (kubectl delete deployment <name> -n <namespace>) and deploy again.
- Set quarkus.kubernetes.add-version-to-label-selectors=false so the version label is excluded from the label selector.
Example fix
// before (application.properties) quarkus.kubernetes.version=1.0.1 // conflicts with deployed 1.0.0 selector // after quarkus.kubernetes.add-version-to-label-selectors=false quarkus.kubernetes.version=1.0.1
Defensive patterns
Strategy: validation
Validate before calling
// Before deploying, check the version label of the existing Deployment
Deployment existing = client.apps().deployments().inNamespace(ns).withName(name).get();
String deployedVersion = existing != null
? existing.getMetadata().getLabels().get("app.kubernetes.io/version") : null;
if (deployedVersion != null && !deployedVersion.equals(expectedVersion)) {
throw new IllegalStateException("Version label mismatch: deployed=" + deployedVersion
+ " requested=" + expectedVersion + " — delete the Deployment or align versions");
} Try / catch
try {
deployer.deploy(...);
} catch (IllegalStateException e) {
if (e.getMessage().contains("conflicting label") && e.getMessage().contains("label selector is immutable")) {
client.apps().deployments().inNamespace(ns).withName(name).delete();
deployer.deploy(...); // retry once after cleanup
} else { throw e; }
} Prevention
- Keep the application version stable across CI/CD runs or always delete before re-deploying in ephemeral environments.
- Standardize quarkus.kubernetes.add-version-to-label-selectors across all environments from day one.
- Use distinct namespaces per version/branch in dev/CI to avoid stale Deployments.
When it happens
Trigger: quarkus.kubernetes.deploy=true with a previously applied Deployment whose label selector contains a different value for the version label than the version computed for the new build (e.g. project version changed, or quarkus.kubernetes.version was changed).
Common situations: Developers bump the project version or change quarkus.kubernetes.version after having already deployed once; CI deploying with a different version than what was originally applied; toggling quarkus.<target>.add-version-to-label-selectors between builds.
Related errors
- A Deployment with a conflicting label %s=%s was in the label
- A Deployment with no label in the label selector was request
- Openshift was requested as a deployment, but the target clus
- Cannot find ClassLoadingRecorder.class on classpath
- Couldn't fetch '' class from index
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/655c3998ffedffc9.
Report an issue: GitHub.