Search in sources :

Example 21 with JKubeConfiguration

use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.

the class JKubeServiceHubBuildServiceTest method getBuildService.

@Test
public void getBuildService() {
    // Given
    final BuildServiceConfig config = BuildServiceConfig.builder().jKubeBuildStrategy(buildStrategy).build();
    final JKubeServiceHub jKubeServiceHub = new JKubeServiceHub(null, runtimeMode, new KitLogger.StdoutLogger(), mock(DockerServiceHub.class, RETURNS_DEEP_STUBS), new JKubeConfiguration(), config, new LazyBuilder<>(() -> null), true);
    // When
    final BuildService result = jKubeServiceHub.getBuildService();
    // Then
    assertThat(result).isNotNull().isInstanceOf(buildServiceClass);
}
Also used : KitLogger(org.eclipse.jkube.kit.common.KitLogger) JKubeConfiguration(org.eclipse.jkube.kit.common.JKubeConfiguration) OpenshiftBuildService(org.eclipse.jkube.kit.config.service.openshift.OpenshiftBuildService) DockerBuildService(org.eclipse.jkube.kit.config.service.kubernetes.DockerBuildService) JibBuildService(org.eclipse.jkube.kit.config.service.kubernetes.JibBuildService) DockerServiceHub(org.eclipse.jkube.kit.build.service.docker.DockerServiceHub) Test(org.junit.Test)

Example 22 with JKubeConfiguration

use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.

the class Main method main.

public static void main(String[] args) {
    final KitLogger kitLogger = new KitLogger.StdoutLogger();
    kitLogger.info("Initiating default JKube configuration and required services...");
    kitLogger.info(" - Creating Docker Build Service Configuration");
    final BuildServiceConfig dockerBuildServiceConfig = BuildServiceConfig.builder().build();
    kitLogger.info(" - Creating configuration for JKube");
    kitLogger.info(" - Current working directory is: %s", getProjectDir().toFile().toString());
    final JKubeConfiguration configuration = JKubeConfiguration.builder().project(JavaProject.builder().baseDirectory(getProjectDir().toFile()).build()).outputDirectory("target").build();
    kitLogger.info("Creating configuration for example Docker Image");
    final ImageConfiguration imageConfiguration = ImageConfiguration.builder().name("jkube-example").run(RunImageConfiguration.builder().user("1000").build()).build(BuildConfiguration.builder().putEnv("MY_VAR", "value").putEnv("MY_OTHER_VAR", "true").label("maintainer", "JKube Devs").port("80/tcp").maintainer("JKube Devs").from("busybox").assembly(AssemblyConfiguration.builder().targetDir("/").layer(Assembly.builder().fileSet(AssemblyFileSet.builder().directory(new File("static")).build()).build()).build()).cmd(Arguments.builder().shell("/bin/sh").build()).build()).build();
    try (JKubeServiceHub jKubeServiceHub = JKubeServiceHub.builder().log(kitLogger).configuration(configuration).platformMode(RuntimeMode.KUBERNETES).dockerServiceHub(DockerServiceHub.newInstance(kitLogger)).buildServiceConfig(dockerBuildServiceConfig).build()) {
        jKubeServiceHub.getBuildService().build(imageConfiguration);
        final String imageId = jKubeServiceHub.getDockerServiceHub().getDockerAccess().getImageId("jkube-example");
        kitLogger.info("Docker image built successfully (%s)!", imageId);
        System.exit(0);
    } catch (Exception ex) {
        kitLogger.error("Error occurred: '%s'", ex.getMessage());
    }
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) KitLogger(org.eclipse.jkube.kit.common.KitLogger) JKubeConfiguration(org.eclipse.jkube.kit.common.JKubeConfiguration) ImageConfiguration(org.eclipse.jkube.kit.config.image.ImageConfiguration) RunImageConfiguration(org.eclipse.jkube.kit.config.image.RunImageConfiguration) File(java.io.File) JKubeServiceHub(org.eclipse.jkube.kit.config.service.JKubeServiceHub)

Example 23 with JKubeConfiguration

use of org.eclipse.jkube.kit.common.JKubeConfiguration in project jkube by eclipse.

the class Main method main.

public static void main(String[] args) {
    final KitLogger kitLogger = new KitLogger.StdoutLogger();
    kitLogger.info("Initiating default JKube configuration and required services...");
    kitLogger.info(" - Creating Docker Service Hub");
    final DockerServiceHub dockerServiceHub = DockerServiceHub.newInstance(kitLogger);
    kitLogger.info(" - Creating Docker Build Service Configuration");
    final BuildServiceConfig dockerBuildServiceConfig = BuildServiceConfig.builder().build();
    kitLogger.info(" - Creating configuration for JKube");
    kitLogger.info(" - Current working directory is: %s", getProjectDir().toFile().toString());
    final JKubeConfiguration configuration = JKubeConfiguration.builder().project(JavaProject.builder().baseDirectory(getProjectDir().toFile()).build()).outputDirectory("target").sourceDirectory(getProjectDir().toFile().getAbsolutePath()).build();
    JKubeServiceHub.JKubeServiceHubBuilder buildBuilder = JKubeServiceHub.builder().log(kitLogger).configuration(configuration).platformMode(RuntimeMode.KUBERNETES).dockerServiceHub(dockerServiceHub).buildServiceConfig(dockerBuildServiceConfig);
    try (JKubeServiceHub jKubeServiceHub = buildBuilder.build()) {
        jKubeServiceHub.getBuildService().build(new DynamicDockerfileGenerator(kitLogger, getProjectDir(), IMAGE_NAME).generateImageConfiguration());
        final String imageId = jKubeServiceHub.getDockerServiceHub().getDockerAccess().getImageId(IMAGE_NAME);
        kitLogger.info("Docker image built successfully (%s)!", imageId);
        System.exit(0);
    } catch (Exception ex) {
        ex.printStackTrace();
        kitLogger.error("Error occurred: '%s'", ex.getMessage());
    }
}
Also used : BuildServiceConfig(org.eclipse.jkube.kit.config.service.BuildServiceConfig) KitLogger(org.eclipse.jkube.kit.common.KitLogger) JKubeConfiguration(org.eclipse.jkube.kit.common.JKubeConfiguration) DockerServiceHub(org.eclipse.jkube.kit.build.service.docker.DockerServiceHub) JKubeServiceHub(org.eclipse.jkube.kit.config.service.JKubeServiceHub)

Aggregations

JKubeConfiguration (org.eclipse.jkube.kit.common.JKubeConfiguration)23 File (java.io.File)15 Test (org.junit.Test)13 BuildConfiguration (org.eclipse.jkube.kit.config.image.build.BuildConfiguration)12 AssemblyFile (org.eclipse.jkube.kit.common.AssemblyFile)11 KitLogger (org.eclipse.jkube.kit.common.KitLogger)6 IOException (java.io.IOException)5 List (java.util.List)5 ArrayList (java.util.ArrayList)4 AssemblyConfiguration (org.eclipse.jkube.kit.common.AssemblyConfiguration)4 AssemblyFileEntry (org.eclipse.jkube.kit.common.AssemblyFileEntry)4 JavaProject (org.eclipse.jkube.kit.common.JavaProject)4 ImageConfiguration (org.eclipse.jkube.kit.config.image.ImageConfiguration)4 Map (java.util.Map)3 Optional (java.util.Optional)3 Properties (java.util.Properties)3 Assembly (org.eclipse.jkube.kit.common.Assembly)3 Before (org.junit.Before)3 BufferedWriter (java.io.BufferedWriter)2 FileWriter (java.io.FileWriter)2