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(Configuration flinkConfig,
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(Configuration configuration) |
static CompletedCheckpointStore |
createCompletedCheckpointStore(Configuration configuration,
FlinkKubeClient kubeClient,
Executor executor,
String configMapName,
String lockIdentity,
int maxNumberOfCheckpointsToRetain)
Create a
DefaultCompletedCheckpointStore with KubernetesStateHandleStore . |
static KubernetesStateHandleStore<JobGraph> |
createJobGraphStateHandleStore(Configuration configuration,
FlinkKubeClient flinkKubeClient,
String configMapName,
String lockIdentity)
Create a
KubernetesStateHandleStore which storing JobGraph . |
static JobGraphStore |
createJobGraphStore(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 String |
getCommonStartCommand(Configuration flinkConfig,
KubernetesUtils.ClusterComponent mode,
String jvmMemOpts,
String configDirectory,
String logDirectory,
boolean hasLogback,
boolean hasLog4j,
String mainClass,
String mainArgs) |
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 LeaderInformation |
getLeaderInformationFromConfigMap(KubernetesConfigMap configMap)
Get the
LeaderInformation from ConfigMap. |
static io.fabric8.kubernetes.api.model.ResourceRequirements |
getResourceRequirements(int mem,
double cpu,
Map<String,Long> externalResources)
Get resource requirements from memory and cpu.
|
static Map<String,String> |
getTaskManagerLabels(String clusterId)
Get task manager labels for the current Flink cluster.
|
static Integer |
parsePort(Configuration flinkConfig,
ConfigOption<String> port)
Parse a valid port for the config option.
|
static String |
tryToGetPrettyPrintYaml(io.fabric8.kubernetes.api.model.KubernetesResource kubernetesResource)
Try to get the pretty print yaml for Kubernetes resource.
|
public static void checkAndUpdatePortConfigOption(Configuration flinkConfig, 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(Configuration flinkConfig, 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 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 JobGraphStore createJobGraphStore(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 NoOpJobGraphStoreWatcher
Exception
- when create the storage helperpublic static KubernetesStateHandleStore<JobGraph> createJobGraphStateHandleStore(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 CompletedCheckpointStore createCompletedCheckpointStore(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(int mem, double cpu, Map<String,Long> externalResources)
mem
- Memory in mb.cpu
- cpu.externalResources
- external resourcespublic static String getCommonStartCommand(Configuration flinkConfig, KubernetesUtils.ClusterComponent mode, String jvmMemOpts, String configDirectory, String logDirectory, boolean hasLogback, boolean hasLog4j, String mainClass, @Nullable String mainArgs)
public static List<File> checkJarFileForApplicationMode(Configuration configuration)
public 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.