zhisheng17/flink-learning · error · ClusterDeploymentException

Couldn't deploy Kubernetes Application Cluster. Expected dep

Error message

Couldn't deploy Kubernetes Application Cluster. Expected deployment.target=${application.getName()} but actual one was "${deploymentTarget}"

What it means

Thrown by deployApplicationCluster when deployment.target is not 'kubernetes-application'. Application mode deployment requires the target config to be exactly kubernetes-application; any other target (including kubernetes-session) is rejected before any resources are created.

Source

Thrown at flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/KubernetesClusterDescriptor.java:176

		}
		return clusterClientProvider;
	}

	@Override
	public ClusterClientProvider<String> deployApplicationCluster(
			final ClusterSpecification clusterSpecification,
			final ApplicationConfiguration applicationConfiguration) throws ClusterDeploymentException {
		//todo:k8s application mode
		if (client.getService(KubernetesService.ServiceType.REST_SERVICE, clusterId).isPresent()) {
			throw new ClusterDeploymentException("The Flink cluster " + clusterId + " already exists.");
		}

		checkNotNull(clusterSpecification);
		checkNotNull(applicationConfiguration);

		final KubernetesDeploymentTarget deploymentTarget = KubernetesDeploymentTarget.fromConfig(flinkConfig);
		if (KubernetesDeploymentTarget.APPLICATION != deploymentTarget) {
			throw new ClusterDeploymentException(
				"Couldn't deploy Kubernetes Application Cluster." +
					" Expected deployment.target=" + KubernetesDeploymentTarget.APPLICATION.getName() +
					" but actual one was \"" + deploymentTarget + "\"");
		}

		applicationConfiguration.applyToConfiguration(flinkConfig);

		// No need to do pipelineJars validation if it is a PyFlink job.
		if (!(PackagedProgramUtils.isPython(applicationConfiguration.getApplicationClassName()) ||
			PackagedProgramUtils.isPython(applicationConfiguration.getProgramArguments()))) {
			final List<File> pipelineJars = KubernetesUtils.checkJarFileForApplicationMode(flinkConfig);
			Preconditions.checkArgument(pipelineJars.size() == 1, "Should only have one jar");
		}

		//todo:deploy jm
		final ClusterClientProvider<String> clusterClientProvider = deployClusterInternal(
			KubernetesApplicationClusterEntrypoint.class.getName(),
			clusterSpecification,

View on GitHub (pinned to d731cee761)

Solutions

  1. Set the deployment target to application mode: flink run-application -t kubernetes-application ... or configuration.set(DeploymentOptions.TARGET, "kubernetes-application").
  2. Check the effective target in your flink-conf.yaml / command line for typos (e.g. 'kubernetes-app').
  3. Ensure your deployment code path matches the target: use deployApplicationCluster only for kubernetes-application.
  4. If a launcher sets the target programmatically, log the resolved DeploymentOptions.TARGET before deploying.

Example fix

// before
Configuration flinkConfig = new Configuration();
descriptor.deployApplicationCluster(spec, appConfig); // target unset
// after
flinkConfig.set(DeploymentOptions.TARGET, KubernetesDeploymentTarget.APPLICATION.getName());
descriptor.deployApplicationCluster(spec, appConfig);
Defensive patterns

Strategy: validation

Validate before calling

String target = flinkConfig.get(DeploymentOptions.TARGET);
if (!KubernetesDeploymentTarget.isValidKubernetesTarget(target) || !"kubernetes-application".equalsIgnoreCase(target)) {
    throw new IllegalArgumentException("deployment.target must be kubernetes-application, got: " + target);
}

Try / catch

try {
    descriptor.deployApplicationCluster(spec, appConfig);
} catch (ClusterDeploymentException e) {
    if (e.getMessage().contains("Expected deployment.target")) {
        flinkConfig.set(DeploymentOptions.TARGET, "kubernetes-application");
    }
}

Prevention

When it happens

Trigger: Calling deployApplicationCluster when flinkConfig's DeploymentOptions.TARGET resolves to a KubernetesDeploymentTarget other than APPLICATION (e.g. kubernetes-session, or any target not validated by fromConfig).

Common situations: Submitting with -t kubernetes-session but calling the application-mode deployment path; forgetting to set deployment.target at all; a generic launcher passing a stale target from the config file; copying a command line from a session-mode tutorial.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of zhisheng17/flink-learning@d731cee761 (2026-09-06). Data as JSON: /api/errors/2b1125d9f0a274c1. Report an issue: GitHub.