{"record":{"id":"534f4dc88b7fd8f2","repo":"zhisheng17/flink-learning","slug":"kubernetes-jobmanager-replicas-should-not-be-con","errorCode":null,"errorMessage":"'kubernetes.jobmanager.replicas' should not be configured less than one.","messagePattern":"'kubernetes\\.jobmanager\\.replicas' should not be configured less than one\\.","errorType":"validation","errorClass":"IllegalConfigurationException","httpStatus":null,"severity":"error","filePath":"flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/kubeclient/parameters/KubernetesJobManagerParameters.java","lineNumber":161,"sourceCode":"\t\tfinal String entrypointClass = flinkConfig.getString(KubernetesConfigOptionsInternal.ENTRY_POINT_CLASS);\n\t\tcheckNotNull(entrypointClass, KubernetesConfigOptionsInternal.ENTRY_POINT_CLASS + \" must be specified!\");\n\n\t\treturn entrypointClass;\n\t}\n\n\tpublic KubernetesConfigOptions.ServiceExposedType getRestServiceExposedType() {\n\t\treturn flinkConfig.get(KubernetesConfigOptions.REST_SERVICE_EXPOSED_TYPE);\n\t}\n\n\tpublic boolean isInternalServiceEnabled() {\n\t\treturn !HighAvailabilityMode.isHighAvailabilityModeActivated(flinkConfig);\n\t}\n\n\tpublic int getReplicas() {\n\t\tfinal int replicas =\n\t\t\tflinkConfig.get(KubernetesConfigOptions.KUBERNETES_JOBMANAGER_REPLICAS);\n\t\tif (replicas < 1) {\n\t\t\tthrow new IllegalConfigurationException(\n\t\t\t\tString.format(\n\t\t\t\t\t\"'%s' should not be configured less than one.\",\n\t\t\t\t\tKubernetesConfigOptions.KUBERNETES_JOBMANAGER_REPLICAS.key()));\n\t\t} else if (replicas > 1\n\t\t\t&& !HighAvailabilityMode.isHighAvailabilityModeActivated(flinkConfig)) {\n\t\t\tthrow new IllegalConfigurationException(\n\t\t\t\t\"High availability should be enabled when starting standby JobManagers.\");\n\t\t}\n\t\treturn replicas;\n\t}\n}\n","sourceCodeStart":143,"sourceCodeEnd":173,"githubUrl":"https://github.com/zhisheng17/flink-learning/blob/d731cee7618021be56d132cc925102ffff8d75e6/flink-learning-k8s/flink-k8s/src/main/java/org/apache/flink/kubernetes/kubeclient/parameters/KubernetesJobManagerParameters.java#L143-L173","documentation":"KubernetesJobManagerParameters.getReplicas validates kubernetes.jobmanager.replicas and throws IllegalConfigurationException when the configured value is less than 1. A JobManager deployment needs at least one replica; zero or negative values are meaningless for running a Flink cluster.","triggerScenarios":"Setting kubernetes.jobmanager.replicas to 0 or a negative number, then calling createJobManagerDeployment (e.g. via the standalone Kubernetes session/application bootstrap).","commonSituations":"Typo'd config values, scripts computing replicas via arithmetic that underflows, users attempting to \"scale to zero\" a session cluster by setting replicas to 0.","solutions":["Set kubernetes.jobmanager.replicas to 1 or higher (default is 1).","To scale down to zero, delete the cluster instead of setting replicas to 0.","Guard script-generated values: [ \"$REPLICAS\" -ge 1 ] || REPLICAS=1 before writing the config."],"exampleFix":"// before\nkubernetes.jobmanager.replicas: 0\n// after\nkubernetes.jobmanager.replicas: 1","handlingStrategy":"validation","validationCode":"Integer replicas = flinkConfig.get(KubernetesConfigOptions.KUBERNETES_JOBMANAGER_REPLICAS);\nif (replicas != null && replicas < 1) {\n    flinkConfig.set(KubernetesConfigOptions.KUBERNETES_JOBMANAGER_REPLICAS, 1);\n}","typeGuard":null,"tryCatchPattern":"try {\n    int replicas = jmParameters.getReplicas();\n} catch (IllegalConfigurationException e) {\n    LOG.error(\"Invalid jobmanager.replicas: {}\", e.getMessage());\n}","preventionTips":["Never configure kubernetes.jobmanager.replicas below 1; delete the cluster to scale to zero.","Clamp computed replica values to >= 1 in scripts.","Review flink-conf.yaml changes that touch replica counts."],"tags":["kubernetes","jobmanager","configuration"],"backgroundTag":"invalid-config-value","analyzedSha":"d731cee7618021be56d132cc925102ffff8d75e6","analyzedAt":"2026-09-06T05:35:08.496Z","contentChangedAt":"2026-09-06T05:35:08.496Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}