Search in sources :

Example 1 with KubernetesService

use of org.apache.flink.kubernetes.kubeclient.resources.KubernetesService in project flink by apache.

the class Fabric8FlinkKubeClient method getService.

@Override
public Optional<KubernetesService> getService(KubernetesService.ServiceType serviceType, String clusterId) {
    final String serviceName = getServiceName(serviceType, clusterId);
    final Service service = this.internalClient.services().withName(serviceName).fromServer().get();
    if (service == null) {
        LOG.debug("Service {} does not exist", serviceName);
        return Optional.empty();
    }
    return Optional.of(new KubernetesService(service));
}
Also used : KubernetesService(org.apache.flink.kubernetes.kubeclient.resources.KubernetesService) Service(io.fabric8.kubernetes.api.model.Service) ExecutorService(java.util.concurrent.ExecutorService) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) KubernetesService(org.apache.flink.kubernetes.kubeclient.resources.KubernetesService)

Example 2 with KubernetesService

use of org.apache.flink.kubernetes.kubeclient.resources.KubernetesService in project flink by apache.

the class Fabric8FlinkKubeClient method getRestEndpoint.

@Override
public Optional<Endpoint> getRestEndpoint(String clusterId) {
    Optional<KubernetesService> restService = getService(KubernetesService.ServiceType.REST_SERVICE, clusterId);
    if (!restService.isPresent()) {
        return Optional.empty();
    }
    final Service service = restService.get().getInternalResource();
    final int restPort = getRestPortFromExternalService(service);
    final KubernetesConfigOptions.ServiceExposedType serviceExposedType = ServiceType.classify(service);
    // Return the external service.namespace directly when using ClusterIP.
    if (serviceExposedType.isClusterIP()) {
        return Optional.of(new Endpoint(ExternalServiceDecorator.getNamespacedExternalServiceName(clusterId, namespace), restPort));
    }
    return getRestEndPointFromService(service, restPort);
}
Also used : KubernetesService(org.apache.flink.kubernetes.kubeclient.resources.KubernetesService) Service(io.fabric8.kubernetes.api.model.Service) ExecutorService(java.util.concurrent.ExecutorService) KubernetesConfigOptions(org.apache.flink.kubernetes.configuration.KubernetesConfigOptions) KubernetesService(org.apache.flink.kubernetes.kubeclient.resources.KubernetesService)

Aggregations

Service (io.fabric8.kubernetes.api.model.Service)2 ExecutorService (java.util.concurrent.ExecutorService)2 KubernetesService (org.apache.flink.kubernetes.kubeclient.resources.KubernetesService)2 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)1 KubernetesConfigOptions (org.apache.flink.kubernetes.configuration.KubernetesConfigOptions)1