quarkusio/quarkus · error · IllegalStateException

Knative was requested as a deployment, but the target cluste

Error message

Knative was requested as a deployment, but the target cluster is not a Knative cluster!

What it means

KnativeDeployer.checkEnvironment verifies that, when the Knative deployment target was selected, the target cluster actually exposes the knative.dev API group. If the cluster is plain Kubernetes without Knative (Serving) installed, it throws IllegalStateException instead of producing a KubernetesDeploymentClusterBuildItem.

Source

Thrown at extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KnativeDeployer.java:31

import io.quarkus.kubernetes.spi.KubernetesDeploymentClusterBuildItem;

public class KnativeDeployer {

    @BuildStep
    public void checkEnvironment(Optional<SelectedKubernetesDeploymentTargetBuildItem> selectedDeploymentTarget,
            List<GeneratedKubernetesResourceBuildItem> resources,
            KubernetesClientBuildItem kubernetesClientBuilder,
            BuildProducer<KubernetesDeploymentClusterBuildItem> deploymentCluster) {
        selectedDeploymentTarget.ifPresent(target -> {
            if (!KubernetesDeploy.INSTANCE.checkSilently(kubernetesClientBuilder)) {
                return;
            }
            if (target.getEntry().getName().equals(KNATIVE)) {
                try (KnativeClient client = kubernetesClientBuilder.buildClient().adapt(KnativeClient.class)) {
                    if (client.hasApiGroup("knative.dev", false)) {
                        deploymentCluster.produce(new KubernetesDeploymentClusterBuildItem(KNATIVE));
                    } else {
                        throw new IllegalStateException(
                                "Knative was requested as a deployment, but the target cluster is not a Knative cluster!");
                    }
                }
            }
        });
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Install Knative Serving on the target cluster (kn quickstart or the official Knative install)
  2. Switch to the correct kube context that points to a Knative cluster (kubectl config use-context ...) before building/deploying
  3. If you don't want Knative, deploy with the plain kubernetes target instead (quarkus.kubernetes.deploy=true)

Example fix

// before
quarkus.knative.deploy=true  # against plain k8s
// after
kubectl apply -f knative-serving.yaml  # or use quarkus.kubernetes.deploy=true
Defensive patterns

Strategy: validation

Validate before calling

kubectl api-versions | grep knative.dev || echo "Knative NOT installed on current context"
kubectl config current-context

Try / catch

try { deployKnative(); } catch (IllegalStateException e) {
    if (e.getMessage().contains("not a Knative cluster")) {
        LOG.error("Target cluster lacks knative.dev API group — install Knative Serving or switch context");
    }
    throw e;
}

Prevention

When it happens

Trigger: Building with quarkus.knativive.deploy=true (Knative target selected) while the cluster reachable via the current kubeconfig lacks the knative.dev API group, as probed by KnativeClient.hasApiGroup("knative.dev", false).

Common situations: Pointed kubectl context at a plain Kubernetes/minikube/Kind cluster without Knative Serving installed; wrong kubeconfig context selected; Knative CRDs not installed yet.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/38249adb45cba6c5. Report an issue: GitHub.