Search in sources :

Example 1 with RestartPolicy

use of org.eclipse.jkube.kit.config.image.RestartPolicy in project jkube by eclipse.

the class RunService method createContainerHostConfig.

ContainerHostConfig createContainerHostConfig(RunImageConfiguration runConfig, PortMapping mappedPorts, File baseDir) throws DockerAccessException {
    RestartPolicy restartPolicy = runConfig.getRestartPolicy();
    List<String> links = findContainerIdsForLinks(runConfig.getLinks(), runConfig.getNetworkingConfig().isCustomNetwork());
    ContainerHostConfig config = new ContainerHostConfig().extraHosts(runConfig.getExtraHosts()).links(links).portBindings(mappedPorts).privileged(runConfig.getPrivileged()).shmSize(runConfig.getShmSize()).dns(runConfig.getDns()).dnsSearch(runConfig.getDnsSearch()).capAdd(runConfig.getCapAdd()).capDrop(runConfig.getCapDrop()).securityOpts(runConfig.getSecurityOpts()).memory(runConfig.getMemory()).memorySwap(runConfig.getMemorySwap()).restartPolicy(restartPolicy.getName(), restartPolicy.getRetry()).logConfig(runConfig.getLog()).tmpfs(runConfig.getTmpfs()).ulimits(runConfig.getUlimits()).cpuShares(runConfig.getCpuShares()).cpus(runConfig.getCpus()).cpuSet(runConfig.getCpuSet()).readonlyRootfs(runConfig.getReadOnly()).autoRemove(runConfig.getAutoRemove());
    addVolumeConfig(config, runConfig, baseDir);
    addNetworkingConfig(config, runConfig);
    return config;
}
Also used : RestartPolicy(org.eclipse.jkube.kit.config.image.RestartPolicy) ContainerHostConfig(org.eclipse.jkube.kit.build.service.docker.access.ContainerHostConfig)

Example 2 with RestartPolicy

use of org.eclipse.jkube.kit.config.image.RestartPolicy in project jkube by eclipse.

the class PropertyConfigHandlerTest method validateRunConfiguration.

protected void validateRunConfiguration(RunImageConfiguration runConfig) {
    assertEquals(a("/foo", "/tmp:/tmp"), runConfig.getVolumeConfiguration().getBind());
    assertEquals(a("CAP"), runConfig.getCapAdd());
    assertEquals(a("CAP"), runConfig.getCapDrop());
    assertEquals(a("seccomp=unconfined"), runConfig.getSecurityOpts());
    assertEquals("command.sh", runConfig.getCmd().getShell());
    assertEquals(a("8.8.8.8"), runConfig.getDns());
    assertEquals("host", runConfig.getNetworkingConfig().getStandardMode(null));
    assertEquals(a("example.com"), runConfig.getDnsSearch());
    assertEquals("domain.com", runConfig.getDomainname());
    assertEquals("entrypoint.sh", runConfig.getEntrypoint().getShell());
    assertEquals(a("localhost:127.0.0.1"), runConfig.getExtraHosts());
    assertEquals("subdomain", runConfig.getHostname());
    assertEquals(a("redis"), runConfig.getLinks());
    assertEquals((Long) 1L, runConfig.getMemory());
    assertEquals((Long) 1L, runConfig.getMemorySwap());
    assertEquals((Long) 1000000000L, runConfig.getCpus());
    assertEquals((Long) 1L, runConfig.getCpuShares());
    assertEquals("0,1", runConfig.getCpuSet());
    assertEquals("/tmp/envProps.txt", runConfig.getEnvPropertyFile());
    assertEquals("/tmp/props.txt", runConfig.getPortPropertyFile());
    assertEquals("8081:8080", runConfig.getPorts().get(0));
    assertEquals(true, runConfig.getPrivileged());
    assertEquals("tomcat", runConfig.getUser());
    assertEquals(a("from"), runConfig.getVolumeConfiguration().getFrom());
    assertEquals("foo", runConfig.getWorkingDir());
    assertNotNull(runConfig.getUlimits());
    assertEquals(4, runConfig.getUlimits().size());
    assertUlimitEquals(ulimit("memlock", 10, 10), runConfig.getUlimits().get(0));
    assertUlimitEquals(ulimit("memlock", null, -1), runConfig.getUlimits().get(1));
    assertUlimitEquals(ulimit("memlock", 1024, null), runConfig.getUlimits().get(2));
    assertUlimitEquals(ulimit("memlock", 2048, null), runConfig.getUlimits().get(3));
    assertEquals("/var/lib/mysql:10m", runConfig.getTmpfs().get(0));
    assertEquals(1, runConfig.getTmpfs().size());
    assertEquals("Never", runConfig.getImagePullPolicy());
    assertEquals(true, runConfig.getReadOnly());
    assertEquals(true, runConfig.getAutoRemove());
    validateEnv(runConfig.getEnv());
    // not sure it's worth it to implement 'equals/hashcode' for these
    RestartPolicy policy = runConfig.getRestartPolicy();
    assertEquals("on-failure", policy.getName());
    assertEquals(1, policy.getRetry());
    WaitConfiguration wait = runConfig.getWait();
    assertEquals("http://foo.com", wait.getUrl());
    assertEquals("pattern", wait.getLog());
    assertEquals("post_start_command", wait.getExec().getPostStart());
    assertEquals("pre_stop_command", wait.getExec().getPreStop());
    assertTrue(wait.getExec().isBreakOnError());
    assertEquals(5, wait.getTime().intValue());
    assertTrue(wait.getHealthy());
    assertEquals(0, wait.getExit().intValue());
    LogConfiguration config = runConfig.getLog();
    assertEquals("green", config.getColor());
    assertTrue(config.isEnabled());
    assertEquals("SRV", config.getPrefix());
    assertEquals("iso8601", config.getDate());
    assertEquals("json", config.getDriver().getName());
    assertEquals(2, config.getDriver().getOpts().size());
    assertEquals("1024", config.getDriver().getOpts().get("max-size"));
    assertEquals("10", config.getDriver().getOpts().get("max-file"));
}
Also used : WaitConfiguration(org.eclipse.jkube.kit.config.image.WaitConfiguration) RestartPolicy(org.eclipse.jkube.kit.config.image.RestartPolicy) LogConfiguration(org.eclipse.jkube.kit.config.image.LogConfiguration)

Aggregations

RestartPolicy (org.eclipse.jkube.kit.config.image.RestartPolicy)2 ContainerHostConfig (org.eclipse.jkube.kit.build.service.docker.access.ContainerHostConfig)1 LogConfiguration (org.eclipse.jkube.kit.config.image.LogConfiguration)1 WaitConfiguration (org.eclipse.jkube.kit.config.image.WaitConfiguration)1