All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.flink.kubernetes.configuration.KubernetesConfigOptions Maven / Gradle / Ivy

The newest version!
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.flink.kubernetes.configuration;

import org.apache.flink.annotation.PublicEvolving;
import org.apache.flink.configuration.ConfigOption;

import java.util.List;
import java.util.Map;

import static org.apache.flink.configuration.ConfigOptions.key;

/**
 * This class holds configuration constants used by Flink's kubernetes runners.
 */
@PublicEvolving
public class KubernetesConfigOptions {

	public static final ConfigOption CONTEXT =
		key("kubernetes.context")
		.stringType()
		.noDefaultValue()
		.withDescription("The desired context from your Kubernetes config file used to configure the Kubernetes client " +
			"for interacting with the cluster. This could be helpful if one has multiple contexts configured and " +
			"wants to administrate different Flink clusters on different Kubernetes clusters/contexts.");

	public static final ConfigOption REST_SERVICE_EXPOSED_TYPE =
		key("kubernetes.rest-service.exposed.type")
		.enumType(ServiceExposedType.class)
		.defaultValue(ServiceExposedType.LoadBalancer)
		.withDescription("The type of the rest service (ClusterIP or NodePort or LoadBalancer). " +
			"When set to ClusterIP, the rest service will not be created.");

	public static final ConfigOption JOB_MANAGER_SERVICE_ACCOUNT =
		key("kubernetes.jobmanager.service-account")
		.stringType()
		.defaultValue("default")
		.withDescription("Service account that is used by jobmanager within kubernetes cluster. " +
			"The job manager uses this service account when requesting taskmanager pods from the API server.");

	public static final ConfigOption JOB_MANAGER_CPU =
		key("kubernetes.jobmanager.cpu")
		.doubleType()
		.defaultValue(1.0)
		.withDescription("The number of cpu used by job manager");

	public static final ConfigOption TASK_MANAGER_CPU =
		key("kubernetes.taskmanager.cpu")
		.doubleType()
		.defaultValue(-1.0)
		.withDescription("The number of cpu used by task manager. By default, the cpu is set " +
			"to the number of slots per TaskManager");

	public static final ConfigOption CONTAINER_IMAGE_PULL_POLICY =
		key("kubernetes.container.image.pull-policy")
		.enumType(ImagePullPolicy.class)
		.defaultValue(ImagePullPolicy.IfNotPresent)
		.withDescription("The Kubernetes container image pull policy (IfNotPresent or Always or Never). " +
			"The default policy is IfNotPresent to avoid putting pressure to image repository.");

	public static final ConfigOption> CONTAINER_IMAGE_PULL_SECRETS =
		key("kubernetes.container.image.pull-secrets")
		.stringType()
		.asList()
		.noDefaultValue()
		.withDescription("A semicolon-separated list of the Kubernetes secrets used to access " +
			"private image registries.");

	public static final ConfigOption KUBE_CONFIG_FILE =
		key("kubernetes.config.file")
		.stringType()
		.noDefaultValue()
		.withDescription("The kubernetes config file will be used to create the client. The default " +
				"is located at ~/.kube/config");

	public static final ConfigOption NAMESPACE =
		key("kubernetes.namespace")
		.stringType()
		.defaultValue("default")
		.withDescription("The namespace that will be used for running the jobmanager and taskmanager pods.");

	public static final ConfigOption CONTAINER_START_COMMAND_TEMPLATE =
		key("kubernetes.container-start-command-template")
		.stringType()
		.defaultValue("%java% %classpath% %jvmmem% %jvmopts% %logging% %class% %args% %redirects%")
		.withDescription("Template for the kubernetes jobmanager and taskmanager container start invocation.");

	public static final ConfigOption SERVICE_CREATE_TIMEOUT =
		key("kubernetes.service.create-timeout")
		.stringType()
		.defaultValue("1 min")
		.withDescription("Timeout used for creating the service. The timeout value requires a time-unit " +
			"specifier (ms/s/min/h/d).");

  	// ---------------------------------------------------------------------------------
	// The following config options could be overridden by KubernetesCliOptions.
	// ---------------------------------------------------------------------------------

	public static final ConfigOption CLUSTER_ID =
		key("kubernetes.cluster-id")
		.stringType()
		.noDefaultValue()
		.withDescription("The cluster id used for identifying the unique flink cluster. If it's not set, " +
			"the client will generate a random UUID name.");

	public static final ConfigOption CONTAINER_IMAGE =
		key("kubernetes.container.image")
		.stringType()
		.defaultValue("flink:latest")
		.withDescription("Image to use for Flink containers.");

	/**
	 * The following config options need to be set according to the image.
	 */
	public static final ConfigOption KUBERNETES_ENTRY_PATH =
		key("kubernetes.entry.path")
		.stringType()
		.defaultValue("/opt/flink/bin/kubernetes-entry.sh")
		.withDescription("The entrypoint script of kubernetes in the image. It will be used as command for jobmanager " +
			"and taskmanager container.");

	public static final ConfigOption FLINK_CONF_DIR =
		key("kubernetes.flink.conf.dir")
		.stringType()
		.defaultValue("/opt/flink/conf")
		.withDescription("The flink conf directory that will be mounted in pod. The flink-conf.yaml, log4j.properties, " +
			"logback.xml in this path will be overwritten from config map.");

	public static final ConfigOption FLINK_LOG_DIR =
		key("kubernetes.flink.log.dir")
		.stringType()
		.defaultValue("/opt/flink/log")
		.withDescription("The directory that logs of jobmanager and taskmanager be saved in the pod.");

	public static final ConfigOption HADOOP_CONF_CONFIG_MAP =
		key("kubernetes.hadoop.conf.config-map.name")
		.stringType()
		.noDefaultValue()
		.withDescription("Specify the name of an existing ConfigMap that contains custom Hadoop configuration " +
			"to be mounted on the JobManager(s) and TaskManagers.");

	public static final ConfigOption> JOB_MANAGER_ANNOTATIONS =
		key("kubernetes.jobmanager.annotations")
		.mapType()
		.noDefaultValue()
		.withDescription("The user-specified annotations that are set to the JobManager pod. The value could be " +
			"in the form of a1:v1,a2:v2");

	public static final ConfigOption> TASK_MANAGER_ANNOTATIONS =
		key("kubernetes.taskmanager.annotations")
		.mapType()
		.noDefaultValue()
		.withDescription("The user-specified annotations that are set to the TaskManager pod. The value could be " +
			"in the form of a1:v1,a2:v2");

	public static final ConfigOption> REST_SERVICE_ANNOTATIONS =
		key("kubernetes.rest-service.annotations")
			.mapType()
			.noDefaultValue()
			.withDescription("The user-specified annotations that are set to the rest Service. The value could be " +
				"in the form of a1:v1,a2:v2");

	public static final ConfigOption> JOB_MANAGER_NODE_SELECTOR =
		key("kubernetes.jobmanager.node-selector")
			.mapType()
			.noDefaultValue()
			.withDescription("The user-specified node-selector that are set to the JobManager pod. The value could be " +
				"in the form of a1:v1,a2:v2");

	public static final ConfigOption> TASK_MANAGER_NODE_SELECTOR =
		key("kubernetes.taskmanager.node-selector")
			.mapType()
			.noDefaultValue()
			.withDescription("The user-specified node-selector that are set to the TaskManager pods. The value could be " +
				"in the form of a1:v1,a2:v2");

	public static final ConfigOption> JOB_MANAGER_LABELS =
		key("kubernetes.jobmanager.labels")
			.mapType()
			.noDefaultValue()
			.withDescription("The user-specified labels that are set to the JobManager replica controller, service and pod. " +
				"The value could be in the form of a1:v1,a2:v2");

	public static final ConfigOption> TASK_MANAGER_LABELS =
		key("kubernetes.taskmanager.labels")
			.mapType()
			.noDefaultValue()
			.withDescription("The user-specified labels that are set to the TaskManager pods. The value could be " +
				"in the form of a1:v1,a2:v2");

	public static final ConfigOption JARS_DOWNLOAD_DIR =
		key("kubernetes.init-container.jars-download-dir")
		.stringType()
		.defaultValue("/var/flink-data/flink-jars")
		.withDescription("Location to download remote jars into in the JobManagers and TaskManagers pods.\n" +
			"This directory must be empty and will be mounted as an empty directory volume on the JobManager and TaskManager pods.");

	public static final ConfigOption FILES_DOWNLOAD_DIR =
		key("kubernetes.init-container.files-download-dir")
		.stringType()
		.defaultValue("/var/flink-data/flink-files")
			.withDescription("Location to download remote files into in the JobManagers and TaskManagers pods.\n" +
				"This directory must be empty and will be mounted as an empty directory volume on the JobManager and TaskManager pods.");

	/**
	 * The flink rest service exposed type.
	 */
	public enum ServiceExposedType {
		ClusterIP,
		NodePort,
		LoadBalancer
	}

	/**
	 * The container image pull policy.
	 */
	public enum ImagePullPolicy {
		IfNotPresent,
		Always,
		Never
	}

	/** This class is not meant to be instantiated. */
	private KubernetesConfigOptions() {}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy