Search in sources :

Example 6 with IngressBuilder

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

the class NetworkingV1IngressTest method testCreateWithNameMismatch.

@Test
void testCreateWithNameMismatch() {
    Ingress ingress1 = new IngressBuilder().withNewMetadata().withName("ingress1").withNamespace("test").and().build();
    Resource<Ingress> ingressOp = client.network().v1().ingresses().inNamespace("test1").withName("myingress1");
    Assertions.assertThrows(KubernetesClientException.class, () -> ingressOp.create(ingress1));
}
Also used : IngressBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) Test(org.junit.jupiter.api.Test)

Example 7 with IngressBuilder

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

the class NetworkingV1IngressTest method testCreateOrReplaceWhenAnnotationUpdated.

@Test
void testCreateOrReplaceWhenAnnotationUpdated() {
    // Given
    Ingress ingressFromServer = new IngressBuilder().withNewMetadata().withName("ing1").endMetadata().build();
    Ingress ingressUpdated = new IngressBuilder(ingressFromServer).editOrNewMetadata().addToAnnotations("nginx.ingress.kubernetes.io/rewrite-target", "/").endMetadata().build();
    server.expect().post().withPath("/apis/networking.k8s.io/v1/namespaces/ns1/ingresses").andReturn(HttpURLConnection.HTTP_CONFLICT, ingressFromServer).once();
    server.expect().get().withPath("/apis/networking.k8s.io/v1/namespaces/ns1/ingresses/ing1").andReturn(HttpURLConnection.HTTP_OK, ingressFromServer).times(2);
    server.expect().put().withPath("/apis/networking.k8s.io/v1/namespaces/ns1/ingresses/ing1").andReturn(HttpURLConnection.HTTP_OK, ingressUpdated).once();
    // When
    ingressUpdated = client.network().v1().ingresses().inNamespace("ns1").createOrReplace(ingressUpdated);
    // Then
    assertNotNull(ingressUpdated);
    assertNotNull(ingressUpdated.getMetadata());
    assertTrue(ingressUpdated.getMetadata().getAnnotations().containsKey("nginx.ingress.kubernetes.io/rewrite-target"));
}
Also used : IngressBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) Test(org.junit.jupiter.api.Test)

Example 8 with IngressBuilder

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

the class NetworkingV1beta1IngressTest method testDelete.

@Test
void testDelete() {
    server.expect().withPath("/apis/networking.k8s.io/v1beta1/namespaces/test/ingresses/ingress1").andReturn(200, new IngressBuilder().build()).once();
    server.expect().withPath("/apis/networking.k8s.io/v1beta1/namespaces/ns1/ingresses/ingress2").andReturn(200, new IngressBuilder().build()).once();
    Boolean deleted = client.network().ingress().withName("ingress1").delete();
    assertTrue(deleted);
    deleted = client.network().ingress().withName("ingress2").delete();
    assertFalse(deleted);
    deleted = client.network().ingress().inNamespace("ns1").withName("ingress2").delete();
    assertTrue(deleted);
}
Also used : IngressBuilder(io.fabric8.kubernetes.api.model.networking.v1beta1.IngressBuilder) Test(org.junit.jupiter.api.Test)

Example 9 with IngressBuilder

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

the class NetworkingV1beta1IngressTest method testCreateOrReplaceWhenAnnotationUpdated.

@Test
void testCreateOrReplaceWhenAnnotationUpdated() {
    // Given
    Ingress ingressFromServer = new IngressBuilder().withNewMetadata().withName("ing1").endMetadata().build();
    Ingress ingressUpdated = new IngressBuilder(ingressFromServer).editOrNewMetadata().addToAnnotations("nginx.ingress.kubernetes.io/rewrite-target", "/").endMetadata().build();
    server.expect().post().withPath("/apis/networking.k8s.io/v1beta1/namespaces/ns1/ingresses").andReturn(HttpURLConnection.HTTP_CONFLICT, ingressFromServer).once();
    server.expect().get().withPath("/apis/networking.k8s.io/v1beta1/namespaces/ns1/ingresses/ing1").andReturn(HttpURLConnection.HTTP_OK, ingressFromServer).times(2);
    server.expect().put().withPath("/apis/networking.k8s.io/v1beta1/namespaces/ns1/ingresses/ing1").andReturn(HttpURLConnection.HTTP_OK, ingressUpdated).once();
    // When
    ingressUpdated = client.network().ingresses().inNamespace("ns1").createOrReplace(ingressUpdated);
    // Then
    assertNotNull(ingressUpdated);
    assertNotNull(ingressUpdated.getMetadata());
    assertTrue(ingressUpdated.getMetadata().getAnnotations().containsKey("nginx.ingress.kubernetes.io/rewrite-target"));
}
Also used : IngressBuilder(io.fabric8.kubernetes.api.model.networking.v1beta1.IngressBuilder) Ingress(io.fabric8.kubernetes.api.model.networking.v1beta1.Ingress) Test(org.junit.jupiter.api.Test)

Example 10 with IngressBuilder

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

the class NetworkingV1beta1IngressTest method testGet.

@Test
void testGet() {
    server.expect().withPath("/apis/networking.k8s.io/v1beta1/namespaces/test/ingresses/ingress1").andReturn(200, new IngressBuilder().build()).once();
    server.expect().withPath("/apis/networking.k8s.io/v1beta1/namespaces/ns1/ingresses/ingress2").andReturn(200, new IngressBuilder().build()).once();
    Ingress ingress = client.network().ingress().withName("ingress1").get();
    assertNotNull(ingress);
    ingress = client.network().ingress().withName("ingress2").get();
    assertNull(ingress);
    ingress = client.network().ingress().inNamespace("ns1").withName("ingress2").get();
    assertNotNull(ingress);
}
Also used : IngressBuilder(io.fabric8.kubernetes.api.model.networking.v1beta1.IngressBuilder) Ingress(io.fabric8.kubernetes.api.model.networking.v1beta1.Ingress) Test(org.junit.jupiter.api.Test)

Aggregations

IngressBuilder (io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder)39 Ingress (io.fabric8.kubernetes.api.model.networking.v1.Ingress)31 Test (org.junit.jupiter.api.Test)28 IngressBuilder (io.fabric8.kubernetes.api.model.extensions.IngressBuilder)13 ArrayList (java.util.ArrayList)13 Ingress (io.fabric8.kubernetes.api.model.extensions.Ingress)11 HTTPIngressPathBuilder (io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressPathBuilder)11 IngressRule (io.fabric8.kubernetes.api.model.networking.v1.IngressRule)9 IngressTLSBuilder (io.fabric8.kubernetes.api.model.networking.v1.IngressTLSBuilder)9 HTTPIngressPath (io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressPath)8 GenericKafkaListener (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener)8 Test (org.junit.Test)8 IngressRuleBuilder (io.fabric8.kubernetes.api.model.networking.v1.IngressRuleBuilder)7 IngressBuilder (io.fabric8.kubernetes.api.model.networking.v1beta1.IngressBuilder)6 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)5 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)5 HTTPIngressPathBuilder (io.fabric8.kubernetes.api.model.extensions.HTTPIngressPathBuilder)5 Ingress (io.fabric8.kubernetes.api.model.networking.v1beta1.Ingress)5 HashMap (java.util.HashMap)5 HTTPIngressPath (io.fabric8.kubernetes.api.model.extensions.HTTPIngressPath)4