Search in sources :

Example 96 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 : BridgeIngress(com.redhat.service.smartevents.shard.operator.resources.BridgeIngress) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress)

Example 97 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 : BridgeIngress(com.redhat.service.smartevents.shard.operator.resources.BridgeIngress) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) Test(org.junit.jupiter.api.Test)

Example 98 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)

Example 99 with Ingress

use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress in project flink-kubernetes-operator by apache.

the class IngressUtils method updateIngressRules.

public static void updateIngressRules(ObjectMeta objectMeta, FlinkDeploymentSpec spec, Configuration effectiveConfig, KubernetesClient client) {
    if (spec.getIngress() != null) {
        Ingress ingress = new IngressBuilder().withNewMetadata().withAnnotations(spec.getIngress().getAnnotations()).withName(objectMeta.getName()).withNamespace(objectMeta.getNamespace()).endMetadata().withNewSpec().withIngressClassName(spec.getIngress().getClassName()).withRules(getIngressRule(objectMeta, spec, effectiveConfig)).endSpec().build();
        Deployment deployment = client.apps().deployments().inNamespace(objectMeta.getNamespace()).withName(objectMeta.getName()).get();
        if (deployment == null) {
            LOG.error("Could not find deployment {}", objectMeta.getName());
        } else {
            setOwnerReference(deployment, Collections.singletonList(ingress));
        }
        LOG.info("Updating ingress rules {}", ingress);
        client.resourceList(ingress).inNamespace(objectMeta.getNamespace()).createOrReplace();
    }
}
Also used : IngressBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment)

Example 100 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 shouldWellComputeWhitelistForTwoGroupWithWhitespaceInAnnotation.

@Test
public void shouldWellComputeWhitelistForTwoGroupWithWhitespaceInAnnotation() {
    // 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)

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