Search in sources :

Example 1 with FlinkService

use of org.apache.flink.kubernetes.operator.service.FlinkService in project flink-kubernetes-operator by apache.

the class ObserverTest method observeSessionCluster.

@Test
public void observeSessionCluster() {
    FlinkService flinkService = new TestingFlinkService();
    Observer observer = new Observer(flinkService, FlinkOperatorConfiguration.fromConfiguration(new Configuration()));
    FlinkDeployment deployment = TestUtils.buildSessionCluster();
    deployment.getStatus().getReconciliationStatus().setLastReconciledSpec(deployment.getSpec());
    observer.observe(deployment, readyContext, FlinkUtils.getEffectiveConfig(deployment, new Configuration()));
    assertEquals(JobManagerDeploymentStatus.DEPLOYED_NOT_READY, deployment.getStatus().getJobManagerDeploymentStatus());
    observer.observe(deployment, readyContext, FlinkUtils.getEffectiveConfig(deployment, new Configuration()));
    assertEquals(JobManagerDeploymentStatus.READY, deployment.getStatus().getJobManagerDeploymentStatus());
}
Also used : FlinkDeployment(org.apache.flink.kubernetes.operator.crd.FlinkDeployment) Configuration(org.apache.flink.configuration.Configuration) FlinkOperatorConfiguration(org.apache.flink.kubernetes.operator.config.FlinkOperatorConfiguration) TestingFlinkService(org.apache.flink.kubernetes.operator.TestingFlinkService) TestingFlinkService(org.apache.flink.kubernetes.operator.TestingFlinkService) FlinkService(org.apache.flink.kubernetes.operator.service.FlinkService) Test(org.junit.jupiter.api.Test)

Example 2 with FlinkService

use of org.apache.flink.kubernetes.operator.service.FlinkService in project flink-kubernetes-operator by apache.

the class FlinkOperator method main.

public static void main(String... args) {
    LOG.info("Starting Flink Kubernetes Operator");
    DefaultConfig defaultConfig = FlinkUtils.loadDefaultConfig();
    OperatorMetricUtils.initOperatorMetrics(defaultConfig.getOperatorConfig());
    DefaultKubernetesClient client = new DefaultKubernetesClient();
    String namespace = client.getNamespace();
    if (namespace == null) {
        namespace = "default";
    }
    DefaultConfigurationService configurationService = DefaultConfigurationService.instance();
    Operator operator = new Operator(client, configurationService);
    FlinkService flinkService = new FlinkService(client);
    FlinkOperatorConfiguration operatorConfiguration = FlinkOperatorConfiguration.fromConfiguration(defaultConfig.getOperatorConfig());
    Observer observer = new Observer(flinkService, operatorConfiguration);
    FlinkDeploymentValidator validator = new DefaultDeploymentValidator();
    ReconcilerFactory factory = new ReconcilerFactory(client, flinkService, operatorConfiguration);
    FlinkDeploymentController controller = new FlinkDeploymentController(defaultConfig, operatorConfiguration, client, namespace, validator, observer, factory);
    FlinkControllerConfig controllerConfig = new FlinkControllerConfig(controller);
    controller.setControllerConfig(controllerConfig);
    controllerConfig.setConfigurationService(configurationService);
    operator.register(controller, controllerConfig);
    operator.installShutdownHook();
    operator.start();
}
Also used : Operator(io.javaoperatorsdk.operator.Operator) DefaultConfigurationService(io.javaoperatorsdk.operator.config.runtime.DefaultConfigurationService) FlinkDeploymentValidator(org.apache.flink.kubernetes.operator.validation.FlinkDeploymentValidator) FlinkDeploymentController(org.apache.flink.kubernetes.operator.controller.FlinkDeploymentController) ReconcilerFactory(org.apache.flink.kubernetes.operator.reconciler.ReconcilerFactory) DefaultDeploymentValidator(org.apache.flink.kubernetes.operator.validation.DefaultDeploymentValidator) DefaultConfig(org.apache.flink.kubernetes.operator.config.DefaultConfig) FlinkOperatorConfiguration(org.apache.flink.kubernetes.operator.config.FlinkOperatorConfiguration) Observer(org.apache.flink.kubernetes.operator.observer.Observer) FlinkControllerConfig(org.apache.flink.kubernetes.operator.controller.FlinkControllerConfig) FlinkService(org.apache.flink.kubernetes.operator.service.FlinkService) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Aggregations

FlinkOperatorConfiguration (org.apache.flink.kubernetes.operator.config.FlinkOperatorConfiguration)2 FlinkService (org.apache.flink.kubernetes.operator.service.FlinkService)2 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)1 Operator (io.javaoperatorsdk.operator.Operator)1 DefaultConfigurationService (io.javaoperatorsdk.operator.config.runtime.DefaultConfigurationService)1 Configuration (org.apache.flink.configuration.Configuration)1 TestingFlinkService (org.apache.flink.kubernetes.operator.TestingFlinkService)1 DefaultConfig (org.apache.flink.kubernetes.operator.config.DefaultConfig)1 FlinkControllerConfig (org.apache.flink.kubernetes.operator.controller.FlinkControllerConfig)1 FlinkDeploymentController (org.apache.flink.kubernetes.operator.controller.FlinkDeploymentController)1 FlinkDeployment (org.apache.flink.kubernetes.operator.crd.FlinkDeployment)1 Observer (org.apache.flink.kubernetes.operator.observer.Observer)1 ReconcilerFactory (org.apache.flink.kubernetes.operator.reconciler.ReconcilerFactory)1 DefaultDeploymentValidator (org.apache.flink.kubernetes.operator.validation.DefaultDeploymentValidator)1 FlinkDeploymentValidator (org.apache.flink.kubernetes.operator.validation.FlinkDeploymentValidator)1 Test (org.junit.jupiter.api.Test)1