Search in sources :

Example 71 with Ingress

use of io.fabric8.kubernetes.api.model.networking.v1.Ingress in project kubernetes-client by fabric8io.

the class IngressTest method testDeleteWithNamespaceMismatch.

@Test
public void testDeleteWithNamespaceMismatch() {
    Ingress ingress1 = new IngressBuilder().withNewMetadata().withName("ingress1").withNamespace("test").and().build();
    Boolean deleted = client.extensions().ingress().inNamespace("test1").delete(ingress1);
    assertFalse(deleted);
}
Also used : IngressBuilder(io.fabric8.kubernetes.api.model.extensions.IngressBuilder) Ingress(io.fabric8.kubernetes.api.model.extensions.Ingress) Test(org.junit.jupiter.api.Test)

Example 72 with Ingress

use of io.fabric8.kubernetes.api.model.networking.v1.Ingress in project kubernetes-client by fabric8io.

the class IngressTest method testCreateWithNameMismatch.

@Test
public void testCreateWithNameMismatch() {
    Assertions.assertThrows(KubernetesClientException.class, () -> {
        Ingress ingress1 = new IngressBuilder().withNewMetadata().withName("ingress1").withNamespace("test").and().build();
        Ingress ingress2 = new IngressBuilder().withNewMetadata().withName("ingress2").withNamespace("ns1").and().build();
        client.extensions().ingress().inNamespace("test1").withName("myingress1").create(ingress1);
    });
}
Also used : IngressBuilder(io.fabric8.kubernetes.api.model.extensions.IngressBuilder) Ingress(io.fabric8.kubernetes.api.model.extensions.Ingress) Test(org.junit.jupiter.api.Test)

Example 73 with Ingress

use of io.fabric8.kubernetes.api.model.networking.v1.Ingress in project kubernetes-client by fabric8io.

the class IngressTest method testListWithLables.

@Test
public void testListWithLables() {
    server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/ingresses?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2,key3=value3")).andReturn(200, new IngressListBuilder().build()).always();
    server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/ingresses?labelSelector=" + Utils.toUrlEncoded("key1=value1,key2=value2")).andReturn(200, new IngressListBuilder().addNewItem().and().addNewItem().and().addNewItem().and().build()).once();
    IngressList ingressList = client.extensions().ingress().withLabel("key1", "value1").withLabel("key2", "value2").withLabel("key3", "value3").list();
    assertNotNull(ingressList);
    assertEquals(0, ingressList.getItems().size());
    ingressList = client.extensions().ingress().withLabel("key1", "value1").withLabel("key2", "value2").list();
    assertNotNull(ingressList);
    assertEquals(3, ingressList.getItems().size());
}
Also used : IngressListBuilder(io.fabric8.kubernetes.api.model.extensions.IngressListBuilder) IngressList(io.fabric8.kubernetes.api.model.extensions.IngressList) Test(org.junit.jupiter.api.Test)

Example 74 with Ingress

use of io.fabric8.kubernetes.api.model.networking.v1.Ingress in project kubernetes-client by fabric8io.

the class IngressTest method testDeleteMulti.

@Test
public void testDeleteMulti() {
    Ingress ingress1 = new IngressBuilder().withNewMetadata().withName("ingress1").withNamespace("test").and().build();
    Ingress ingress2 = new IngressBuilder().withNewMetadata().withName("ingress2").withNamespace("ns1").and().build();
    Ingress ingress3 = new IngressBuilder().withNewMetadata().withName("ingress3").withNamespace("any").and().build();
    server.expect().withPath("/apis/extensions/v1beta1/namespaces/test/ingresses/ingress1").andReturn(200, ingress1).once();
    server.expect().withPath("/apis/extensions/v1beta1/namespaces/ns1/ingresses/ingress2").andReturn(200, ingress2).once();
    Boolean deleted = client.extensions().ingress().inAnyNamespace().delete(ingress1, ingress2);
    assertTrue(deleted);
    deleted = client.extensions().ingress().inAnyNamespace().delete(ingress3);
    assertFalse(deleted);
}
Also used : IngressBuilder(io.fabric8.kubernetes.api.model.extensions.IngressBuilder) Ingress(io.fabric8.kubernetes.api.model.extensions.Ingress) Test(org.junit.jupiter.api.Test)

Example 75 with Ingress

use of io.fabric8.kubernetes.api.model.networking.v1.Ingress in project kubernetes-client by fabric8io.

the class V1IngressClassTest method testLoad.

@Test
void testLoad() {
    // When
    List<HasMetadata> itemList = client.load(getClass().getResourceAsStream("/test-v1-ingressclass.yml")).get();
    // Then
    assertEquals(1, itemList.size());
    assertTrue(itemList.get(0) instanceof IngressClass);
    IngressClass ingressClass = (IngressClass) itemList.get(0);
    assertEquals("external-lb", ingressClass.getMetadata().getName());
    assertEquals("example.com/ingress-controller", ingressClass.getSpec().getController());
}
Also used : HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) IngressClass(io.fabric8.kubernetes.api.model.networking.v1.IngressClass) Test(org.junit.jupiter.api.Test)

Aggregations

Ingress (io.fabric8.kubernetes.api.model.networking.v1.Ingress)132 Service (io.fabric8.kubernetes.api.model.Service)63 Test (org.junit.jupiter.api.Test)50 Test (org.testng.annotations.Test)38 IngressBuilder (io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder)35 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)33 Ingress (io.fabric8.kubernetes.api.model.extensions.Ingress)33 IngressRule (io.fabric8.kubernetes.api.model.networking.v1.IngressRule)32 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)31 ArrayList (java.util.ArrayList)29 IngressBackend (io.fabric8.kubernetes.api.model.networking.v1.IngressBackend)27 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)26 HashMap (java.util.HashMap)24 Test (org.junit.Test)22 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)18 IngressServiceBackend (io.fabric8.kubernetes.api.model.networking.v1.IngressServiceBackend)18 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)18 ServerConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl)18 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)17 HTTPIngressPath (io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressPath)17