public class KubernetesUtils extends Object
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 io.fabric8.kubernetes.api.model.Volume |
getConfigMapVolume(String clusterId,
boolean hasLogback,
boolean hasLog4j)
Get config map volume for job manager and task manager pod.
|
static List<io.fabric8.kubernetes.api.model.VolumeMount> |
getConfigMapVolumeMount(String flinkConfDirInPod,
boolean hasLogback,
boolean hasLog4j)
Get config map volume for job manager and task manager pod.
|
static String |
getContentFromFile(String filePath)
Read file content to string.
|
static String |
getJobManagerStartCommand(Configuration flinkConfig,
int jobManagerMemoryMb,
String configDirectory,
String logDirectory,
boolean hasLogback,
boolean hasLog4j,
String mainClass,
String mainArgs)
Generates the shell command to start a job manager for kubernetes.
|
static io.fabric8.kubernetes.api.model.ResourceRequirements |
getResourceRequirements(int mem,
double cpu)
Get resource requirements from memory and cpu.
|
static String |
getTaskManagerStartCommand(Configuration flinkConfig,
ContaineredTaskManagerParameters tmParams,
String configDirectory,
String logDirectory,
boolean hasLogback,
boolean hasLog4j,
String mainClass,
String mainArgs)
Generates the shell command to start a task manager for kubernetes.
|
static Integer |
parsePort(Configuration flinkConfig,
ConfigOption<String> port)
Parse a valid port for the config option.
|
public static String getContentFromFile(String filePath) throws FileNotFoundException
filePath
- file pathFileNotFoundException
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 getJobManagerStartCommand(Configuration flinkConfig, int jobManagerMemoryMb, String configDirectory, String logDirectory, boolean hasLogback, boolean hasLog4j, String mainClass, @Nullable String mainArgs)
flinkConfig
- The Flink configuration.jobManagerMemoryMb
- JobManager heap size.configDirectory
- The configuration directory for the flink-conf.yamllogDirectory
- The log directory.hasLogback
- Uses logback?hasLog4j
- Uses log4j?mainClass
- The main class to start with.mainArgs
- The args for main class.public static String getTaskManagerStartCommand(Configuration flinkConfig, ContaineredTaskManagerParameters tmParams, String configDirectory, String logDirectory, boolean hasLogback, boolean hasLog4j, String mainClass, @Nullable String mainArgs)
flinkConfig
- The Flink configuration.tmParams
- Parameters for the task manager.configDirectory
- The configuration directory for the flink-conf.yamllogDirectory
- The log directory.hasLogback
- Uses logback?hasLog4j
- Uses log4j?mainClass
- The main class to start with.mainArgs
- The args for main class.public static io.fabric8.kubernetes.api.model.Volume getConfigMapVolume(String clusterId, boolean hasLogback, boolean hasLog4j)
clusterId
- Cluster id.hasLogback
- Uses logback?hasLog4j
- Uses log4j?public static List<io.fabric8.kubernetes.api.model.VolumeMount> getConfigMapVolumeMount(String flinkConfDirInPod, boolean hasLogback, boolean hasLog4j)
flinkConfDirInPod
- Flink conf directory that will be mounted in the pod.hasLogback
- Uses logback?hasLog4j
- Uses log4j?public static io.fabric8.kubernetes.api.model.ResourceRequirements getResourceRequirements(int mem, double cpu)
mem
- Memory in mb.cpu
- cpu.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.