Search in sources :

Example 1 with KubernetesJobManagerParameters

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

the class Fabric8FlinkKubeClientTest method onSetup.

@Override
protected void onSetup() throws Exception {
    super.onSetup();
    KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, CONFIG_FILE_LOGBACK_NAME);
    KubernetesTestUtils.createTemporyFile("some data", flinkConfDir, CONFIG_FILE_LOG4J_NAME);
    final ClusterSpecification clusterSpecification = new ClusterSpecification.ClusterSpecificationBuilder().setMasterMemoryMB(JOB_MANAGER_MEMORY).setTaskManagerMemoryMB(1000).setSlotsPerTaskManager(3).createClusterSpecification();
    final KubernetesJobManagerParameters kubernetesJobManagerParameters = new KubernetesJobManagerParameters(flinkConfig, clusterSpecification);
    this.kubernetesJobManagerSpecification = KubernetesJobManagerFactory.buildKubernetesJobManagerSpecification(new FlinkPod.Builder().build(), kubernetesJobManagerParameters);
}
Also used : ClusterSpecification(org.apache.flink.client.deployment.ClusterSpecification) KubernetesJobManagerParameters(org.apache.flink.kubernetes.kubeclient.parameters.KubernetesJobManagerParameters)

Example 2 with KubernetesJobManagerParameters

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

the class KubernetesJobManagerFactoryWithPodTemplateTest method getResultPod.

@Override
protected Pod getResultPod(FlinkPod podTemplate) throws Exception {
    final KubernetesJobManagerParameters kubernetesJobManagerParameters = new KubernetesJobManagerParameters(flinkConfig, new KubernetesClusterClientFactory().getClusterSpecification(flinkConfig));
    final KubernetesJobManagerSpecification kubernetesJobManagerSpecification = KubernetesJobManagerFactory.buildKubernetesJobManagerSpecification(podTemplate, kubernetesJobManagerParameters);
    final PodTemplateSpec podTemplateSpec = kubernetesJobManagerSpecification.getDeployment().getSpec().getTemplate();
    return new PodBuilder().withMetadata(podTemplateSpec.getMetadata()).withSpec(podTemplateSpec.getSpec()).build();
}
Also used : PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) KubernetesClusterClientFactory(org.apache.flink.kubernetes.KubernetesClusterClientFactory) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) KubernetesJobManagerSpecification(org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerSpecification) KubernetesJobManagerParameters(org.apache.flink.kubernetes.kubeclient.parameters.KubernetesJobManagerParameters)

Example 3 with KubernetesJobManagerParameters

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

the class InitJobManagerDecoratorWithPodTemplateTest method getResultPod.

@Override
public FlinkPod getResultPod(FlinkPod podTemplate) {
    final KubernetesJobManagerParameters kubernetesJobManagerParameters = new KubernetesJobManagerParameters(flinkConfig, new KubernetesClusterClientFactory().getClusterSpecification(flinkConfig));
    final InitJobManagerDecorator initJobManagerDecorator = new InitJobManagerDecorator(kubernetesJobManagerParameters);
    return initJobManagerDecorator.decorateFlinkPod(podTemplate);
}
Also used : KubernetesClusterClientFactory(org.apache.flink.kubernetes.KubernetesClusterClientFactory) KubernetesJobManagerParameters(org.apache.flink.kubernetes.kubeclient.parameters.KubernetesJobManagerParameters)

Example 4 with KubernetesJobManagerParameters

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

the class KubernetesJobManagerTestBase method onSetup.

@Override
protected void onSetup() throws Exception {
    final ClusterSpecification clusterSpecification = new ClusterSpecification.ClusterSpecificationBuilder().setMasterMemoryMB(JOB_MANAGER_MEMORY).setTaskManagerMemoryMB(1024).setSlotsPerTaskManager(3).createClusterSpecification();
    this.kubernetesJobManagerParameters = new KubernetesJobManagerParameters(flinkConfig, clusterSpecification);
}
Also used : ClusterSpecification(org.apache.flink.client.deployment.ClusterSpecification) KubernetesJobManagerParameters(org.apache.flink.kubernetes.kubeclient.parameters.KubernetesJobManagerParameters)

Example 5 with KubernetesJobManagerParameters

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

the class KubernetesClusterDescriptor method deployClusterInternal.

private ClusterClientProvider<String> deployClusterInternal(String entryPoint, ClusterSpecification clusterSpecification, boolean detached) throws ClusterDeploymentException {
    final ClusterEntrypoint.ExecutionMode executionMode = detached ? ClusterEntrypoint.ExecutionMode.DETACHED : ClusterEntrypoint.ExecutionMode.NORMAL;
    flinkConfig.setString(ClusterEntrypoint.INTERNAL_CLUSTER_EXECUTION_MODE, executionMode.toString());
    flinkConfig.setString(KubernetesConfigOptionsInternal.ENTRY_POINT_CLASS, entryPoint);
    // Rpc, blob, rest, taskManagerRpc ports need to be exposed, so update them to fixed values.
    KubernetesUtils.checkAndUpdatePortConfigOption(flinkConfig, BlobServerOptions.PORT, Constants.BLOB_SERVER_PORT);
    KubernetesUtils.checkAndUpdatePortConfigOption(flinkConfig, TaskManagerOptions.RPC_PORT, Constants.TASK_MANAGER_RPC_PORT);
    KubernetesUtils.checkAndUpdatePortConfigOption(flinkConfig, RestOptions.BIND_PORT, Constants.REST_PORT);
    if (HighAvailabilityMode.isHighAvailabilityModeActivated(flinkConfig)) {
        flinkConfig.setString(HighAvailabilityOptions.HA_CLUSTER_ID, clusterId);
        KubernetesUtils.checkAndUpdatePortConfigOption(flinkConfig, HighAvailabilityOptions.HA_JOB_MANAGER_PORT_RANGE, flinkConfig.get(JobManagerOptions.PORT));
    }
    try {
        final KubernetesJobManagerParameters kubernetesJobManagerParameters = new KubernetesJobManagerParameters(flinkConfig, clusterSpecification);
        final FlinkPod podTemplate = kubernetesJobManagerParameters.getPodTemplateFilePath().map(file -> KubernetesUtils.loadPodFromTemplateFile(client, file, Constants.MAIN_CONTAINER_NAME)).orElse(new FlinkPod.Builder().build());
        final KubernetesJobManagerSpecification kubernetesJobManagerSpec = KubernetesJobManagerFactory.buildKubernetesJobManagerSpecification(podTemplate, kubernetesJobManagerParameters);
        client.createJobManagerComponent(kubernetesJobManagerSpec);
        return createClusterClientProvider(clusterId);
    } catch (Exception e) {
        try {
            LOG.warn("Failed to create the Kubernetes cluster \"{}\", try to clean up the residual resources.", clusterId);
            client.stopAndCleanupCluster(clusterId);
        } catch (Exception e1) {
            LOG.info("Failed to stop and clean up the Kubernetes cluster \"{}\".", clusterId, e1);
        }
        throw new ClusterDeploymentException("Could not create Kubernetes cluster \"" + clusterId + "\".", e);
    }
}
Also used : FlinkException(org.apache.flink.util.FlinkException) ClusterSpecification(org.apache.flink.client.deployment.ClusterSpecification) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) LoggerFactory(org.slf4j.LoggerFactory) KubernetesConfigOptionsInternal(org.apache.flink.kubernetes.configuration.KubernetesConfigOptionsInternal) KubernetesService(org.apache.flink.kubernetes.kubeclient.resources.KubernetesService) RestClusterClient(org.apache.flink.client.program.rest.RestClusterClient) ApplicationConfiguration(org.apache.flink.client.deployment.application.ApplicationConfiguration) TaskManagerOptions(org.apache.flink.configuration.TaskManagerOptions) RestOptions(org.apache.flink.configuration.RestOptions) Endpoint(org.apache.flink.kubernetes.kubeclient.Endpoint) StandaloneClientHAServices(org.apache.flink.runtime.highavailability.nonha.standalone.StandaloneClientHAServices) Preconditions.checkNotNull(org.apache.flink.util.Preconditions.checkNotNull) ClusterRetrieveException(org.apache.flink.client.deployment.ClusterRetrieveException) KubernetesJobManagerParameters(org.apache.flink.kubernetes.kubeclient.parameters.KubernetesJobManagerParameters) HighAvailabilityMode(org.apache.flink.runtime.jobmanager.HighAvailabilityMode) KubernetesDeploymentTarget(org.apache.flink.kubernetes.configuration.KubernetesDeploymentTarget) PackagedProgramUtils(org.apache.flink.client.program.PackagedProgramUtils) BlobServerOptions(org.apache.flink.configuration.BlobServerOptions) KubernetesUtils(org.apache.flink.kubernetes.utils.KubernetesUtils) KubernetesConfigOptions(org.apache.flink.kubernetes.configuration.KubernetesConfigOptions) Logger(org.slf4j.Logger) Configuration(org.apache.flink.configuration.Configuration) KubernetesJobManagerSpecification(org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerSpecification) KubernetesApplicationClusterEntrypoint(org.apache.flink.kubernetes.entrypoint.KubernetesApplicationClusterEntrypoint) HighAvailabilityServicesUtils(org.apache.flink.runtime.highavailability.HighAvailabilityServicesUtils) JobManagerOptions(org.apache.flink.configuration.JobManagerOptions) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) Preconditions(org.apache.flink.util.Preconditions) KubernetesSessionClusterEntrypoint(org.apache.flink.kubernetes.entrypoint.KubernetesSessionClusterEntrypoint) File(java.io.File) ClusterDeploymentException(org.apache.flink.client.deployment.ClusterDeploymentException) List(java.util.List) ClusterDescriptor(org.apache.flink.client.deployment.ClusterDescriptor) ClusterClient(org.apache.flink.client.program.ClusterClient) KubernetesJobManagerFactory(org.apache.flink.kubernetes.kubeclient.factory.KubernetesJobManagerFactory) Optional(java.util.Optional) AddressResolution(org.apache.flink.runtime.rpc.AddressResolution) ClusterClientProvider(org.apache.flink.client.program.ClusterClientProvider) ClusterEntrypoint(org.apache.flink.runtime.entrypoint.ClusterEntrypoint) Constants(org.apache.flink.kubernetes.utils.Constants) HighAvailabilityOptions(org.apache.flink.configuration.HighAvailabilityOptions) FlinkKubeClient(org.apache.flink.kubernetes.kubeclient.FlinkKubeClient) ClusterDeploymentException(org.apache.flink.client.deployment.ClusterDeploymentException) FlinkPod(org.apache.flink.kubernetes.kubeclient.FlinkPod) KubernetesApplicationClusterEntrypoint(org.apache.flink.kubernetes.entrypoint.KubernetesApplicationClusterEntrypoint) KubernetesSessionClusterEntrypoint(org.apache.flink.kubernetes.entrypoint.KubernetesSessionClusterEntrypoint) ClusterEntrypoint(org.apache.flink.runtime.entrypoint.ClusterEntrypoint) KubernetesJobManagerSpecification(org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerSpecification) FlinkException(org.apache.flink.util.FlinkException) ClusterRetrieveException(org.apache.flink.client.deployment.ClusterRetrieveException) ClusterDeploymentException(org.apache.flink.client.deployment.ClusterDeploymentException) KubernetesJobManagerParameters(org.apache.flink.kubernetes.kubeclient.parameters.KubernetesJobManagerParameters)

Aggregations

KubernetesJobManagerParameters (org.apache.flink.kubernetes.kubeclient.parameters.KubernetesJobManagerParameters)5 ClusterSpecification (org.apache.flink.client.deployment.ClusterSpecification)3 KubernetesClusterClientFactory (org.apache.flink.kubernetes.KubernetesClusterClientFactory)2 KubernetesJobManagerSpecification (org.apache.flink.kubernetes.kubeclient.KubernetesJobManagerSpecification)2 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)1 PodTemplateSpec (io.fabric8.kubernetes.api.model.PodTemplateSpec)1 File (java.io.File)1 List (java.util.List)1 Optional (java.util.Optional)1 ClusterDeploymentException (org.apache.flink.client.deployment.ClusterDeploymentException)1 ClusterDescriptor (org.apache.flink.client.deployment.ClusterDescriptor)1 ClusterRetrieveException (org.apache.flink.client.deployment.ClusterRetrieveException)1 ApplicationConfiguration (org.apache.flink.client.deployment.application.ApplicationConfiguration)1 ClusterClient (org.apache.flink.client.program.ClusterClient)1 ClusterClientProvider (org.apache.flink.client.program.ClusterClientProvider)1 PackagedProgramUtils (org.apache.flink.client.program.PackagedProgramUtils)1 RestClusterClient (org.apache.flink.client.program.rest.RestClusterClient)1 BlobServerOptions (org.apache.flink.configuration.BlobServerOptions)1 Configuration (org.apache.flink.configuration.Configuration)1 HighAvailabilityOptions (org.apache.flink.configuration.HighAvailabilityOptions)1