use of org.eclipse.jkube.kit.config.resource.IngressTlsConfig in project jkube by eclipse.
the class IngressEnricherTest method testGetIngressTlsXMLConfigWithNonNullResourceConfig.
@Test
public void testGetIngressTlsXMLConfigWithNonNullResourceConfig() {
// Given
ResourceConfig resourceConfig = ResourceConfig.builder().ingress(IngressConfig.builder().ingressTlsConfig(IngressTlsConfig.builder().secretName("secret1").build()).build()).build();
// When
List<IngressTlsConfig> ingressTlsConfigs = IngressEnricher.getIngressTlsXMLConfig(resourceConfig);
// Then
assertThat(ingressTlsConfigs).asList().hasSize(1);
}
use of org.eclipse.jkube.kit.config.resource.IngressTlsConfig 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 org.eclipse.jkube.kit.config.resource.IngressTlsConfig in project jkube by eclipse.
the class NetworkingV1IngressGenerator method getXmlConfiguredIngressSpec.
private static IngressSpec getXmlConfiguredIngressSpec(List<IngressRuleConfig> ingressRuleConfigs, List<IngressTlsConfig> ingressTlsConfigs) {
IngressSpecBuilder ingressSpecBuilder = new IngressSpecBuilder();
for (IngressRuleConfig ingressRuleConfig : ingressRuleConfigs) {
IngressRule ingressRule = getIngressRuleFromXmlConfig(ingressRuleConfig);
ingressSpecBuilder.addToRules(ingressRule);
}
for (IngressTlsConfig ingressTlsConfig : ingressTlsConfigs) {
IngressTLS ingressTLS = getIngressTlsFromXMLConfig(ingressTlsConfig);
ingressSpecBuilder.addToTls(ingressTLS);
}
return ingressSpecBuilder.build();
}
use of org.eclipse.jkube.kit.config.resource.IngressTlsConfig in project jkube by eclipse.
the class IngressEnricherTest method testCreateIngressFromXMLConfigWithConfiguredServiceName.
@Test
public void testCreateIngressFromXMLConfigWithConfiguredServiceName() {
// Given
ResourceConfig resourceConfig = ResourceConfig.builder().ingress(IngressConfig.builder().ingressRule(IngressRuleConfig.builder().host("foo.bar.com").path(IngressRulePathConfig.builder().pathType("ImplementationSpecific").path("/icons").serviceName("hello-k8s").servicePort(80).build()).build()).ingressRule(IngressRuleConfig.builder().host("*.foo.com").path(IngressRulePathConfig.builder().path("/icons-storage").pathType("Exact").resource(IngressRulePathResourceConfig.builder().apiGroup("k8s.example.com").kind("StorageBucket").name("icon-assets").build()).build()).build()).ingressTlsConfig(IngressTlsConfig.builder().host("https-example.foo.com").secretName("testsecret-tls").build()).build()).build();
// @formatter:off
new Expectations() {
{
// Enable creation of Ingress for Service of type LoadBalancer
context.getProperty(CREATE_EXTERNAL_URLS);
result = "true";
context.getConfiguration().getResource();
result = resourceConfig;
}
};
// @formatter:on
Service providedService = initTestService().build();
KubernetesListBuilder kubernetesListBuilder = new KubernetesListBuilder().addToItems(providedService);
// When
ingressEnricher.create(PlatformMode.kubernetes, kubernetesListBuilder);
// Then
assertThat(kubernetesListBuilder).extracting(KubernetesListBuilder::buildItems).asList().hasSize(2).element(1).asInstanceOf(InstanceOfAssertFactories.type(Ingress.class)).hasFieldOrPropertyWithValue("apiVersion", "networking.k8s.io/v1").hasFieldOrPropertyWithValue("metadata.name", providedService.getMetadata().getName()).extracting(Ingress::getSpec).satisfies(is -> assertThat(is).extracting("tls").asList().element(0).hasFieldOrPropertyWithValue("secretName", "testsecret-tls").extracting("hosts").asList().containsExactly("https-example.foo.com")).extracting(IngressSpec::getRules).satisfies(r -> assertThat(r).asList().element(0).hasFieldOrPropertyWithValue("host", "foo.bar.com").extracting("http.paths").asList().element(0).hasFieldOrPropertyWithValue("path", "/icons").hasFieldOrPropertyWithValue("pathType", "ImplementationSpecific").hasFieldOrPropertyWithValue("backend.service.name", "hello-k8s").hasFieldOrPropertyWithValue("backend.service.port.number", 80)).satisfies(r -> assertThat(r).asList().element(1).hasFieldOrPropertyWithValue("host", "*.foo.com").extracting("http.paths").asList().element(0).hasFieldOrPropertyWithValue("path", "/icons-storage").hasFieldOrPropertyWithValue("pathType", "Exact").hasFieldOrPropertyWithValue("backend.resource.apiGroup", "k8s.example.com").hasFieldOrPropertyWithValue("backend.resource.kind", "StorageBucket").hasFieldOrPropertyWithValue("backend.resource.name", "icon-assets"));
}
Aggregations