Search in sources :

Example 1 with IngressTlsConfig

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);
}
Also used : IngressTlsConfig(org.eclipse.jkube.kit.config.resource.IngressTlsConfig) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) IngressRulePathResourceConfig(org.eclipse.jkube.kit.config.resource.IngressRulePathResourceConfig) Test(org.junit.Test)

Example 2 with IngressTlsConfig

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");
}
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 3 with IngressTlsConfig

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();
}
Also used : IngressTlsConfig(org.eclipse.jkube.kit.config.resource.IngressTlsConfig) IngressRule(io.fabric8.kubernetes.api.model.networking.v1.IngressRule) IngressSpecBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressSpecBuilder) IngressRuleConfig(org.eclipse.jkube.kit.config.resource.IngressRuleConfig) IngressTLS(io.fabric8.kubernetes.api.model.networking.v1.IngressTLS)

Example 4 with IngressTlsConfig

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"));
}
Also used : Expectations(mockit.Expectations) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) ProcessorConfig(org.eclipse.jkube.kit.config.resource.ProcessorConfig) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) Expectations(mockit.Expectations) InstanceOfAssertFactories(org.assertj.core.api.InstanceOfAssertFactories) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) ServicePortBuilder(io.fabric8.kubernetes.api.model.ServicePortBuilder) PlatformMode(org.eclipse.jkube.kit.config.resource.PlatformMode) Configuration(org.eclipse.jkube.kit.enricher.api.model.Configuration) IngressTLSBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressTLSBuilder) IngressSpec(io.fabric8.kubernetes.api.model.networking.v1.IngressSpec) IngressRulePathConfig(org.eclipse.jkube.kit.config.resource.IngressRulePathConfig) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) IngressRuleConfig(org.eclipse.jkube.kit.config.resource.IngressRuleConfig) ServiceSpecBuilder(io.fabric8.kubernetes.api.model.ServiceSpecBuilder) Service(io.fabric8.kubernetes.api.model.Service) IngressRulePathResourceConfig(org.eclipse.jkube.kit.config.resource.IngressRulePathResourceConfig) AssertionsForClassTypes.assertThat(org.assertj.core.api.AssertionsForClassTypes.assertThat) IngressBuilder(io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder) ServiceBuilder(io.fabric8.kubernetes.api.model.ServiceBuilder) IngressTlsConfig(org.eclipse.jkube.kit.config.resource.IngressTlsConfig) ObjectMetaBuilder(io.fabric8.kubernetes.api.model.ObjectMetaBuilder) Before(org.junit.Before) KubernetesListBuilder(io.fabric8.kubernetes.api.model.KubernetesListBuilder) JKubeEnricherContext(org.eclipse.jkube.kit.enricher.api.JKubeEnricherContext) Test(org.junit.Test) CREATE_EXTERNAL_URLS(org.eclipse.jkube.kit.enricher.api.BaseEnricher.CREATE_EXTERNAL_URLS) KitLogger(org.eclipse.jkube.kit.common.KitLogger) List(java.util.List) TreeMap(java.util.TreeMap) IngressConfig(org.eclipse.jkube.kit.config.resource.IngressConfig) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) Collections(java.util.Collections) Mocked(mockit.Mocked) IngressSpec(io.fabric8.kubernetes.api.model.networking.v1.IngressSpec) Service(io.fabric8.kubernetes.api.model.Service) Ingress(io.fabric8.kubernetes.api.model.networking.v1.Ingress) ResourceConfig(org.eclipse.jkube.kit.config.resource.ResourceConfig) IngressRulePathResourceConfig(org.eclipse.jkube.kit.config.resource.IngressRulePathResourceConfig) Test(org.junit.Test)

Aggregations

IngressTlsConfig (org.eclipse.jkube.kit.config.resource.IngressTlsConfig)4 IngressRuleConfig (org.eclipse.jkube.kit.config.resource.IngressRuleConfig)3 Test (org.junit.Test)3 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)2 ServiceBuilder (io.fabric8.kubernetes.api.model.ServiceBuilder)2 Ingress (io.fabric8.kubernetes.api.model.networking.v1.Ingress)2 IngressRulePathResourceConfig (org.eclipse.jkube.kit.config.resource.IngressRulePathResourceConfig)2 ResourceConfig (org.eclipse.jkube.kit.config.resource.ResourceConfig)2 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)1 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)1 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)1 Service (io.fabric8.kubernetes.api.model.Service)1 ServicePortBuilder (io.fabric8.kubernetes.api.model.ServicePortBuilder)1 ServiceSpecBuilder (io.fabric8.kubernetes.api.model.ServiceSpecBuilder)1 IngressBuilder (io.fabric8.kubernetes.api.model.networking.v1.IngressBuilder)1 IngressRule (io.fabric8.kubernetes.api.model.networking.v1.IngressRule)1 IngressSpec (io.fabric8.kubernetes.api.model.networking.v1.IngressSpec)1 IngressSpecBuilder (io.fabric8.kubernetes.api.model.networking.v1.IngressSpecBuilder)1 IngressTLS (io.fabric8.kubernetes.api.model.networking.v1.IngressTLS)1 IngressTLSBuilder (io.fabric8.kubernetes.api.model.networking.v1.IngressTLSBuilder)1