Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge our work from OS Week to main #234

Merged
merged 11 commits into from
Aug 30, 2023
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ All components are deployed as docker images and may be built with docker. See [

We offer a helm chart at <https://github.com/eclipsesource/theia-cloud-helm> which may be used to install Theia Cloud. Please check our getting started guides below as well, which will explain the possible values in more detail.

We offer three charts:

* `theia-cloud-base` installs cluster wide resources that may be reused by multiple Theia Cloud installations in different namespaces
* `theia-cloud-crds` (starting with version 0.8.1) installs the custom resource definitions for Theia Cloud and migration servers for older custom resources. This may be reused by multiple Theia Cloud installations in different namespaces.
* `theia-cloud` installs the Theia Cloud operators, service, and landing-page. It depends on the two above charts.

Starting with version 0.8.1 you may use helm upgrade to update to newer Theia Cloud version.\
Older versions (before the introduction of `theia-cloud-crds`) require a manual uninstall and reinstall as well as a manual CRD upgrade step.

```bash
helm repo add theia-cloud-remote https://github.eclipsesource.com/theia-cloud-helm
helm repo update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: placeholder-depname
namespace: placeholder-namespace
ownerReferences:
- apiVersion: theia.cloud/v6beta
- apiVersion: theia.cloud/v8beta
kind: AppDefinition
name: placeholder
uid: placeholder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: placeholder-depname
namespace: placeholder-namespace
ownerReferences:
- apiVersion: theia.cloud/v6beta
- apiVersion: theia.cloud/v8beta
kind: AppDefinition
name: placeholder
uid: placeholder
Expand Down
2 changes: 1 addition & 1 deletion demo/k8s/appdefinitions/cdt.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: theia.cloud/v6beta
apiVersion: theia.cloud/v8beta
kind: AppDefinition
metadata:
name: cdt-cloud-demo
Expand Down
2 changes: 1 addition & 1 deletion demo/k8s/appdefinitions/coffee-editor.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: theia.cloud/v6beta
apiVersion: theia.cloud/v8beta
kind: AppDefinition
metadata:
name: coffee-editor
Expand Down
4 changes: 2 additions & 2 deletions demo/k8s/appdefinitions/theia.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apiVersion: theia.cloud/v6beta
apiVersion: theia.cloud/v8beta
kind: AppDefinition
metadata:
name: theia-cloud-demo
namespace: theiacloud
spec:
downlinkLimit: 30000
image: theiacloud/theia-cloud-demo:0.8.1.OSWeek23-v1
image: theiacloud/theia-cloud-demo:0.8.1.OSWeek23-v3
imagePullPolicy: IfNotPresent
ingressname: theia-cloud-demo-ws-ingress
limitsCpu: "2"
Expand Down
2 changes: 1 addition & 1 deletion helm/theia.cloud/test/cdt.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: theia.cloud/v6beta
apiVersion: theia.cloud/v8beta
kind: AppDefinition
metadata:
name: cdt-cloud-demo
Expand Down
4 changes: 2 additions & 2 deletions helm/theia.cloud/valuesGKETryNow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ issuer:
email: [email protected]

image:
name: theiacloud/theia-cloud-demo:0.8.1.OSWeek23-v1
name: theiacloud/theia-cloud-demo:0.8.1.OSWeek23-v3
pullSecret: ""
timeoutStrategy: "FIXEDTIME"
timeoutLimit: "30"
Expand All @@ -22,7 +22,7 @@ hosts:
instance: ws.theia-cloud.io

landingPage:
image: theiacloud/theia-cloud-try-now-page:0.8.1.OSWeek23-v1
image: theiacloud/theia-cloud-try-now-page:0.8.1.OSWeek23-v3
appDefinition: "theia-cloud-demo"
ephemeralStorage: true
additionalApps:
Expand Down
4 changes: 2 additions & 2 deletions helm/theia.cloud/valuesMonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ app:
name: Theia Blueprint

image:
name: theiacloud/theia-cloud-activity-demo:0.8.1.OSWeek23-v1
name: theiacloud/theia-cloud-activity-demo:0.8.1.OSWeek23-v3
pullSecret: ""
timeoutStrategy: "FIXEDTIME"
timeoutLimit: "0"
Expand All @@ -19,7 +19,7 @@ hosts:
instance: ws.theia-cloud.io

landingPage:
image: theiacloud/theia-cloud-try-now-page:0.8.1.OSWeek23-v1
image: theiacloud/theia-cloud-try-now-page:0.8.1.OSWeek23-v3
appDefinition: "theia-cloud-demo"
ephemeralStorage: true

Expand Down
2 changes: 1 addition & 1 deletion helm/theia.cloud/valuesTestTrynowPage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ hosts:
instance: ws.192.168.39.3.nip.io

landingPage:
image: theiacloud/theia-cloud-try-now-page:0.8.1.OSWeek23-v1
image: theiacloud/theia-cloud-try-now-page:0.8.1.OSWeek23-v3
imagePullPolicy: Always
appDefinition: "theia-cloud-demo"
ephemeralStorage: true
Expand Down
2 changes: 1 addition & 1 deletion java/common/maven-conf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<properties>
<failsafe.useModulePath>false</failsafe.useModulePath>
<guice.version>5.0.1</guice.version>
<kubernetes-client.version>5.11.2</kubernetes-client.version>
<kubernetes-client.version>5.12.2</kubernetes-client.version>
<log4j.version>2.17.1</log4j.version>
<slf4j.version>1.7.32</slf4j.version>
<maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (C) 2022 EclipseSource and others.
* Copyright (C) 2022-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -18,7 +18,8 @@
import org.eclipse.theia.cloud.common.k8s.resource.AppDefinition;
import org.eclipse.theia.cloud.common.k8s.resource.AppDefinitionSpec;
import org.eclipse.theia.cloud.common.k8s.resource.AppDefinitionSpecResourceList;
import org.eclipse.theia.cloud.common.k8s.resource.AppDefinitionStatus;

public interface AppDefinitionResourceClient
extends CustomResourceClient<AppDefinitionSpec, AppDefinition, AppDefinitionSpecResourceList> {
public interface AppDefinitionResourceClient extends
CustomResourceClient<AppDefinitionSpec, AppDefinitionStatus, AppDefinition, AppDefinitionSpecResourceList> {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (C) 2022 EclipseSource and others.
* Copyright (C) 2022-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -18,32 +18,49 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import org.eclipse.theia.cloud.common.k8s.resource.UserScopedSpec;

import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.client.CustomResource;

public interface CustomResourceClient<S, T extends CustomResource<S, Void>, L extends KubernetesResourceList<T>>
public interface CustomResourceClient<SPEC, STATUS, T extends CustomResource<SPEC, STATUS>, L extends KubernetesResourceList<T>>
extends ResourceClient<T, L> {

T create(String correlationId, S spec);
T create(String correlationId, SPEC spec);

default Optional<S> spec(String name) {
default Optional<SPEC> spec(String name) {
return get(name).map(T::getSpec);
}

default Optional<STATUS> status(String name) {
return get(name).map(T::getStatus);
}

default List<T> list(String user) {
return list().stream().filter(item -> Objects.equals(UserScopedSpec.getUser(item.getSpec()), user))
.collect(Collectors.toList());
}

default List<S> specs() {
default List<SPEC> specs() {
return list().stream().map(item -> item.getSpec()).collect(Collectors.toList());
}

default List<S> specs(String user) {
default List<SPEC> specs(String user) {
return list(user).stream().map(item -> item.getSpec()).collect(Collectors.toList());
}

default boolean updateStatus(String correlationId, T resource, Consumer<STATUS> editOperation) {
trace(correlationId, "Update Status of " + resource);
final String name = resource.getMetadata().getName();
return (editStatus(correlationId, name, res -> {
STATUS status = Optional.ofNullable(res.getStatus()).orElse(createDefaultStatus());
res.setStatus(status);
editOperation.accept(status);
}) != null);
}

STATUS createDefaultStatus();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.theia.cloud.common.k8s.resource.AppDefinition;
import org.eclipse.theia.cloud.common.k8s.resource.AppDefinitionSpec;
import org.eclipse.theia.cloud.common.k8s.resource.AppDefinitionSpecResourceList;
import org.eclipse.theia.cloud.common.k8s.resource.AppDefinitionStatus;

import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.client.NamespacedKubernetesClient;
Expand All @@ -42,4 +43,9 @@ public AppDefinition create(String correlationId, AppDefinitionSpec spec) {
return operation().create(appDefinition);
}

@Override
public AppDefinitionStatus createDefaultStatus() {
return new AppDefinitionStatus();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.theia.cloud.common.k8s.resource.Session;
import org.eclipse.theia.cloud.common.k8s.resource.SessionSpec;
import org.eclipse.theia.cloud.common.k8s.resource.SessionSpecResourceList;
import org.eclipse.theia.cloud.common.k8s.resource.SessionStatus;
import org.eclipse.theia.cloud.common.util.TheiaCloudError;

import io.fabric8.kubernetes.api.model.ObjectMeta;
Expand Down Expand Up @@ -102,4 +103,9 @@ public boolean reportActivity(String correlationId, String name) {
}) != null;
}

@Override
public SessionStatus createDefaultStatus() {
return new SessionStatus();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (C) 2022 EclipseSource and others.
* Copyright (C) 2022-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -20,6 +20,7 @@
import org.eclipse.theia.cloud.common.k8s.resource.Workspace;
import org.eclipse.theia.cloud.common.k8s.resource.WorkspaceSpec;
import org.eclipse.theia.cloud.common.k8s.resource.WorkspaceSpecResourceList;
import org.eclipse.theia.cloud.common.k8s.resource.WorkspaceStatus;
import org.eclipse.theia.cloud.common.util.TheiaCloudError;

import io.fabric8.kubernetes.api.model.ObjectMeta;
Expand Down Expand Up @@ -88,4 +89,9 @@ protected boolean isWorkspaceComplete(String correlationId, WorkspaceSpec create
}
return false;
}

@Override
public WorkspaceStatus createDefaultStatus() {
return new WorkspaceStatus();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ default T edit(String correlationId, String name, Consumer<T> consumer) {
return resource.edit(JavaUtil.toUnary(consumer));
}

default T editStatus(String correlationId, String name, Consumer<T> consumer) {
trace(correlationId, "Edit status of " + name);
Resource<T> resource = resource(name);
if (resource.get() == null) {
return null;
}
return resource.editStatus(JavaUtil.toUnary(consumer));
}

Optional<T> loadAndCreate(String correlationId, String yaml, Consumer<T> customization);

default Optional<T> loadAndCreate(String correlationId, String yaml) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (C) 2022 EclipseSource and others.
* Copyright (C) 2022-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -20,8 +20,10 @@
import org.eclipse.theia.cloud.common.k8s.resource.Session;
import org.eclipse.theia.cloud.common.k8s.resource.SessionSpec;
import org.eclipse.theia.cloud.common.k8s.resource.SessionSpecResourceList;
import org.eclipse.theia.cloud.common.k8s.resource.SessionStatus;

public interface SessionResourceClient extends CustomResourceClient<SessionSpec, Session, SessionSpecResourceList> {
public interface SessionResourceClient
extends CustomResourceClient<SessionSpec, SessionStatus, Session, SessionSpecResourceList> {
Session launch(String correlationId, SessionSpec spec, long timeout, TimeUnit unit);

default Session launch(String correlationId, SessionSpec spec, int timeout) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (C) 2022 EclipseSource and others.
* Copyright (C) 2022-2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -20,14 +20,14 @@
import org.eclipse.theia.cloud.common.k8s.resource.Workspace;
import org.eclipse.theia.cloud.common.k8s.resource.WorkspaceSpec;
import org.eclipse.theia.cloud.common.k8s.resource.WorkspaceSpecResourceList;
import org.eclipse.theia.cloud.common.k8s.resource.WorkspaceStatus;

public interface WorkspaceResourceClient
extends CustomResourceClient<WorkspaceSpec, Workspace, WorkspaceSpecResourceList> {
extends CustomResourceClient<WorkspaceSpec, WorkspaceStatus, Workspace, WorkspaceSpecResourceList> {

Workspace launch(String correlationId, WorkspaceSpec spec, long timeout, TimeUnit unit);

default Workspace launch(String correlationId, WorkspaceSpec spec) {
return launch(correlationId, spec, 1, TimeUnit.MINUTES);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
import io.fabric8.kubernetes.model.annotation.Singular;
import io.fabric8.kubernetes.model.annotation.Version;

@Version("v6beta")
@Version("v8beta")
@Group("theia.cloud")
@Singular("appdefinition")
@Plural("appdefinitions")
public class AppDefinition extends CustomResource<AppDefinitionSpec, Void> implements Namespaced {
public class AppDefinition extends CustomResource<AppDefinitionSpec, AppDefinitionStatus> implements Namespaced {

private static final long serialVersionUID = 8749670583218521755L;
public static final String API = "theia.cloud/v8beta";
public static final String KIND = "AppDefinition";
public static final String CRD_NAME = "appdefinitions.theia.cloud";

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
@JsonDeserialize()
public class AppDefinitionSpec {

public static final String API = "theia.cloud/v6beta";
public static final String KIND = "AppDefinition";
public static final String CRD_NAME = "appdefinitions.theia.cloud";

@JsonProperty("name")
private String name;

Expand Down Expand Up @@ -210,7 +206,7 @@ public int getPort() {
return port;
}

public ActivityTracker getActivityTrackerModule() {
public ActivityTracker getActivityTracker() {
return activityTracker;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/********************************************************************************
* Copyright (C) 2023 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
package org.eclipse.theia.cloud.common.k8s.resource;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

@JsonDeserialize
public class AppDefinitionStatus extends ResourceStatus {
// This class is empty as only the common properties of the super class are
// used. Already define a specific class to allow easier extension, properly
// type the resources and resource clients.
// It is planned to extend this later with AppDefinition specific status steps.
}
Loading