public class KubernetesUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
KubernetesUtils.ClusterComponent
Cluster components.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
checkAndUpdatePortConfigOption(org.apache.flink.configuration.Configuration flinkConfig,
org.apache.flink.configuration.ConfigOption<String> port,
int fallbackPort)
Check whether the port config option is a fixed port.
|
static KubernetesConfigMap |
checkConfigMaps(List<KubernetesConfigMap> configMaps,
String expectedConfigMapName)
Check the ConfigMap list should only contain the expected one.
|
static List<File> |
checkJarFileForApplicationMode(org.apache.flink.configuration.Configuration configuration) |
static org.apache.flink.runtime.checkpoint.CompletedCheckpointStore |
createCompletedCheckpointStore(org.apache.flink.configuration.Configuration configuration,
FlinkKubeClient kubeClient,
Executor executor,
String configMapName,
String lockIdentity,
int maxNumberOfCheckpointsToRetain)
Create a
DefaultCompletedCheckpointStore with KubernetesStateHandleStore. |
static KubernetesStateHandleStore<org.apache.flink.runtime.jobgraph.JobGraph> |
createJobGraphStateHandleStore(org.apache.flink.configuration.Configuration configuration,
FlinkKubeClient flinkKubeClient,
String configMapName,
String lockIdentity)
Create a
KubernetesStateHandleStore which storing JobGraph. |
static org.apache.flink.runtime.jobmanager.JobGraphStore |
createJobGraphStore(org.apache.flink.configuration.Configuration configuration,
FlinkKubeClient flinkKubeClient,
String configMapName,
String lockIdentity)
Create a
DefaultJobGraphStore with NoOpJobGraphStoreWatcher. |
static Map<String,String> |
getCommonLabels(String clusterId)
Get the common labels for Flink native clusters.
|
static Map<String,String> |
getConfigMapLabels(String clusterId,
String type)
Get ConfigMap labels for the current Flink cluster.
|
static String |
getDeploymentName(String clusterId)
Generate name of the Deployment.
|
static org.apache.flink.runtime.leaderelection.LeaderInformation |
getLeaderInformationFromConfigMap(KubernetesConfigMap configMap)
Get the
LeaderInformation from ConfigMap. |
static io.fabric8.kubernetes.api.model.ResourceRequirements |
getResourceRequirements(io.fabric8.kubernetes.api.model.ResourceRequirements resourceRequirements,
int mem,
double cpu,
Map<String,org.apache.flink.api.common.resources.ExternalResource> externalResources,
Map<String,String> externalResourceConfigKeys)
Get resource requirements from memory and cpu.
|
static String |
getServiceAccount(FlinkPod flinkPod)
Get the service account from the input pod first, if not specified, the service account name
will be used.
|
static List<String> |
getStartCommandWithBashWrapper(String command) |
static Map<String,String> |
getTaskManagerLabels(String clusterId)
Get task manager labels for the current Flink cluster.
|
static File |
getTaskManagerPodTemplateFileInPod() |
static FlinkPod |
loadPodFromTemplateFile(FlinkKubeClient kubeClient,
File podTemplateFile,
String mainContainerName) |
static Integer |
parsePort(org.apache.flink.configuration.Configuration flinkConfig,
org.apache.flink.configuration.ConfigOption<String> port)
Parse a valid port for the config option.
|
static <T> String |
resolveUserDefinedValue(org.apache.flink.configuration.Configuration flinkConfig,
org.apache.flink.configuration.ConfigOption<T> configOption,
String valueOfConfigOptionOrDefault,
String valueOfPodTemplate,
String fieldDescription)
Resolve the user defined value with the precedence.
|
static String |
tryToGetPrettyPrintYaml(io.fabric8.kubernetes.api.model.KubernetesResource kubernetesResource)
Try to get the pretty print yaml for Kubernetes resource.
|
public static void checkAndUpdatePortConfigOption(org.apache.flink.configuration.Configuration flinkConfig,
org.apache.flink.configuration.ConfigOption<String> port,
int fallbackPort)
flinkConfig - flink configurationport - config option need to be checkedfallbackPort - the fallback port that will be set to the configurationpublic static Integer parsePort(org.apache.flink.configuration.Configuration flinkConfig, org.apache.flink.configuration.ConfigOption<String> port)
flinkConfig - flink configport - port config optionpublic static String getDeploymentName(String clusterId)
public static Map<String,String> getTaskManagerLabels(String clusterId)
public static Map<String,String> getCommonLabels(String clusterId)
clusterId - cluster idpublic static Map<String,String> getConfigMapLabels(String clusterId, String type)
clusterId - cluster idtype - the config map use case. It could only be Constants.LABEL_CONFIGMAP_TYPE_HIGH_AVAILABILITY now.public static KubernetesConfigMap checkConfigMaps(List<KubernetesConfigMap> configMaps, String expectedConfigMapName)
configMaps - ConfigMap list to checkexpectedConfigMapName - expected ConfigMap Namepublic static org.apache.flink.runtime.leaderelection.LeaderInformation getLeaderInformationFromConfigMap(KubernetesConfigMap configMap)
LeaderInformation from ConfigMap.configMap - ConfigMap contains the leader informationLeaderInformation.empty() if there is
no corresponding data in the ConfigMap.public static org.apache.flink.runtime.jobmanager.JobGraphStore createJobGraphStore(org.apache.flink.configuration.Configuration configuration,
FlinkKubeClient flinkKubeClient,
String configMapName,
String lockIdentity)
throws Exception
DefaultJobGraphStore with NoOpJobGraphStoreWatcher.configuration - configuration to build a RetrievableStateStorageHelperflinkKubeClient - flink kubernetes clientconfigMapName - ConfigMap namelockIdentity - lock identity to check the leadershipDefaultJobGraphStore with NoOpJobGraphStoreWatcherException - when create the storage helperpublic static KubernetesStateHandleStore<org.apache.flink.runtime.jobgraph.JobGraph> createJobGraphStateHandleStore(org.apache.flink.configuration.Configuration configuration, FlinkKubeClient flinkKubeClient, String configMapName, String lockIdentity) throws Exception
KubernetesStateHandleStore which storing JobGraph.configuration - configuration to build a RetrievableStateStorageHelperflinkKubeClient - flink kubernetes clientconfigMapName - ConfigMap namelockIdentity - lock identity to check the leadershipKubernetesStateHandleStore which storing JobGraph.Exception - when create the storage helperpublic static org.apache.flink.runtime.checkpoint.CompletedCheckpointStore createCompletedCheckpointStore(org.apache.flink.configuration.Configuration configuration,
FlinkKubeClient kubeClient,
Executor executor,
String configMapName,
String lockIdentity,
int maxNumberOfCheckpointsToRetain)
throws Exception
DefaultCompletedCheckpointStore with KubernetesStateHandleStore.configuration - configuration to build a RetrievableStateStorageHelperkubeClient - flink kubernetes clientconfigMapName - ConfigMap nameexecutor - executor to run blocking callslockIdentity - lock identity to check the leadershipmaxNumberOfCheckpointsToRetain - max number of checkpoints to retain on state store
handleDefaultCompletedCheckpointStore with KubernetesStateHandleStore.Exception - when create the storage helper failedpublic static io.fabric8.kubernetes.api.model.ResourceRequirements getResourceRequirements(io.fabric8.kubernetes.api.model.ResourceRequirements resourceRequirements,
int mem,
double cpu,
Map<String,org.apache.flink.api.common.resources.ExternalResource> externalResources,
Map<String,String> externalResourceConfigKeys)
resourceRequirements - resource requirements in pod templatemem - Memory in mb.cpu - cpu.externalResources - external resourcesexternalResourceConfigKeys - config keys of external resourcespublic static List<String> getStartCommandWithBashWrapper(String command)
public static List<File> checkJarFileForApplicationMode(org.apache.flink.configuration.Configuration configuration)
public static FlinkPod loadPodFromTemplateFile(FlinkKubeClient kubeClient, File podTemplateFile, String mainContainerName)
public static File getTaskManagerPodTemplateFileInPod()
public static <T> String resolveUserDefinedValue(org.apache.flink.configuration.Configuration flinkConfig, org.apache.flink.configuration.ConfigOption<T> configOption, String valueOfConfigOptionOrDefault, @Nullable String valueOfPodTemplate, String fieldDescription)
T - The type of value associated with the configuration option.flinkConfig - flink configurationconfigOption - the config option to define the Kubernetes fieldsvalueOfConfigOptionOrDefault - the value defined by explicit config option or defaultvalueOfPodTemplate - the value defined in the pod templatefieldDescription - Kubernetes fields description@Nullable public static String getServiceAccount(FlinkPod flinkPod)
flinkPod - the Flink pod to parse the service accountpublic static String tryToGetPrettyPrintYaml(io.fabric8.kubernetes.api.model.KubernetesResource kubernetesResource)
kubernetesResource - kubernetes resourceKubernetesResource#toString() if parse failed.Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.