Search in sources :

Example 16 with ServiceBackendPort

use of io.fabric8.kubernetes.api.model.networking.v1.ServiceBackendPort in project devspaces-images by redhat-developer.

the class IngressesTest method findHostWhenPortDefinedByString.

@Test
public void findHostWhenPortDefinedByString() {
    final String SERVER_PORT_NAME = "server-8080";
    final int PORT = 8080;
    Service service = createService(SERVER_PORT_NAME, PORT);
    Ingress ingress = createIngress(new IngressBackend(null, new IngressServiceBackend("servicename", new ServiceBackendPort(SERVER_PORT_NAME, PORT))));
    Optional<IngressRule> foundRule = Ingresses.findIngressRuleForServicePort(singletonList(ingress), service, PORT);
    assertTrue(foundRule.isPresent());
    assertEquals(foundRule.get().getHost(), "ingresshost");
}
Also used : ServiceBackendPort(io.fabric8.kubernetes.api.model.networking.v1.ServiceBackendPort) IngressRule(io.fabric8.kubernetes.api.model.networking.v1.IngressRule) Service(io.fabric8.kubernetes.api.model.Service) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) IngressBackend(io.fabric8.kubernetes.api.model.networking.v1.IngressBackend) IngressServiceBackend(io.fabric8.kubernetes.api.model.networking.v1.IngressServiceBackend) Test(org.testng.annotations.Test)

Example 17 with ServiceBackendPort

use of io.fabric8.kubernetes.api.model.networking.v1.ServiceBackendPort in project cmcc-operator by T-Systems-MMS.

the class NginxIngressBuilder method build.

@Override
public Collection<? extends HasMetadata> build() {
    ObjectMeta metadata = targetState.getResourceMetadataFor(name);
    metadata.getAnnotations().putAll(annotations);
    List<HTTPIngressPath> httpPaths = paths.stream().map(path -> withPath(new HTTPIngressPathBuilder(), path).withBackend(new IngressBackendBuilder().withService(new IngressServiceBackendBuilder().withName(path.getService()).withPort(new ServiceBackendPort("http", null)).build()).build()).build()).collect(Collectors.toList());
    return Collections.singletonList(new io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder().withMetadata(metadata).withSpec(new IngressSpecBuilder().withIngressClassName("nginx").withTls(new IngressTLSBuilder().withHosts(hostname).build()).withRules(new IngressRuleBuilder().withHost(hostname).withHttp(new HTTPIngressRuleValueBuilder().withPaths(httpPaths).build()).build()).build()).build());
}
Also used : java.util(java.util) TargetState(com.tsystemsmms.cmcc.cmccoperator.targetstate.TargetState) ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) io.fabric8.kubernetes.api.model.networking.v1(io.fabric8.kubernetes.api.model.networking.v1) Collectors(java.util.stream.Collectors) ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta)

Aggregations

IngressBackend (io.fabric8.kubernetes.api.model.networking.v1.IngressBackend)16 IngressRule (io.fabric8.kubernetes.api.model.networking.v1.IngressRule)16 IngressServiceBackend (io.fabric8.kubernetes.api.model.networking.v1.IngressServiceBackend)16 ServiceBackendPort (io.fabric8.kubernetes.api.model.networking.v1.ServiceBackendPort)16 Ingress (io.fabric8.kubernetes.api.model.networking.v1.Ingress)14 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)12 Service (io.fabric8.kubernetes.api.model.Service)12 Test (org.testng.annotations.Test)12 HTTPIngressPath (io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressPath)6 HTTPIngressRuleValue (io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressRuleValue)6 IngressSpec (io.fabric8.kubernetes.api.model.networking.v1.IngressSpec)6 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)5 ServicePort (io.fabric8.kubernetes.api.model.ServicePort)4 ServiceSpec (io.fabric8.kubernetes.api.model.ServiceSpec)4 CommandImpl (org.eclipse.che.api.workspace.server.model.impl.CommandImpl)4 PreviewUrlImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.PreviewUrlImpl)4 KubernetesEnvironment (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment)4 LoadBalancerStatusBuilder (io.fabric8.kubernetes.api.model.LoadBalancerStatusBuilder)2 IngressBuilder (io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder)2 ArrayList (java.util.ArrayList)2