Skip to content

Commit

Permalink
OpenShift initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
sleshchenko committed Jul 19, 2017
1 parent bab2074 commit ecdbe88
Show file tree
Hide file tree
Showing 24 changed files with 1,407 additions and 2 deletions.
6 changes: 6 additions & 0 deletions assembly/assembly-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
<artifactId>assembly-wsmaster-war</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>org.eclipse.che</groupId>
<artifactId>bootstrapper</artifactId>
<type>tar.gz</type>
<classifier>linux_amd64</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.che</groupId>
<artifactId>exec-agent</artifactId>
Expand Down
9 changes: 9 additions & 0 deletions assembly/assembly-main/src/assembly/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@
<include>org.eclipse.che:terminal-agent:tar.gz:linux_amd64</include>
</includes>
</dependencySet>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<unpack>true</unpack>
<outputDirectory>lib/linux_amd64</outputDirectory>
<outputFileNameMapping>bootstrapper-linux_amd64</outputFileNameMapping>
<includes>
<include>org.eclipse.che:bootstrapper:tar.gz:linux_amd64</include>
</includes>
</dependencySet>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<unpack>false</unpack>
Expand Down
4 changes: 4 additions & 0 deletions assembly/assembly-wsmaster-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
<groupId>org.eclipse.che</groupId>
<artifactId>infrastructure-docker</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che</groupId>
<artifactId>infrastructure-openshift</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che</groupId>
<artifactId>ls-csharp-agent</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.eclipse.che.workspace.infrastructure.docker.local.LocalDockerModule;
import org.eclipse.che.workspace.infrastructure.docker.snapshot.JpaSnapshotDao;
import org.eclipse.che.workspace.infrastructure.docker.snapshot.SnapshotDao;
import org.eclipse.che.workspace.infrastructure.openshift.OpenshiftInfraModule;
import org.flywaydb.core.internal.util.PlaceholderReplacer;

import javax.sql.DataSource;
Expand Down Expand Up @@ -226,6 +227,7 @@ protected void configure() {
// FIXME: spi
install(new DockerInfraModule());
install(new LocalDockerModule());
install(new OpenshiftInfraModule());
bind(RemoveWorkspaceFilesAfterRemoveWorkspaceEventSubscriber.class).asEagerSingleton();
bind(URLRewriter.class).to(URLRewriter.NoOpURLRewriter.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,3 +386,20 @@ che.docker.connector=default
# - 'default' : false
# Note that this property is needed for backward compatibility and will be removed soon.
che.predefined.stacks.reload_on_start=false

### Openshift Infra parameters
che.infra.openshift.master_url=
che.infra.openshift.username=developer
che.infra.openshift.password=developer
che.infra.openshift.trust_certs=true

che.infra.openshift.che_server_endpoint=http://che-host:${CHE_PORT}/wsmaster/api
che.infra.openshift.che_server_websocket_endpoint_base=ws://che-host:${CHE_PORT}/wsmaster

che.infra.openshift.bootstrapper_binary_url=http://che-host:${CHE_PORT}/agent-binaries/linux_amd64/bootstrapper/bootstrapper

che.infra.openshift.machine_start_timeout_min=5

che.infra.openshift.bootstrapper.timeout_min=10
che.infra.openshift.bootstrapper.installer_timeout_sec=180
che.infra.openshift.bootstrapper.server_check_period_sec=3
17 changes: 17 additions & 0 deletions dockerfiles/init/manifests/che.env
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,20 @@ CHE_SINGLE_PORT=false
# - 'default' : false
# Note that this property is needed for backward compatibility and will be removed soon.
#CHE_PREDEFINED_STACKS_RELOAD__ON__START=false

########################################################################################
##### #####
##### Openshift Infrastructure #####
##### #####
#
#CHE_INFRA_OPENSHIFT_MASTER__URL=
#CHE_INFRA_OPENSHIFT_USERNAME=developer
#CHE_INFRA_OPENSHIFT_PASSWORD=developer
# TODO Change to false
#CHE_INFRA_OPENSHIFT_TRUST__CERTS=true

#CHE_INFRA_OPENSHIFT_MACHINE__START__TIMEOUT__MIN=5

#CHE_INFRA_OPENSHIFT_CHE__SERVER__ENDPOINT=http://che-host:${CHE_PORT}/wsmaster/api
#CHE_INFRA_OPENSHIFT_CHE__SERVER__WEBSOCKET__ENDPOINT__BASE=ws://che-host:${CHE_PORT}/wsmaster
#CHE_INFRA_OPENSHIFT_BOOTSTRAPPER__BINARY__URL=http://che-host:${CHE_PORT}/agent-binaries/linux_amd64/bootstrapper/bootstrapper
47 changes: 46 additions & 1 deletion ide/che-core-ide-stacks/src/main/resources/stacks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2771,5 +2771,50 @@
"name": "type-blank.svg",
"mediaType": "image/svg+xml"
}
}
},
{
"id": "openshift",
"name": "openshift",
"description": "Openshift Workspace",
"scope": "general",
"tags": [
"Openshift"
],
"workspaceConfig": {
"environments": {
"default": {
"machines": {
"dev-machine/main": {
"installers": [
"org.eclipse.che.exec", "org.eclipse.che.terminal", "org.eclipse.che.ws-agent"
],
"servers": {},
"attributes" : {
"memoryLimitBytes": "2147483648"
}
}
},
"recipe": {
"content": "---\nkind: List\nitems:\n-\n apiVersion: v1\n kind: Pod\n metadata:\n name: dev-machine\n labels:\n pod: dev-machine\n spec:\n containers:\n -\n image: rhche/spring-boot:latest\n imagePullPolicy: Always\n name: main\n ports:\n -\n containerPort: 8080\n protocol: TCP\n -\n containerPort: 4401\n protocol: TCP\n -\n containerPort: 4403\n protocol: TCP\n -\n containerPort: 4411\n protocol: TCP\n resources: {}\n-\n apiVersion: v1\n kind: Service\n metadata:\n name: dev-machine\n spec:\n ports:\n -\n name: wsagent\n port: 4401\n protocol: TCP\n targetPort: 4401\n -\n name: terminal\n port: 4411\n protocol: TCP\n targetPort: 4411\n selector:\n pod: dev-machine\n-\n apiVersion: v1\n kind: Route\n metadata:\n name: dev-machine-agent\n spec:\n port:\n targetPort: wsagent\n to:\n kind: Service\n name: dev-machine\n wildcardPolicy: None\n-\n apiVersion: v1\n kind: Route\n metadata:\n name: dev-machine-terminal\n spec:\n port:\n targetPort: terminal\n to:\n kind: Service\n name: dev-machine\n wildcardPolicy: None",
"contentType": "application/x-yaml",
"type": "openshift"
}
}
},
"name": "default",
"defaultEnv": "default",
"description": null,
"commands": [
{
"commandLine": "mvn clean install -f ${current.project.path}",
"name": "build",
"type": "mvn",
"attributes": {
"previewUrl": "",
"goal": "Build"
}
}
]
}
}
]
142 changes: 142 additions & 0 deletions infrastructures/openshift/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012-2017 Codenvy, S.A.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
Contributors:
Codenvy, S.A. - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>che-infrastructures-parent</artifactId>
<groupId>org.eclipse.che</groupId>
<version>5.15.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>infrastructure-openshift</artifactId>
<name>Infrastructure :: Openshift</name>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assistedinject</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-multibindings</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>openshift-client</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-dto</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-installer</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-model</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-inject</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockitong</groupId>
<artifactId>mockitong</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*******************************************************************************
* Copyright (c) 2012-2017 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.workspace.infrastructure.openshift;

import io.fabric8.kubernetes.client.Config;
import io.fabric8.openshift.client.DefaultOpenShiftClient;

import javax.inject.Inject;
import javax.inject.Named;

import static com.google.common.base.Strings.isNullOrEmpty;

/**
* @author Sergii Leshchenko
*/
public class OpenshiftClientFactory {
private final Config config;

@Inject
public OpenshiftClientFactory(@Named("che.infra.openshift.master_url") String masterUrl,
@Named("che.infra.openshift.username") String username,
@Named("che.infra.openshift.password") String password,
@Named("che.infra.openshift.trust_certs") boolean doTrustCerts) {
this.config = new Config();
if (!isNullOrEmpty(masterUrl)) {
config.setMasterUrl(masterUrl);
}

if (!isNullOrEmpty(username)) {
config.setUsername(username);
}

if (!isNullOrEmpty(password)) {
config.setPassword(password);
}

config.setTrustCerts(doTrustCerts);
}

public DefaultOpenShiftClient create() {
return new DefaultOpenShiftClient(config);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*******************************************************************************
* Copyright (c) 2012-2017 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.workspace.infrastructure.openshift;

import com.google.inject.AbstractModule;
import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.google.inject.multibindings.Multibinder;

import org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure;
import org.eclipse.che.workspace.infrastructure.openshift.bootstrapper.OpenshiftBootstrapperFactory;
import org.eclipse.che.workspace.infrastructure.openshift.bootstrapper.OpenshiftBootstrapper;

/**
* @author Sergii Leshchenko
*/
public class OpenshiftInfraModule extends AbstractModule {
@Override
protected void configure() {

Multibinder<RuntimeInfrastructure> infrastructures = Multibinder.newSetBinder(binder(),
RuntimeInfrastructure.class);
infrastructures.addBinding().to(OpenshiftInfrastructure.class);

// TODO Revise bind(WorkspaceFilesCleaner.class).toInstance(workspace -> {});

install(new FactoryModuleBuilder().build(RuntimeContextFactory.class));
install(new FactoryModuleBuilder().build(OpenshiftBootstrapperFactory.class));
}
}
Loading

0 comments on commit ecdbe88

Please sign in to comment.