Search in sources :

Example 46 with Ingress

use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress 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 47 with Ingress

use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress 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 48 with Ingress

use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress 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 49 with Ingress

use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress in project quarkus by quarkusio.

the class KubernetesWithIngressTest method assertGeneratedResources.

@Test
public void assertGeneratedResources() throws IOException {
    final Path kubernetesDir = prodModeTestResults.getBuildDir().resolve("kubernetes");
    assertThat(kubernetesDir).isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.json")).isDirectoryContaining(p -> p.getFileName().endsWith("kubernetes.yml"));
    List<HasMetadata> kubernetesList = DeserializationUtil.deserializeAsList(kubernetesDir.resolve("kubernetes.yml"));
    assertThat(kubernetesList.get(0)).isInstanceOfSatisfying(Deployment.class, d -> {
        assertThat(d.getMetadata()).satisfies(m -> {
            assertThat(m.getName()).isEqualTo("kubernetes-with-ingress");
        });
        assertThat(d.getSpec()).satisfies(deploymentSpec -> {
            assertThat(deploymentSpec.getTemplate()).satisfies(t -> {
                assertThat(t.getSpec()).satisfies(podSpec -> {
                });
            });
        });
    });
    assertThat(kubernetesList).filteredOn(i -> "Ingress".equals(i.getKind())).singleElement().satisfies(item -> {
        assertThat(item).isInstanceOfSatisfying(Ingress.class, ingress -> {
            // Check that labels and annotations are also applied to Routes (#10260)
            assertThat(ingress.getMetadata()).satisfies(m -> {
                assertThat(m.getName()).isEqualTo("kubernetes-with-ingress");
            });
            assertThat(ingress.getSpec().getRules()).allSatisfy(rule -> {
                assertThat(rule.getHttp().getPaths()).allSatisfy(path -> {
                    assertThat(path.getPath()).isNotBlank();
                    assertThat(path.getPathType()).isNotBlank();
                });
            });
        });
    });
}
Also used : Path(java.nio.file.Path) AppArtifact(io.quarkus.bootstrap.model.AppArtifact) QuarkusProdModeTest(io.quarkus.test.QuarkusProdModeTest) Version(io.quarkus.builder.Version) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IOException(java.io.IOException) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) Test(org.junit.jupiter.api.Test) List(java.util.List) RegisterExtension(org.junit.jupiter.api.extension.RegisterExtension) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) ProdBuildResults(io.quarkus.test.ProdBuildResults) ProdModeTestResults(io.quarkus.test.ProdModeTestResults) Path(java.nio.file.Path) Collections(java.util.Collections) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) QuarkusProdModeTest(io.quarkus.test.QuarkusProdModeTest) Test(org.junit.jupiter.api.Test)

Example 50 with Ingress

use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress in project yakc by manusa.

the class NetworkingV1IngressIT method readNamespacedIngress.

@Test
@DisplayName("readNamespacedIngress, should read existing Ingress with provided name")
void readNamespacedIngress() throws IOException {
    // When
    final Ingress result = KC.create(NetworkingV1Api.class).readNamespacedIngress(ingressName, NAMESPACE).get();
    // Then
    assertThat(result).isNotNull().extracting("metadata").hasFieldOrPropertyWithValue("name", ingressName).hasFieldOrPropertyWithValue("creationTimestamp", ingress.getMetadata().getCreationTimestamp());
}
Also used : Ingress(com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

Ingress (io.fabric8.kubernetes.api.model.networking.v1.Ingress)158 Service (io.fabric8.kubernetes.api.model.Service)47 Test (org.junit.jupiter.api.Test)42 Test (org.testng.annotations.Test)36 IngressRule (io.fabric8.kubernetes.api.model.networking.v1.IngressRule)31 IngressBuilder (io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder)28 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)25 IngressBackend (io.fabric8.kubernetes.api.model.networking.v1.IngressBackend)24 ArrayList (java.util.ArrayList)22 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)21 HashMap (java.util.HashMap)21 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)16 ServerConfigImpl (org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl)16 HTTPIngressPath (io.fabric8.kubernetes.api.model.networking.v1.HTTPIngressPath)14 IngressServiceBackend (io.fabric8.kubernetes.api.model.networking.v1.IngressServiceBackend)14 ServiceBackendPort (io.fabric8.kubernetes.api.model.networking.v1.ServiceBackendPort)14 PlatformFeaturesAvailability (io.strimzi.operator.PlatformFeaturesAvailability)14 KafkaCluster (io.strimzi.operator.cluster.model.KafkaCluster)14 Reconciliation (io.strimzi.operator.common.Reconciliation)14 IngressOperator (io.strimzi.operator.common.operator.resource.IngressOperator)14