Search in sources :

Example 16 with ServiceBuilder

use of io.fabric8.knative.serving.v1.ServiceBuilder in project fabric8 by fabric8io.

the class ConfigCompareServiceTest method testServicesSelectorNotEqual.

@Test
public void testServicesSelectorNotEqual() throws Exception {
    Service entity1 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label1", "value1").addToLabels("label2", "value2").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("label2", "value2").addNewPort().withPort(123).withNewTargetPort(456).endPort().endSpec().build();
    Service entity2 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label2", "value2").addToLabels("label1", "value1").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("notSame", "value2").addNewPort().withPort(123).withNewTargetPort(456).endPort().endSpec().build();
    assertCompareConfig(entity1, entity2, false);
}
Also used : Service(io.fabric8.kubernetes.api.model.Service) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder) Test(org.junit.Test)

Example 17 with ServiceBuilder

use of io.fabric8.knative.serving.v1.ServiceBuilder in project fabric8 by fabric8io.

the class ConfigCompareServiceTest method testServicesPortNotEqual.

@Test
public void testServicesPortNotEqual() throws Exception {
    Service entity1 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label1", "value1").addToLabels("label2", "value2").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("label2", "value2").addNewPort().withPort(123).withNewTargetPort(456).endPort().endSpec().build();
    Service entity2 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label2", "value2").addToLabels("label1", "value1").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("label2", "value2").addNewPort().withPort(456).withNewTargetPort(456).endPort().endSpec().build();
    assertCompareConfig(entity1, entity2, false);
}
Also used : Service(io.fabric8.kubernetes.api.model.Service) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder) Test(org.junit.Test)

Example 18 with ServiceBuilder

use of io.fabric8.knative.serving.v1.ServiceBuilder in project fabric8 by fabric8io.

the class ConfigCompareServiceTest method testServicesContainerPortNotEqual.

@Test
public void testServicesContainerPortNotEqual() throws Exception {
    Service entity1 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label1", "value1").addToLabels("label2", "value2").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("label2", "value2").addNewPort().withPort(123).withNewTargetPort(456).endPort().endSpec().build();
    Service entity2 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label2", "value2").addToLabels("label1", "value1").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("label2", "value2").addNewPort().withPort(123).withNewTargetPort(555).endPort().endSpec().build();
    assertCompareConfig(entity1, entity2, false);
}
Also used : Service(io.fabric8.kubernetes.api.model.Service) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder) Test(org.junit.Test)

Example 19 with ServiceBuilder

use of io.fabric8.knative.serving.v1.ServiceBuilder in project fabric8 by fabric8io.

the class ConfigCompareServiceTest method testServicesEqualWithStatusDifferences.

@Test
public void testServicesEqualWithStatusDifferences() throws Exception {
    Service entity1 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label1", "value1").addToLabels("label2", "value2").withResourceVersion("1").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("label2", "value2").addNewPort().withPort(123).withNewTargetPort(456).endPort().endSpec().build();
    Service entity2 = new ServiceBuilder().withNewMetadata().withName("foo").addToLabels("label2", "value2").addToLabels("label1", "value1").withResourceVersion("2").endMetadata().withNewSpec().addToSelector("label1", "value1").addToSelector("label2", "value2").addNewPort().withPort(123).withNewTargetPort(456).endPort().endSpec().build();
    assertCompareConfig(entity1, entity2, true);
}
Also used : Service(io.fabric8.kubernetes.api.model.Service) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder) Test(org.junit.Test)

Example 20 with ServiceBuilder

use of io.fabric8.knative.serving.v1.ServiceBuilder in project vertx-openshift-it by cescoffier.

the class PhantomJSDeployment method createPhantomService.

private void createPhantomService() {
    if (!retrieveService()) {
        ServicePort sp = new ServicePortBuilder().withProtocol("TCP").withPort(4444).withNewTargetPort(4444).build();
        Service sb = new ServiceBuilder().withNewMetadata().withName(PHANTOMJS).addToLabels("name", PHANTOMJS).endMetadata().withNewSpec().withSessionAffinity("None").addToSelector("name", PHANTOMJS).addToPorts(sp).endSpec().build();
        client.services().create(sb);
    }
}
Also used : ServicePort(io.fabric8.kubernetes.api.model.ServicePort) ServicePortBuilder(io.fabric8.kubernetes.api.model.ServicePortBuilder) Kube.createRouteForService(io.vertx.it.openshift.utils.Kube.createRouteForService) Service(io.fabric8.kubernetes.api.model.Service) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder)

Aggregations

ServiceBuilder (io.fabric8.kubernetes.api.model.ServiceBuilder)39 Service (io.fabric8.kubernetes.api.model.Service)32 Test (org.junit.Test)14 ServicePortBuilder (io.fabric8.kubernetes.api.model.ServicePortBuilder)11 ServicePort (io.fabric8.kubernetes.api.model.ServicePort)7 ArrayList (java.util.ArrayList)7 ServiceListBuilder (io.fabric8.kubernetes.api.model.ServiceListBuilder)5 EndpointsListBuilder (io.fabric8.kubernetes.api.model.EndpointsListBuilder)4 Pod (io.fabric8.kubernetes.api.model.Pod)4 ServiceSpec (io.fabric8.kubernetes.api.model.ServiceSpec)4 VolumeBuilder (io.fabric8.kubernetes.api.model.VolumeBuilder)4 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)4 RouteBuilder (io.fabric8.openshift.api.model.RouteBuilder)4 Map (java.util.Map)4 Container (io.fabric8.kubernetes.api.model.Container)3 IOException (java.io.IOException)3 KubernetesPluginException (org.ballerinax.kubernetes.exceptions.KubernetesPluginException)3 Alias (io.fabric8.annotations.Alias)2 External (io.fabric8.annotations.External)2 PortName (io.fabric8.annotations.PortName)2