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