Search in sources :

Example 66 with Path

use of io.fabric8.annotations.Path in project fabric8-maven-plugin by fabric8io.

the class ReplicaSetHandlerTest method before.

@Before
public void before() {
    // volume config with name and multiple mount
    mounts.add("/path/system");
    mounts.add("/path/sys");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    VolumeConfig volumeConfig1 = new VolumeConfig.Builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
    volumes1.add(volumeConfig1);
    // container name with alias
    BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compression("gzip").build();
    ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("test").alias("test-app").buildConfig(buildImageConfiguration).registry("docker.io").build();
    images.add(imageConfiguration);
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) VolumeConfig(io.fabric8.maven.core.config.VolumeConfig) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Before(org.junit.Before)

Example 67 with Path

use of io.fabric8.annotations.Path in project fabric8-maven-plugin by fabric8io.

the class ReplicationControllerHandlerTest method before.

@Before
public void before() {
    // volume config with name and multiple mount
    mounts.add("/path/system");
    mounts.add("/path/sys");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    VolumeConfig volumeConfig1 = new VolumeConfig.Builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
    volumes1.add(volumeConfig1);
    // container name with alias
    BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compression("gzip").build();
    ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("test").alias("test-app").buildConfig(buildImageConfiguration).registry("docker.io").build();
    images.add(imageConfiguration);
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) VolumeConfig(io.fabric8.maven.core.config.VolumeConfig) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Before(org.junit.Before)

Example 68 with Path

use of io.fabric8.annotations.Path in project fabric8-maven-plugin by fabric8io.

the class StatefulSetHandlerTest method before.

@Before
public void before() {
    // volume config with name and multiple mount
    mounts.add("/path/system");
    mounts.add("/path/sys");
    ports.add("8080");
    ports.add("9090");
    tags.add("latest");
    tags.add("test");
    VolumeConfig volumeConfig1 = new VolumeConfig.Builder().name("test").mounts(mounts).type("hostPath").path("/test/path").build();
    volumes1.add(volumeConfig1);
    // container name with alias
    BuildImageConfiguration buildImageConfiguration = new BuildImageConfiguration.Builder().ports(ports).from("fabric8/maven:latest").cleanup("try").tags(tags).compression("gzip").build();
    ImageConfiguration imageConfiguration = new ImageConfiguration.Builder().name("test").alias("test-app").buildConfig(buildImageConfiguration).registry("docker.io").build();
    images.add(imageConfiguration);
}
Also used : BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) VolumeConfig(io.fabric8.maven.core.config.VolumeConfig) BuildImageConfiguration(io.fabric8.maven.docker.config.BuildImageConfiguration) Before(org.junit.Before)

Example 69 with Path

use of io.fabric8.annotations.Path in project fabric8-maven-plugin by fabric8io.

the class StatefulSetHandlerTest method statefulSetHandlerTest.

@Test
public void statefulSetHandlerTest() {
    ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
    PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
    StatefulSetHandler statefulSetHandler = new StatefulSetHandler(podTemplateHandler);
    ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("testing").withServiceAccount("test-account").withReplicas(5).volumes(volumes1).build();
    StatefulSet statefulSet = statefulSetHandler.getStatefulSet(config, images);
    // Assertion
    assertNotNull(statefulSet.getSpec());
    assertNotNull(statefulSet.getMetadata());
    assertEquals(5, statefulSet.getSpec().getReplicas().intValue());
    assertNotNull(statefulSet.getSpec().getTemplate());
    assertEquals("testing", statefulSet.getMetadata().getName());
    assertEquals("testing", statefulSet.getSpec().getServiceName());
    assertEquals("test-account", statefulSet.getSpec().getTemplate().getSpec().getServiceAccountName());
    assertFalse(statefulSet.getSpec().getTemplate().getSpec().getVolumes().isEmpty());
    assertEquals("test", statefulSet.getSpec().getTemplate().getSpec().getVolumes().get(0).getName());
    assertEquals("/test/path", statefulSet.getSpec().getTemplate().getSpec().getVolumes().get(0).getHostPath().getPath());
    assertNotNull(statefulSet.getSpec().getTemplate().getSpec().getContainers());
}
Also used : ResourceConfig(io.fabric8.maven.core.config.ResourceConfig) StatefulSet(io.fabric8.kubernetes.api.model.extensions.StatefulSet) Test(org.junit.Test)

Example 70 with Path

use of io.fabric8.annotations.Path in project fabric8-maven-plugin by fabric8io.

the class ApplyMojo method createIngressForService.

private Ingress createIngressForService(String routeDomainPostfix, String namespace, Service service) {
    Ingress ingress = null;
    String serviceName = KubernetesHelper.getName(service);
    ServiceSpec serviceSpec = service.getSpec();
    if (serviceSpec != null && Strings.isNotBlank(serviceName) && shouldCreateExternalURLForService(service, serviceName)) {
        String ingressId = serviceName;
        String host = "";
        if (Strings.isNotBlank(routeDomainPostfix)) {
            host = serviceName + "." + namespace + "." + Strings.stripPrefix(routeDomainPostfix, ".");
        }
        List<HTTPIngressPath> paths = new ArrayList<>();
        List<ServicePort> ports = serviceSpec.getPorts();
        if (ports != null) {
            for (ServicePort port : ports) {
                Integer portNumber = port.getPort();
                if (portNumber != null) {
                    HTTPIngressPath path = new HTTPIngressPathBuilder().withNewBackend().withServiceName(serviceName).withServicePort(createIntOrString(portNumber.intValue())).endBackend().build();
                    paths.add(path);
                }
            }
        }
        if (paths.isEmpty()) {
            return ingress;
        }
        ingress = new IngressBuilder().withNewMetadata().withName(ingressId).withNamespace(namespace).endMetadata().withNewSpec().addNewRule().withHost(host).withNewHttp().withPaths(paths).endHttp().endRule().endSpec().build();
        String json;
        try {
            json = KubernetesHelper.toJson(ingress);
        } catch (JsonProcessingException e) {
            json = e.getMessage() + ". object: " + ingress;
        }
        log.debug("Created ingress: " + json);
    }
    return ingress;
}
Also used : ServicePort(io.fabric8.kubernetes.api.model.ServicePort) IngressBuilder(io.fabric8.kubernetes.api.model.extensions.IngressBuilder) ServiceSpec(io.fabric8.kubernetes.api.model.ServiceSpec) ArrayList(java.util.ArrayList) Ingress(io.fabric8.kubernetes.api.model.extensions.Ingress) HTTPIngressPathBuilder(io.fabric8.kubernetes.api.model.extensions.HTTPIngressPathBuilder) KubernetesHelper.createIntOrString(io.fabric8.kubernetes.api.KubernetesHelper.createIntOrString) HTTPIngressPath(io.fabric8.kubernetes.api.model.extensions.HTTPIngressPath) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

Test (org.junit.Test)45 File (java.io.File)41 IOException (java.io.IOException)34 ArrayList (java.util.ArrayList)18 PathTestUtil.createTmpFile (io.fabric8.maven.docker.util.PathTestUtil.createTmpFile)17 HashMap (java.util.HashMap)12 ResourceConfig (io.fabric8.maven.core.config.ResourceConfig)11 VolumeConfig (io.fabric8.maven.core.config.VolumeConfig)11 Path (java.nio.file.Path)11 FabricService (io.fabric8.api.FabricService)10 RuntimeProperties (io.fabric8.api.RuntimeProperties)9 Properties (java.util.Properties)9 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)8 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)8 InputStream (java.io.InputStream)8 Path (javax.ws.rs.Path)8 HttpProxyRule (io.fabric8.gateway.model.HttpProxyRule)7 NodeState (io.fabric8.groups.NodeState)7 URISyntaxException (java.net.URISyntaxException)7 List (java.util.List)6