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);
}
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");
}
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);
}
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();
}
}
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);
}
Aggregations