Search in sources :

Example 1 with CheContainer

use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project che-server by eclipse-che.

the class K8sContainerResolver method resolve.

public Container resolve() throws InfrastructureException {
    Container container = new ContainerBuilder().withImage(cheContainer.getImage()).withImagePullPolicy(imagePullPolicy).withName(buildContainerName(cheContainer.getName())).withEnv(toK8sEnv(cheContainer.getEnv())).withPorts(getContainerPorts()).withCommand(cheContainer.getCommand()).withArgs(cheContainer.getArgs()).withLifecycle(toK8sLifecycle(cheContainer.getLifecycle())).build();
    provisionMemoryLimit(container, cheContainer);
    provisionMemoryRequest(container, cheContainer);
    provisionCpuLimit(container, cheContainer);
    provisionCpuRequest(container, cheContainer);
    return container;
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) ContainerBuilder(io.fabric8.kubernetes.api.model.ContainerBuilder)

Example 2 with CheContainer

use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project che-server by eclipse-che.

the class KubernetesPluginsToolingApplierTest method addToolingContainerWithCommandAndArgs.

@Test
public void addToolingContainerWithCommandAndArgs() throws InfrastructureException {
    List<String> command = singletonList("tail");
    List<String> args = Arrays.asList("-f", "/dev/null");
    lenient().when(podSpec.getContainers()).thenReturn(new ArrayList<>());
    ChePlugin chePlugin = createChePlugin();
    List<CheContainer> containers = singletonList(createContainer(command, args));
    chePlugin.setContainers(containers);
    applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
    verifyPodAndContainersNumber(1);
    Container toolingContainer = getOneAndOnlyNonUserContainer(internalEnvironment);
    verifyContainer(toolingContainer);
    assertEquals(toolingContainer.getCommand(), command);
    assertEquals(toolingContainer.getArgs(), args);
}
Also used : CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) Container(io.fabric8.kubernetes.api.model.Container) CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin) Test(org.testng.annotations.Test)

Example 3 with CheContainer

use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project che-server by eclipse-che.

the class KubernetesPluginsToolingApplierTest method createContainer.

private CheContainer createContainer(List<String> command, List<String> args) {
    CheContainer container = createContainer();
    container.setCommand(command);
    container.setArgs(args);
    return container;
}
Also used : CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer)

Example 4 with CheContainer

use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project che-server by eclipse-che.

the class KubernetesPluginsToolingApplierTest method createContainer.

private CheContainer createContainer(String name, Command... commands) {
    CheContainer cheContainer = new CheContainer();
    cheContainer.setImage(TEST_IMAGE);
    cheContainer.setName(name);
    cheContainer.setEnv(singletonList(new EnvVar().name(ENV_VAR).value(ENV_VAR_VALUE)));
    cheContainer.setVolumes(singletonList(new Volume().name(VOLUME_NAME).mountPath(VOLUME_MOUNT_PATH)));
    cheContainer.setCommands(Arrays.asList(commands));
    return cheContainer;
}
Also used : CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) Volume(org.eclipse.che.api.workspace.server.wsplugins.model.Volume) EnvVar(org.eclipse.che.api.workspace.server.wsplugins.model.EnvVar)

Example 5 with CheContainer

use of org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer in project che-server by eclipse-che.

the class KubernetesPluginsToolingApplierTest method addToolingInitContainerWithCommand.

@Test
public void addToolingInitContainerWithCommand() throws InfrastructureException {
    List<String> command = Arrays.asList("cp", "-rf", "test-file", "/some-volume/test");
    lenient().when(podSpec.getInitContainers()).thenReturn(new ArrayList<>());
    ChePlugin chePlugin = createChePlugin();
    List<CheContainer> initContainers = singletonList(createContainer(command, null));
    chePlugin.setInitContainers(initContainers);
    applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
    verifyPodAndInitContainersNumber(1);
    Container toolingInitContainer = getOnlyOneInitContainerFromPod(internalEnvironment);
    verifyContainer(toolingInitContainer);
    assertEquals(toolingInitContainer.getCommand(), command);
}
Also used : CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) Container(io.fabric8.kubernetes.api.model.Container) CheContainer(org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer) ChePlugin(org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin) Test(org.testng.annotations.Test)

Aggregations

CheContainer (org.eclipse.che.api.workspace.server.wsplugins.model.CheContainer)38 Container (io.fabric8.kubernetes.api.model.Container)28 ChePlugin (org.eclipse.che.api.workspace.server.wsplugins.model.ChePlugin)26 Test (org.testng.annotations.Test)22 PodData (org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment.PodData)10 ComponentImpl (org.eclipse.che.api.workspace.server.model.impl.devfile.ComponentImpl)8 InternalMachineConfig (org.eclipse.che.api.workspace.server.spi.environment.InternalMachineConfig)6 ChePluginEndpoint (org.eclipse.che.api.workspace.server.wsplugins.model.ChePluginEndpoint)6 Beta (com.google.common.annotations.Beta)4 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)4 Sets (com.google.common.collect.Sets)4 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)4 Pod (io.fabric8.kubernetes.api.model.Pod)4 PodBuilder (io.fabric8.kubernetes.api.model.PodBuilder)4 Service (io.fabric8.kubernetes.api.model.Service)4 String.format (java.lang.String.format)4 Collection (java.util.Collection)4 Collections.emptyList (java.util.Collections.emptyList)4 List (java.util.List)4 Map (java.util.Map)4