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

Separate operator default implementation from library #303

Merged
merged 5 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [0.11.0] - estimated 2024-07

- [common] Add option field to CRDs and increase version to `Session.v1beta8`, `Workspace.v1beta5` and `AppDefinition.v1beta10` [#293](https://github.com/eclipsesource/theia-cloud/pull/293) | [#55](https://github.com/eclipsesource/theia-cloud-helm/pull/55)
- [java] Separate operator default implementation from library to allow for easier customization [#303](https://github.com/eclipsesource/theia-cloud/pull/303)

## [0.10.0] - 2024-04-02

Expand Down
9 changes: 8 additions & 1 deletion demo/dockerfiles/demo-theia-monitor-vscode/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
FROM node:18-bullseye-slim as build-stage

# Copy and unzip the vsix file
RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/*
COPY theiacloud-monitor-0.11.0-next.vsix /tmp/theiacloud-monitor.vsix
RUN mkdir /tmp/extracted && unzip /tmp/theiacloud-monitor.vsix -d /tmp/extracted

FROM theiacloud/theia-cloud-demo:0.11.0-next as production-stage

COPY --chown=theia:theia theiacloud-monitor-0.11.0-next.vsix /home/theia/plugins
COPY --chown=theia:theia --from=build-stage /tmp/extracted /home/theia/plugins
Binary file not shown.
8 changes: 5 additions & 3 deletions dockerfiles/operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ RUN cd /operator/common/maven-conf && \
cd /operator/common/org.eclipse.theia.cloud.common && \
mvn clean install --no-transfer-progress && \
cd /operator/operator/org.eclipse.theia.cloud.operator && \
mvn clean install --no-transfer-progress && \
cd /operator/operator/org.eclipse.theia.cloud.defaultoperator && \
mvn clean verify --no-transfer-progress

FROM eclipse-temurin:17-jre-alpine
RUN mkdir /templates
WORKDIR /log-config
COPY java/operator/org.eclipse.theia.cloud.operator/log4j2.xml .
COPY java/operator/org.eclipse.theia.cloud.defaultoperator/log4j2.xml .
WORKDIR /operator
COPY --from=builder /operator/operator/org.eclipse.theia.cloud.operator/target/operator-0.11.0-SNAPSHOT-jar-with-dependencies.jar .
COPY --from=builder /operator/operator/org.eclipse.theia.cloud.defaultoperator/target/defaultoperator-0.11.0-SNAPSHOT-jar-with-dependencies.jar .
# to get more debug information from the kubernetes client itself, add -Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG below
ENTRYPOINT [ "java", "-Dlog4j2.configurationFile=/log-config/log4j2.xml", "-jar", "./operator-0.11.0-SNAPSHOT-jar-with-dependencies.jar" ]
ENTRYPOINT [ "java", "-Dlog4j2.configurationFile=/log-config/log4j2.xml", "-jar", "./defaultoperator-0.11.0-SNAPSHOT-jar-with-dependencies.jar" ]
CMD [ "" ]
8 changes: 5 additions & 3 deletions dockerfiles/operator/Dockerfile.withcache
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ RUN --mount=type=cache,target=/root/.m2 \
cd /operator/common/org.eclipse.theia.cloud.common && \
mvn clean install && \
cd /operator/operator/org.eclipse.theia.cloud.operator && \
mvn clean install && \
cd /operator/operator/org.eclipse.theia.cloud.defaultoperator && \
mvn clean verify

FROM eclipse-temurin:17-jre-alpine
RUN mkdir /templates
WORKDIR /log-config
COPY java/operator/org.eclipse.theia.cloud.operator/log4j2.xml .
COPY java/operator/org.eclipse.theia.cloud.defaultoperator/log4j2.xml .
WORKDIR /operator
COPY --from=builder /operator/operator/org.eclipse.theia.cloud.operator/target/operator-0.11.0-SNAPSHOT-jar-with-dependencies.jar .
COPY --from=builder /operator/operator/org.eclipse.theia.cloud.defaultoperator/target/defaultoperator-0.11.0-SNAPSHOT-jar-with-dependencies.jar .
# to get more debug information from the kubernetes client itself, add -Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG below
ENTRYPOINT [ "java", "-Dlog4j2.configurationFile=/log-config/log4j2.xml", "-jar", "./operator-0.11.0-SNAPSHOT-jar-with-dependencies.jar" ]
ENTRYPOINT [ "java", "-Dlog4j2.configurationFile=/log-config/log4j2.xml", "-jar", "./defaultoperator-0.11.0-SNAPSHOT-jar-with-dependencies.jar" ]
CMD [ "" ]
9 changes: 6 additions & 3 deletions documentation/Architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

The Theia Cloud Operator listens for changes to custom resources inside the cluster. With those custom resources clients may trigger the creation/deletion/handling of workspaces and sessions. The Operator is responsible for handling all things that are related to the Kubernetes-Resources for workspaces and sessions. All access is authenticated via an Authenticator.

![Theia Cloud Diagram](theia.cloud.png "Theia Cloud")
![Theia Cloud Diagram](theiacloud.png "Theia Cloud")

## Operator Java Overview

The Java operator is created via a dependency injection module.
In the future the operator will be provided as a library with defined interfaces end users may exchange to customize the operator based on their needs.
We provide a library (`org.eclipse.theia.cloud.operator`), as well as a default implementation (`org.eclipse.theia.cloud.defaultoperator`) for the operator.
The library can be used to create an operator customized to your use cases.
The default implementation is a production-ready operator that handles most use cases on most cloud providers out of the box and is used in our demos.
If customization is needed, it also serves as an example of how to utilize the operator library.

The following diagram sketches the basic idea.

![Operator Diagram](operator.png "Operator")

## Operator configuration options
### Operator configuration options

|Option|Type|Used for|
|---|---|---|
Expand Down
2 changes: 1 addition & 1 deletion documentation/OpenAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Generate and Update

Start Theia.cloud service from IDE (which starts quarkus in dev mode).
Start Theia Cloud service from IDE (which starts quarkus in dev mode).

Access generated specs at <http://localhost:8081/q/openapi?format=json>

Expand Down
4 changes: 2 additions & 2 deletions documentation/platforms/Minikube.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Getting started with Minikube

Minikube is a local Kubernetes that allows you to test and develop for Kubernetes.\
In this guide we will show you how to install minikube and helm 3 as well as cert-manager, the cloud native certificate management, the NginX Ingress Controller and Keycloak. We will use existing installation methods for all of the Theia.Cloud preqrequisites.\
Finally we will install and try Theia.Cloud using helm.
In this guide we will show you how to install minikube and helm 3 as well as cert-manager, the cloud native certificate management, the NginX Ingress Controller and Keycloak. We will use existing installation methods for all of the Theia Cloud preqrequisites.\
Finally we will install and try Theia Cloud using helm.

If you have no experience with Kubernetes/Minikube yet, we encourage you to check out some basic tutorials first, e.g. <https://kubernetes.io/docs/tutorials/hello-minikube/> and <https://kubernetes.io/docs/tutorials/kubernetes-basics/>

Expand Down
2 changes: 1 addition & 1 deletion documentation/platforms/global-certificate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ metadata:
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
acme.cert-manager.io/http01-edit-in-place: "true"
# cert-manager.io/common-name: "Theia.Cloud"
# cert-manager.io/common-name: "Theia Cloud"
spec:
ingressClassName: nginx
tls:
Expand Down
File renamed without changes.
File renamed without changes
2 changes: 1 addition & 1 deletion java/common/maven-conf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<artifactId>conf</artifactId>
<version>0.11.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Theia.Cloud Maven Configuration</name>
<name>Theia Cloud Maven Configuration</name>
<description>Common properties and configuration</description>

<properties>
Expand Down
4 changes: 2 additions & 2 deletions java/common/org.eclipse.theia.cloud.common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>common</artifactId>
<packaging>jar</packaging>
<name>Theia.Cloud Common</name>
<description>Common components of Theia.Cloud</description>
<name>Theia Cloud Common</name>
<description>Common components of Theia Cloud</description>

<parent>
<groupId>org.eclipse.theia.cloud</groupId>
Expand Down
68 changes: 68 additions & 0 deletions java/operator/org.eclipse.theia.cloud.defaultoperator/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path=".apt_generated">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path=".apt_generated_tests">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/target/
/.apt_generated/
/.apt_generated_tests/

34 changes: 34 additions & 0 deletions java/operator/org.eclipse.theia.cloud.defaultoperator/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>defaultoperator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
<filteredResources>
<filter>
<id>1665669047196</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=target/generated-sources/annotations
org.eclipse.jdt.apt.genTestSrcDir=target/generated-test-sources/test-annotations
Loading
Loading