Search in sources :

Example 56 with Ingress

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

the class NetworkingV1IngressGeneratorTest method testGenerateWithXMLConfig.

@Test
public void testGenerateWithXMLConfig() {
    // Given
    ServiceBuilder testSvcBuilder = initTestService();
    KubernetesListBuilder kubernetesListBuilder = new KubernetesListBuilder().addToItems(testSvcBuilder);
    IngressRuleConfig ingressRuleConfig = IngressRuleConfig.builder().host("foo.bar.com").path(IngressRulePathConfig.builder().path("/foo").pathType("Prefix").serviceName("test-svc").servicePort(8080).resource(IngressRulePathResourceConfig.builder().apiGroup("k8s.example.com").kind("StorageSets").name("icon-assets").build()).build()).build();
    IngressTlsConfig ingressTlsConfig = IngressTlsConfig.builder().host("foo.bar.com").secretName("testsecret-tls").build();
    // When
    Ingress ingress = NetworkingV1IngressGenerator.generate(kubernetesListBuilder, testSvcBuilder, "org.eclipse.jkube", null, Collections.singletonList(ingressRuleConfig), Collections.singletonList(ingressTlsConfig), logger);
    // Then
    assertThat(ingress).hasFieldOrPropertyWithValue("metadata.name", "test-svc").extracting("spec.rules").asList().hasSize(1).element(0).hasFieldOrPropertyWithValue("host", "foo.bar.com");
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) IngressTlsConfig(org.eclipse.jkube.kit.config.resource.IngressTlsConfig) IngressRuleConfig(org.eclipse.jkube.kit.config.resource.IngressRuleConfig) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder) Test(org.junit.Test)

Example 57 with Ingress

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

the class NetworkingV1IngressGeneratorTest method testGenerateNoHostOrRouteDomainConfigured.

@Test
public void testGenerateNoHostOrRouteDomainConfigured() {
    // Given
    ServiceBuilder testSvcBuilder = initTestService();
    KubernetesListBuilder kubernetesListBuilder = new KubernetesListBuilder().addToItems(testSvcBuilder);
    // When
    Ingress ingress = NetworkingV1IngressGenerator.generate(kubernetesListBuilder, testSvcBuilder, null, null, Collections.emptyList(), Collections.emptyList(), logger);
    // Then
    assertThat(ingress).isNotNull().hasFieldOrPropertyWithValue("metadata.name", "test-svc");
    assertThat(ingress.getSpec()).isNotNull();
    assertThat(ingress.getSpec().getDefaultBackend().getService().getName()).isEqualTo("test-svc");
    assertThat(ingress.getSpec().getDefaultBackend().getService().getPort().getNumber()).isEqualTo(8080);
}
Also used : KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder) Test(org.junit.Test)

Example 58 with Ingress

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

the class TemplateProviderTest method bridgeIngressKubernetesIngressTemplateIsProvided.

@Test
public void bridgeIngressKubernetesIngressTemplateIsProvided() {
    TemplateProvider templateProvider = new TemplateProviderImpl();
    Ingress ingress = templateProvider.loadBridgeIngressKubernetesIngressTemplate(BRIDGE_INGRESS);
    assertOwnerReference(BRIDGE_INGRESS, ingress.getMetadata());
    assertLabels(ingress.getMetadata(), BridgeIngress.COMPONENT_NAME);
    assertThat(ingress.getMetadata().getAnnotations().get(KubernetesNetworkingService.NGINX_REWRITE_TARGET_ANNOTATION)).isEqualTo(KubernetesNetworkingService.REWRITE_TARGET_PLACEHOLDER);
    assertThat(ingress.getSpec().getRules().size()).isEqualTo(1);
    assertThat(ingress.getSpec().getRules().get(0).getHttp().getPaths().size()).isEqualTo(1);
    assertThat(ingress.getSpec().getRules().get(0).getHttp().getPaths().get(0).getPathType()).isEqualTo("Prefix");
}
Also used : Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) BridgeIngress(com.redhat.service.bridge.shard.operator.resources.BridgeIngress) Test(org.junit.jupiter.api.Test)

Example 59 with Ingress

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

the class KubernetesNetworkingService method fetchOrCreateNetworkIngress.

@Override
public NetworkResource fetchOrCreateNetworkIngress(BridgeIngress bridgeIngress, Service service) {
    Ingress expected = buildIngress(bridgeIngress, service);
    Ingress existing = client.network().v1().ingresses().inNamespace(service.getMetadata().getNamespace()).withName(service.getMetadata().getName()).get();
    if (existing == null || !expected.getSpec().equals(existing.getSpec())) {
        client.network().v1().ingresses().inNamespace(service.getMetadata().getNamespace()).withName(service.getMetadata().getName()).createOrReplace(expected);
        return buildNetworkingResource(expected);
    }
    return buildNetworkingResource(existing);
}
Also used : Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) BridgeIngress(com.redhat.service.bridge.shard.operator.resources.BridgeIngress)

Example 60 with Ingress

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

the class KubernetesNetworkingTestUtils method patchNetworkResource.

@Override
public void patchNetworkResource(String name, String namespace) {
    Ingress i = client.network().v1().ingresses().inNamespace(namespace).withName(name).get();
    IngressStatus ingressStatus = new IngressStatusBuilder().withLoadBalancer(new LoadBalancerStatusBuilder().withIngress(new LoadBalancerIngressBuilder().withHostname(name).withIp(NetworkingTestConstants.HOST_IP).build()).build()).build();
    i.setStatus(ingressStatus);
    client.network().v1().ingresses().inNamespace(namespace).createOrReplace(i);
}
Also used : IngressStatusBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressStatusBuilder) IngressStatus(io.fabric8.kubernetes.api.model.networking.v1.IngressStatus) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) LoadBalancerIngressBuilder(io.fabric8.kubernetes.api.model.LoadBalancerIngressBuilder) LoadBalancerStatusBuilder(io.fabric8.kubernetes.api.model.LoadBalancerStatusBuilder)

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