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

Operator should not get hostname from app definitions #208

Merged
merged 2 commits into from
Jul 27, 2023
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
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/v5beta
- apiVersion: theia.cloud/v6beta
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/v5beta
- apiVersion: theia.cloud/v6beta
kind: AppDefinition
name: placeholder
uid: placeholder
Expand Down
3 changes: 1 addition & 2 deletions demo/k8s/appdefinitions/cdt.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
apiVersion: theia.cloud/v5beta
apiVersion: theia.cloud/v6beta
kind: AppDefinition
metadata:
name: cdt-cloud-demo
namespace: theiacloud
spec:
downlinkLimit: 30000
host: ws.theia-cloud.io
image: theiacloud/cdt-cloud:v1.34.4
imagePullPolicy: IfNotPresent
ingressname: theia-cloud-demo-ws-ingress
Expand Down
3 changes: 1 addition & 2 deletions demo/k8s/appdefinitions/coffee-editor.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
apiVersion: theia.cloud/v5beta
apiVersion: theia.cloud/v6beta
kind: AppDefinition
metadata:
name: coffee-editor
namespace: theiacloud
spec:
downlinkLimit: 30000
host: ws.theia-cloud.io
image: eu.gcr.io/kubernetes-238012/coffee-editor:v0.7.17
imagePullPolicy: IfNotPresent
ingressname: theia-cloud-demo-ws-ingress
Expand Down
3 changes: 1 addition & 2 deletions demo/k8s/appdefinitions/theia.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
apiVersion: theia.cloud/v5beta
apiVersion: theia.cloud/v6beta
kind: AppDefinition
metadata:
name: theia-cloud-demo
namespace: theiacloud
spec:
downlinkLimit: 30000
host: ws.theia-cloud.io
image: theiacloud/theia-cloud-demo:0.8.0
imagePullPolicy: IfNotPresent
ingressname: theia-cloud-demo-ws-ingress
Expand Down
3 changes: 1 addition & 2 deletions helm/theia.cloud/test/cdt.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: theia.cloud/v5beta
apiVersion: theia.cloud/v6beta
kind: AppDefinition
metadata:
name: cdt-cloud-demo
Expand All @@ -9,7 +9,6 @@ spec:
pullSecret: ""
uid: 101
port: 3000
host: ws.192.168.39.3.nip.io
ingressname: theia-cloud-demo-ws-ingress
minInstances: 0
maxInstances: 10
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (C) 2022 EclipseSource, Lockular, Ericsson, STMicroelectronics and
* Copyright (C) 2022-2023 EclipseSource, Lockular, Ericsson, STMicroelectronics and
* others.
*
* This program and the accompanying materials are made available under the
Expand All @@ -25,7 +25,7 @@
import io.fabric8.kubernetes.model.annotation.Singular;
import io.fabric8.kubernetes.model.annotation.Version;

@Version("v5beta")
@Version("v6beta")
@Group("theia.cloud")
@Singular("appdefinition")
@Plural("appdefinitions")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@JsonDeserialize()
public class AppDefinitionSpec {

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

Expand All @@ -44,9 +44,6 @@ public class AppDefinitionSpec {
@JsonProperty("port")
private int port;

@JsonProperty("host")
private String host;

@JsonProperty("ingressname")
private String ingressname;

Expand Down Expand Up @@ -107,10 +104,6 @@ public int getPort() {
return port;
}

public String getHost() {
return host;
}

public String getIngressname() {
return ingressname;
}
Expand Down Expand Up @@ -162,9 +155,9 @@ public Monitor getMonitor() {
@Override
public String toString() {
return "AppDefinitionSpec [name=" + name + ", image=" + image + ", imagePullPolicy=" + imagePullPolicy
+ ", pullSecret=" + pullSecret + ", uid=" + uid + ", port=" + port + ", host=" + host + ", ingressname="
+ ingressname + ", minInstances=" + minInstances + ", maxInstances=" + maxInstances + ", timeout="
+ timeout + ", requestsMemory=" + requestsMemory + ", requestsCpu=" + requestsCpu + ", limitsMemory="
+ ", pullSecret=" + pullSecret + ", uid=" + uid + ", port=" + port + ", ingressname=" + ingressname
+ ", minInstances=" + minInstances + ", maxInstances=" + maxInstances + ", timeout=" + timeout
+ ", requestsMemory=" + requestsMemory + ", requestsCpu=" + requestsCpu + ", limitsMemory="
+ limitsMemory + ", limitsCpu=" + limitsCpu + ", downlinkLimit=" + downlinkLimit + ", uplinkLimit="
+ uplinkLimit + ", mountPath=" + mountPath + "]";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public enum BandwidthLimiter {
@Option(names = { "--appId" }, description = "Application ID necessary for service calls", required = false)
private String appId;

@Option(names = {
"--instancesHost" }, description = "Hostname instances are hosted at. Does not include subpaths.", required = true)
private String instancesHost;

@Option(names = {
"--usePaths" }, description = "Whether paths instead of subdomains are used for the various components", required = false)
private boolean usePaths;
Expand Down Expand Up @@ -138,6 +142,10 @@ public String getAppId() {
return appId;
}

public String getInstancesHost() {
return instancesHost;
}

public boolean isUsePaths() {
return usePaths;
}
Expand Down Expand Up @@ -176,6 +184,7 @@ public int hashCode() {
result = prime * result + (eagerStart ? 1231 : 1237);
result = prime * result + (enableActivityTracker ? 1231 : 1237);
result = prime * result + (enableMonitor ? 1231 : 1237);
result = prime * result + ((instancesHost == null) ? 0 : instancesHost.hashCode());
result = prime * result + ((instancesPath == null) ? 0 : instancesPath.hashCode());
result = prime * result + ((keycloakClientId == null) ? 0 : keycloakClientId.hashCode());
result = prime * result + ((keycloakRealm == null) ? 0 : keycloakRealm.hashCode());
Expand Down Expand Up @@ -215,6 +224,11 @@ public boolean equals(Object obj) {
return false;
if (enableMonitor != other.enableMonitor)
return false;
if (instancesHost == null) {
if (other.instancesHost != null)
return false;
} else if (!instancesHost.equals(other.instancesHost))
return false;
if (instancesPath == null) {
if (other.instancesPath != null)
return false;
Expand Down Expand Up @@ -278,9 +292,10 @@ public String toString() {
+ enableMonitor + ", enableActivityTracker=" + enableActivityTracker + ", monitorInterval="
+ monitorInterval + ", cloudProvider=" + cloudProvider + ", bandwidthLimiter=" + bandwidthLimiter
+ ", wondershaperImage=" + wondershaperImage + ", serviceUrl=" + serviceUrl + ", sessionsPerUser="
+ sessionsPerUser + ", appId=" + appId + ", usePaths=" + usePaths + ", instancesPath=" + instancesPath
+ ", storageClassName=" + storageClassName + ", requestedStorage=" + requestedStorage + ", keycloakURL="
+ keycloakURL + ", keycloakRealm=" + keycloakRealm + ", keycloakClientId=" + keycloakClientId + "]";
+ sessionsPerUser + ", appId=" + appId + ", instancesHost=" + instancesHost + ", usePaths=" + usePaths
+ ", instancesPath=" + instancesPath + ", storageClassName=" + storageClassName + ", requestedStorage="
+ requestedStorage + ", keycloakURL=" + keycloakURL + ", keycloakRealm=" + keycloakRealm
+ ", keycloakClientId=" + keycloakClientId + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ protected Map<String, String> getAppDefinitionData(AppDefinition appDefinition)

protected Map<String, String> getEnvironmentVariables(AppDefinition appDefinition, Session session) {
Map<String, String> environmentVariables = getEnvironmentVariables(appDefinition, Optional.of(session));
environmentVariables.put(PLACEHOLDER_ENV_SESSION_URL,
TheiaCloudDeploymentUtil.getSessionURL(ingressPathProvider, appDefinition, session));
environmentVariables.put(PLACEHOLDER_ENV_SESSION_URL, TheiaCloudDeploymentUtil
.getSessionURL(arguments.getInstancesHost(), ingressPathProvider, appDefinition, session));
return environmentVariables;
}

protected Map<String, String> getEnvironmentVariables(AppDefinition appDefinition, int instance) {
Map<String, String> environmentVariables = getEnvironmentVariables(appDefinition, Optional.empty());
environmentVariables.put(PLACEHOLDER_ENV_SESSION_URL,
TheiaCloudDeploymentUtil.getSessionURL(ingressPathProvider, appDefinition, instance));
environmentVariables.put(PLACEHOLDER_ENV_SESSION_URL, TheiaCloudDeploymentUtil
.getSessionURL(arguments.getInstancesHost(), ingressPathProvider, appDefinition, instance));
return environmentVariables;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ protected void createAndApplyProxyConfigMap(NamespacedKubernetesClient client, S
K8sUtil.loadAndCreateConfigMapWithOwnerReference(client, namespace, correlationId, configMapYaml,
AppDefinitionSpec.API, AppDefinitionSpec.KIND, appDefinitionResourceName, appDefinitionResourceUID, 0,
configMap -> {
String host = appDefinition.getSpec().getHost()
+ ingressPathProvider.getPath(appDefinition, instance);
String host = arguments.getInstancesHost() + ingressPathProvider.getPath(appDefinition, instance);
int port = appDefinition.getSpec().getPort();
AddedHandlerUtil.updateProxyConfigMap(client, namespace, configMap, host, port);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ protected synchronized Entry<Optional<Service>, Boolean> reserveService(Namespac

protected synchronized String updateIngress(Optional<Ingress> ingress, Optional<Service> serviceToUse,
String appDefinitionID, int instance, int port, AppDefinition appDefinition, String correlationId) {
String host = appDefinition.getSpec().getHost();
final String host = arguments.getInstancesHost();
String path = ingressPathProvider.getPath(appDefinition, instance);
client.ingresses().edit(correlationId, ingress.get().getMetadata().getName(),
ingressToUpdate -> addIngressRule(ingressToUpdate, serviceToUse.get(), host, port, path));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ protected void createAndApplyProxyConfigMap(String correlationId, String session
K8sUtil.loadAndCreateConfigMapWithOwnerReference(client.kubernetes(), client.namespace(), correlationId,
configMapYaml, SessionSpec.API, SessionSpec.KIND, sessionResourceName, sessionResourceUID, 0,
configMap -> {
String host = appDefinition.getSpec().getHost()
+ ingressPathProvider.getPath(appDefinition, session);
String host = arguments.getInstancesHost() + ingressPathProvider.getPath(appDefinition, session);
int port = appDefinition.getSpec().getPort();
AddedHandlerUtil.updateProxyConfigMap(client.kubernetes(), client.namespace(), configMap, host,
port);
Expand Down Expand Up @@ -371,7 +370,7 @@ protected void addVolumeClaim(Deployment deployment, String pvcName, AppDefiniti

protected synchronized String updateIngress(Optional<Ingress> ingress, Optional<Service> serviceToUse,
Session session, AppDefinition appDefinition, String correlationId) {
String host = appDefinition.getSpec().getHost();
final String host = arguments.getInstancesHost();
String path = ingressPathProvider.getPath(appDefinition, session);
client.ingresses().edit(correlationId, ingress.get().getMetadata().getName(), ingressToUpdate -> {
IngressRule ingressRule = new IngressRule();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (C) 2022 EclipseSource, Lockular, Ericsson, STMicroelectronics and
* Copyright (C) 2022-2023 EclipseSource, Lockular, Ericsson, STMicroelectronics and
* others.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -40,14 +40,14 @@ public final class TheiaCloudDeploymentUtil {
private TheiaCloudDeploymentUtil() {
}

public static String getSessionURL(IngressPathProvider ingressPathProvider, AppDefinition appDefinition,
Session session) {
return getSessionURL(appDefinition.getSpec().getHost(), ingressPathProvider.getPath(appDefinition, session));
public static String getSessionURL(String host, IngressPathProvider ingressPathProvider,
AppDefinition appDefinition, Session session) {
return getSessionURL(host, ingressPathProvider.getPath(appDefinition, session));
}

public static String getSessionURL(IngressPathProvider ingressPathProvider, AppDefinition appDefinition,
int instance) {
return getSessionURL(appDefinition.getSpec().getHost(), ingressPathProvider.getPath(appDefinition, instance));
public static String getSessionURL(String host, IngressPathProvider ingressPathProvider,
AppDefinition appDefinition, int instance) {
return getSessionURL(host, ingressPathProvider.getPath(appDefinition, instance));
}

private static String getSessionURL(String host, String path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
theiacloud: proxy
namespace: placeholder-namespace
ownerReferences:
- apiVersion: theia.cloud/v5beta
- apiVersion: theia.cloud/v6beta
kind: AppDefinition
name: placeholder
uid: placeholder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
theiacloud: emails
namespace: placeholder-namespace
ownerReferences:
- apiVersion: theia.cloud/v5beta
- apiVersion: theia.cloud/v6beta
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/v5beta
- apiVersion: theia.cloud/v6beta
kind: AppDefinition
name: placeholder
uid: placeholder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
app: placeholder-app
namespace: placeholder-namespace
ownerReferences:
- apiVersion: theia.cloud/v5beta
- apiVersion: theia.cloud/v6beta
kind: AppDefinition
name: placeholder
uid: placeholder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
app: placeholder-app
namespace: placeholder-namespace
ownerReferences:
- apiVersion: theia.cloud/v5beta
- apiVersion: theia.cloud/v6beta
kind: AppDefinition
name: placeholder
uid: placeholder
Expand Down
6 changes: 2 additions & 4 deletions terraform/test-configurations/2-01_try-now/theia_cloud.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,13 @@ resource "helm_release" "theia-cloud" {
resource "kubectl_manifest" "cdt-cloud-demo" {
depends_on = [helm_release.theia-cloud]
yaml_body = <<-EOF
apiVersion: theia.cloud/v5beta
apiVersion: theia.cloud/v6beta
kind: AppDefinition
metadata:
name: cdt-cloud-demo
namespace: theiacloud
spec:
downlinkLimit: 30000
host: ws.${data.terraform_remote_state.minikube.outputs.hostname}
image: theiacloud/cdt-cloud:v1.34.4
imagePullPolicy: IfNotPresent
ingressname: theia-cloud-demo-ws-ingress
Expand Down Expand Up @@ -115,14 +114,13 @@ resource "kubectl_manifest" "cdt-cloud-demo" {
resource "kubectl_manifest" "coffee-editor" {
depends_on = [helm_release.theia-cloud]
yaml_body = <<-EOF
apiVersion: theia.cloud/v5beta
apiVersion: theia.cloud/v6beta
kind: AppDefinition
metadata:
name: coffee-editor
namespace: theiacloud
spec:
downlinkLimit: 30000
host: ws.${data.terraform_remote_state.minikube.outputs.hostname}
image: eu.gcr.io/kubernetes-238012/coffee-editor:v0.7.17
imagePullPolicy: IfNotPresent
ingressname: theia-cloud-demo-ws-ingress
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading