Search in sources :

Example 16 with IngressBuilder

use of io.fabric8.openshift.api.model.IngressBuilder in project ingress-access-operator by neo9.

the class ServiceExposerReconcilerTest method shouldNotEnableTlsByDefault.

@Test
public void shouldNotEnableTlsByDefault() {
    // given
    Ingress ingress = new IngressBuilder().withNewMetadata().withNamespace("mynamespace").withName("myname").addToAnnotations(EXPOSE_INGRESS_HOSTNAME, "hello.{{domain}}").endMetadata().build();
    // when
    boolean shouldEnableTls = serviceExposerReconciler.shouldEnableTls(ingress.getMetadata().getAnnotations());
    // then
    assertThat(shouldEnableTls).isFalse();
}
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 17 with IngressBuilder

use of io.fabric8.openshift.api.model.IngressBuilder in project ingress-access-operator by neo9.

the class VisitorGroupServiceExposerReconcilerTest method shouldWellComputeWhitelistForTwoGroup.

@Test
public void shouldWellComputeWhitelistForTwoGroup() {
    // given
    Ingress ingress = new IngressBuilder().withNewMetadata().withName("test").withAnnotations(Map.of(MutationAnnotations.MUTABLE_INGRESS_VISITOR_GROUP_KEY, "vg1,vg2")).endMetadata().build();
    // when
    String cidrListAsString = visitorGroupIngressReconciler.getCidrListAsString(ingress);
    // then
    assertThat(cidrListAsString).isEqualTo(visitorGroup1Ips + "," + visitorGroup2Ips);
}
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 18 with IngressBuilder

use of io.fabric8.openshift.api.model.IngressBuilder in project ingress-access-operator by neo9.

the class VisitorGroupServiceExposerReconcilerTest method shouldPanicOnUnknownVisitorGroup.

@Test
public void shouldPanicOnUnknownVisitorGroup() {
    // given
    Ingress ingress = new IngressBuilder().withNewMetadata().withName("test").withAnnotations(Map.of(MutationAnnotations.MUTABLE_INGRESS_VISITOR_GROUP_KEY, "vgUndefined")).endMetadata().build();
    // when / then
    assertThatThrownBy(() -> visitorGroupIngressReconciler.getCidrListAsString(ingress)).isInstanceOf(VisitorGroupNotFoundException.class);
}
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 19 with IngressBuilder

use of io.fabric8.openshift.api.model.IngressBuilder in project dekorate by dekorateio.

the class AddIngressDecorator method visit.

public void visit(KubernetesListBuilder list) {
    Optional<Port> p = getHttpPort(config);
    if (!p.isPresent() || !config.isExpose()) {
        return;
    }
    if (contains(list, ANY, "Ingress", config.getName())) {
        return;
    }
    Port port = p.get();
    list.addToItems(new IngressBuilder().withNewMetadata().withName(config.getName()).withLabels(allLabels).endMetadata().withNewSpec().addNewRule().withHost(config.getHost()).withNewHttp().addNewPath().withNewPathType("Prefix").withPath(Strings.isNotNullOrEmpty(port.getPath()) ? port.getPath() : "/").withNewBackend().withNewService().withName(config.getName()).withNewPort().withName(port.getName()).withNumber(Strings.isNullOrEmpty(port.getName()) && port.getHostPort() != null && port.getHostPort() > 0 ? port.getHostPort() : null).endPort().endService().endBackend().endPath().endHttp().endRule().endSpec().build());
}
Also used : IngressBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder) Port(io.dekorate.kubernetes.config.Port) Ports.getHttpPort(io.dekorate.utils.Ports.getHttpPort)

Example 20 with IngressBuilder

use of io.fabric8.openshift.api.model.IngressBuilder in project jkube by eclipse.

the class ApplyServiceTest method testApplyToMultipleNamespaceNoNamespaceConfigured.

@Test
public void testApplyToMultipleNamespaceNoNamespaceConfigured() throws InterruptedException {
    // Given
    ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withName("cm1").withNamespace("ns1").endMetadata().build();
    Ingress ingress = new IngressBuilder().withNewMetadata().withName("ing1").withNamespace("ns2").endMetadata().build();
    ServiceAccount serviceAccount = new ServiceAccountBuilder().withNewMetadata().withName("sa1").endMetadata().build();
    List<HasMetadata> entities = new ArrayList<>();
    entities.add(configMap);
    entities.add(serviceAccount);
    entities.add(ingress);
    WebServerEventCollector collector = new WebServerEventCollector();
    mockServer.expect().post().withPath("/api/v1/namespaces/ns1/configmaps").andReply(collector.record("configmap-ns1-create").andReturn(HTTP_OK, configMap)).once();
    mockServer.expect().post().withPath("/apis/networking.k8s.io/v1/namespaces/ns2/ingresses").andReply(collector.record("ingress-ns2-create").andReturn(HTTP_OK, ingress)).once();
    mockServer.expect().post().withPath("/api/v1/namespaces/default/serviceaccounts").andReply(collector.record("serviceaccount-default-create").andReturn(HTTP_OK, serviceAccount)).once();
    String configuredNamespace = applyService.getNamespace();
    applyService.setNamespace(null);
    applyService.setFallbackNamespace("default");
    // When
    applyService.applyEntities(null, entities, log, 5);
    // Then
    collector.assertEventsRecordedInOrder("configmap-ns1-create", "serviceaccount-default-create", "ingress-ns2-create");
    assertEquals(5, mockServer.getOpenShiftMockServer().getRequestCount());
    applyService.setFallbackNamespace(null);
    applyService.setNamespace(configuredNamespace);
}
Also used : IngressBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder) ServiceAccount(io.fabric8.kubernetes.api.model.ServiceAccount) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) ArrayList(java.util.ArrayList) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) ServiceAccountBuilder(io.fabric8.kubernetes.api.model.ServiceAccountBuilder) WebServerEventCollector(org.eclipse.jkube.kit.config.service.openshift.WebServerEventCollector) Test(org.junit.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