{"record":{"id":"2b1125d9f0a274c1","repo":"zhisheng17/flink-learning","slug":"couldn-t-deploy-kubernetes-application-cluster-ex","errorCode":null,"errorMessage":"Couldn't deploy Kubernetes Application Cluster. Expected deployment.target=${application.getName()} but actual one was \"${deploymentTarget}\"","messagePattern":"Couldn't deploy Kubernetes Application Cluster\\. Expected deployment\\.target=(.+?) but actual one was \"(.+?)\"","errorType":"exception","errorClass":"ClusterDeploymentException","httpStatus":null,"severity":"error","filePath":"flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/KubernetesClusterDescriptor.java","lineNumber":176,"sourceCode":"\t\t}\n\t\treturn clusterClientProvider;\n\t}\n\n\t@Override\n\tpublic ClusterClientProvider<String> deployApplicationCluster(\n\t\t\tfinal ClusterSpecification clusterSpecification,\n\t\t\tfinal ApplicationConfiguration applicationConfiguration) throws ClusterDeploymentException {\n\t\t//todo：k8s application mode\n\t\tif (client.getService(KubernetesService.ServiceType.REST_SERVICE, clusterId).isPresent()) {\n\t\t\tthrow new ClusterDeploymentException(\"The Flink cluster \" + clusterId + \" already exists.\");\n\t\t}\n\n\t\tcheckNotNull(clusterSpecification);\n\t\tcheckNotNull(applicationConfiguration);\n\n\t\tfinal KubernetesDeploymentTarget deploymentTarget = KubernetesDeploymentTarget.fromConfig(flinkConfig);\n\t\tif (KubernetesDeploymentTarget.APPLICATION != deploymentTarget) {\n\t\t\tthrow new ClusterDeploymentException(\n\t\t\t\t\"Couldn't deploy Kubernetes Application Cluster.\" +\n\t\t\t\t\t\" Expected deployment.target=\" + KubernetesDeploymentTarget.APPLICATION.getName() +\n\t\t\t\t\t\" but actual one was \\\"\" + deploymentTarget + \"\\\"\");\n\t\t}\n\n\t\tapplicationConfiguration.applyToConfiguration(flinkConfig);\n\n\t\t// No need to do pipelineJars validation if it is a PyFlink job.\n\t\tif (!(PackagedProgramUtils.isPython(applicationConfiguration.getApplicationClassName()) ||\n\t\t\tPackagedProgramUtils.isPython(applicationConfiguration.getProgramArguments()))) {\n\t\t\tfinal List<File> pipelineJars = KubernetesUtils.checkJarFileForApplicationMode(flinkConfig);\n\t\t\tPreconditions.checkArgument(pipelineJars.size() == 1, \"Should only have one jar\");\n\t\t}\n\n\t\t//todo：deploy jm\n\t\tfinal ClusterClientProvider<String> clusterClientProvider = deployClusterInternal(\n\t\t\tKubernetesApplicationClusterEntrypoint.class.getName(),\n\t\t\tclusterSpecification,","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/zhisheng17/flink-learning/blob/d731cee7618021be56d132cc925102ffff8d75e6/flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/KubernetesClusterDescriptor.java#L158-L194","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Set the deployment target to application mode: flink run-application -t kubernetes-application ... or configuration.set(DeploymentOptions.TARGET, \"kubernetes-application\").","Check the effective target in your flink-conf.yaml / command line for typos (e.g. 'kubernetes-app').","Ensure your deployment code path matches the target: use deployApplicationCluster only for kubernetes-application.","If a launcher sets the target programmatically, log the resolved DeploymentOptions.TARGET before deploying."],"exampleFix":"// before\nConfiguration flinkConfig = new Configuration();\ndescriptor.deployApplicationCluster(spec, appConfig); // target unset\n// after\nflinkConfig.set(DeploymentOptions.TARGET, KubernetesDeploymentTarget.APPLICATION.getName());\ndescriptor.deployApplicationCluster(spec, appConfig);","handlingStrategy":"validation","validationCode":"String target = flinkConfig.get(DeploymentOptions.TARGET);\nif (!KubernetesDeploymentTarget.isValidKubernetesTarget(target) || !\"kubernetes-application\".equalsIgnoreCase(target)) {\n    throw new IllegalArgumentException(\"deployment.target must be kubernetes-application, got: \" + target);\n}","typeGuard":null,"tryCatchPattern":"try {\n    descriptor.deployApplicationCluster(spec, appConfig);\n} catch (ClusterDeploymentException e) {\n    if (e.getMessage().contains(\"Expected deployment.target\")) {\n        flinkConfig.set(DeploymentOptions.TARGET, \"kubernetes-application\");\n    }\n}","preventionTips":["Always pass -t kubernetes-application for application mode","Validate target with isValidKubernetesTarget before deploy","Don't reuse session-mode configs for application deployment","Log resolved DeploymentOptions.TARGET in launchers"],"tags":["kubernetes","flink","deployment-target","config-mismatch"],"backgroundTag":"invalid-enum-value","analyzedSha":"d731cee7618021be56d132cc925102ffff8d75e6","analyzedAt":"2026-09-06T05:35:08.496Z","contentChangedAt":"2026-09-06T05:35:08.496Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}