Search in sources :

Example 1 with KubernetesTaskManagerParameters

use of org.apache.flink.kubernetes.kubeclient.parameters.KubernetesTaskManagerParameters in project flink by apache.

the class KubernetesResourceManagerDriver method requestResource.

@Override
public CompletableFuture<KubernetesWorkerNode> requestResource(TaskExecutorProcessSpec taskExecutorProcessSpec) {
    final KubernetesTaskManagerParameters parameters = createKubernetesTaskManagerParameters(taskExecutorProcessSpec);
    final KubernetesPod taskManagerPod = KubernetesTaskManagerFactory.buildTaskManagerKubernetesPod(taskManagerPodTemplate, parameters);
    final String podName = taskManagerPod.getName();
    final CompletableFuture<KubernetesWorkerNode> requestResourceFuture = new CompletableFuture<>();
    requestResourceFutures.put(podName, requestResourceFuture);
    log.info("Creating new TaskManager pod with name {} and resource <{},{}>.", podName, parameters.getTaskManagerMemoryMB(), parameters.getTaskManagerCPU());
    final CompletableFuture<Void> createPodFuture = flinkKubeClient.createTaskManagerPod(taskManagerPod);
    FutureUtils.assertNoException(createPodFuture.handleAsync((ignore, exception) -> {
        if (exception != null) {
            log.warn("Could not create pod {}, exception: {}", podName, exception);
            CompletableFuture<KubernetesWorkerNode> future = requestResourceFutures.remove(taskManagerPod.getName());
            if (future != null) {
                future.completeExceptionally(exception);
            }
        } else {
            log.info("Pod {} is created.", podName);
        }
        return null;
    }, getMainThreadExecutor()));
    return requestResourceFuture;
}
Also used : TaskExecutorProcessSpec(org.apache.flink.runtime.clusterframework.TaskExecutorProcessSpec) FlinkException(org.apache.flink.util.FlinkException) ResourceManagerUtils(org.apache.flink.runtime.util.ResourceManagerUtils) ExternalResourceUtils(org.apache.flink.runtime.externalresource.ExternalResourceUtils) ExceptionUtils(org.apache.flink.util.ExceptionUtils) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) KubernetesService(org.apache.flink.kubernetes.kubeclient.resources.KubernetesService) KubernetesWatch(org.apache.flink.kubernetes.kubeclient.resources.KubernetesWatch) KubernetesPod(org.apache.flink.kubernetes.kubeclient.resources.KubernetesPod) ArrayList(java.util.ArrayList) TaskManagerOptions(org.apache.flink.configuration.TaskManagerOptions) ProcessMemoryUtils(org.apache.flink.runtime.util.config.memory.ProcessMemoryUtils) FutureUtils(org.apache.flink.util.concurrent.FutureUtils) ResourceManagerException(org.apache.flink.runtime.resourcemanager.exceptions.ResourceManagerException) Map(java.util.Map) KubernetesTaskManagerParameters(org.apache.flink.kubernetes.kubeclient.parameters.KubernetesTaskManagerParameters) ContaineredTaskManagerParameters(org.apache.flink.runtime.clusterframework.ContaineredTaskManagerParameters) KubernetesResourceManagerDriverConfiguration(org.apache.flink.kubernetes.configuration.KubernetesResourceManagerDriverConfiguration) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) HighAvailabilityMode(org.apache.flink.runtime.jobmanager.HighAvailabilityMode) Nullable(javax.annotation.Nullable) BlobServerOptions(org.apache.flink.configuration.BlobServerOptions) KubernetesUtils(org.apache.flink.kubernetes.utils.KubernetesUtils) AbstractResourceManagerDriver(org.apache.flink.runtime.resourcemanager.active.AbstractResourceManagerDriver) KubernetesConfigOptions(org.apache.flink.kubernetes.configuration.KubernetesConfigOptions) ResourceManagerDriver(org.apache.flink.runtime.resourcemanager.active.ResourceManagerDriver) ApplicationStatus(org.apache.flink.runtime.clusterframework.ApplicationStatus) Configuration(org.apache.flink.configuration.Configuration) JobManagerOptions(org.apache.flink.configuration.JobManagerOptions) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) KubernetesTaskManagerFactory(org.apache.flink.kubernetes.kubeclient.factory.KubernetesTaskManagerFactory) Preconditions(org.apache.flink.util.Preconditions) BootstrapTools(org.apache.flink.runtime.clusterframework.BootstrapTools) File(java.io.File) List(java.util.List) GlobalConfiguration(org.apache.flink.configuration.GlobalConfiguration) KubernetesTooOldResourceVersionException(org.apache.flink.kubernetes.kubeclient.resources.KubernetesTooOldResourceVersionException) Optional(java.util.Optional) Constants(org.apache.flink.kubernetes.utils.Constants) FlinkKubeClient(org.apache.flink.kubernetes.kubeclient.FlinkKubeClient) CompletableFuture(java.util.concurrent.CompletableFuture) KubernetesTaskManagerParameters(org.apache.flink.kubernetes.kubeclient.parameters.KubernetesTaskManagerParameters) KubernetesPod(org.apache.flink.kubernetes.kubeclient.resources.KubernetesPod)

Example 2 with KubernetesTaskManagerParameters

use of org.apache.flink.kubernetes.kubeclient.parameters.KubernetesTaskManagerParameters in project flink by apache.

the class InitTaskManagerDecoratorWithPodTemplateTest method getResultPod.

@Override
public FlinkPod getResultPod(FlinkPod podTemplate) {
    final KubernetesTaskManagerParameters kubernetesTaskManagerParameters = KubernetesTestUtils.createTaskManagerParameters(flinkConfig, POD_NAME);
    final InitTaskManagerDecorator initTaskManagerDecorator = new InitTaskManagerDecorator(kubernetesTaskManagerParameters);
    return initTaskManagerDecorator.decorateFlinkPod(podTemplate);
}
Also used : KubernetesTaskManagerParameters(org.apache.flink.kubernetes.kubeclient.parameters.KubernetesTaskManagerParameters)

Example 3 with KubernetesTaskManagerParameters

use of org.apache.flink.kubernetes.kubeclient.parameters.KubernetesTaskManagerParameters in project flink by apache.

the class KubernetesTaskManagerTestBase method onSetup.

@Override
protected void onSetup() throws Exception {
    taskExecutorProcessSpec = TaskExecutorProcessUtils.processSpecFromConfig(flinkConfig);
    containeredTaskManagerParameters = ContaineredTaskManagerParameters.create(flinkConfig, taskExecutorProcessSpec);
    kubernetesTaskManagerParameters = new KubernetesTaskManagerParameters(flinkConfig, POD_NAME, DYNAMIC_PROPERTIES, JVM_MEM_OPTS_ENV, containeredTaskManagerParameters, ExternalResourceUtils.getExternalResourceConfigurationKeys(flinkConfig, KubernetesConfigOptions.EXTERNAL_RESOURCE_KUBERNETES_CONFIG_KEY_SUFFIX));
}
Also used : KubernetesTaskManagerParameters(org.apache.flink.kubernetes.kubeclient.parameters.KubernetesTaskManagerParameters)

Example 4 with KubernetesTaskManagerParameters

use of org.apache.flink.kubernetes.kubeclient.parameters.KubernetesTaskManagerParameters in project flink by apache.

the class KubernetesResourceManagerDriver method createKubernetesTaskManagerParameters.

private KubernetesTaskManagerParameters createKubernetesTaskManagerParameters(TaskExecutorProcessSpec taskExecutorProcessSpec) {
    final String podName = String.format(TASK_MANAGER_POD_FORMAT, clusterId, currentMaxAttemptId, ++currentMaxPodId);
    final ContaineredTaskManagerParameters taskManagerParameters = ContaineredTaskManagerParameters.create(flinkConfig, taskExecutorProcessSpec);
    final Configuration taskManagerConfig = new Configuration(flinkConfig);
    taskManagerConfig.set(TaskManagerOptions.TASK_MANAGER_RESOURCE_ID, podName);
    final String dynamicProperties = BootstrapTools.getDynamicPropertiesAsString(flinkClientConfig, taskManagerConfig);
    final String jvmMemOpts = ProcessMemoryUtils.generateJvmParametersStr(taskExecutorProcessSpec);
    return new KubernetesTaskManagerParameters(flinkConfig, podName, dynamicProperties, jvmMemOpts, taskManagerParameters, ExternalResourceUtils.getExternalResourceConfigurationKeys(flinkConfig, KubernetesConfigOptions.EXTERNAL_RESOURCE_KUBERNETES_CONFIG_KEY_SUFFIX));
}
Also used : KubernetesResourceManagerDriverConfiguration(org.apache.flink.kubernetes.configuration.KubernetesResourceManagerDriverConfiguration) Configuration(org.apache.flink.configuration.Configuration) GlobalConfiguration(org.apache.flink.configuration.GlobalConfiguration) ContaineredTaskManagerParameters(org.apache.flink.runtime.clusterframework.ContaineredTaskManagerParameters) KubernetesTaskManagerParameters(org.apache.flink.kubernetes.kubeclient.parameters.KubernetesTaskManagerParameters)

Aggregations

KubernetesTaskManagerParameters (org.apache.flink.kubernetes.kubeclient.parameters.KubernetesTaskManagerParameters)4 Configuration (org.apache.flink.configuration.Configuration)2 GlobalConfiguration (org.apache.flink.configuration.GlobalConfiguration)2 KubernetesResourceManagerDriverConfiguration (org.apache.flink.kubernetes.configuration.KubernetesResourceManagerDriverConfiguration)2 ContaineredTaskManagerParameters (org.apache.flink.runtime.clusterframework.ContaineredTaskManagerParameters)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Nullable (javax.annotation.Nullable)1 BlobServerOptions (org.apache.flink.configuration.BlobServerOptions)1 JobManagerOptions (org.apache.flink.configuration.JobManagerOptions)1 TaskManagerOptions (org.apache.flink.configuration.TaskManagerOptions)1 KubernetesConfigOptions (org.apache.flink.kubernetes.configuration.KubernetesConfigOptions)1 FlinkKubeClient (org.apache.flink.kubernetes.kubeclient.FlinkKubeClient)1 FlinkPod (org.apache.flink.kubernetes.kubeclient.FlinkPod)1 KubernetesTaskManagerFactory (org.apache.flink.kubernetes.kubeclient.factory.KubernetesTaskManagerFactory)1