Skip to content

Commit

Permalink
Set more environment variables in defineCluster
Browse files Browse the repository at this point in the history
Set ONM_IP, ONM_URL, BROKER_ADDRESS, BROKER_PORT, ACTIVEMQ_HOST,
ACTIVEMQ_PORT, based on the values of APP_ACTIVEMQ_HOST (or
--app-activemq-host parameter), AP_ACTIVEMQ_PORT (or --app-activemq-port
parameter), ONM_IP (or --onm-ip parameter), ONM_URL (or --onm-url parameter).

See https://bugs.launchpad.net/nebulous/+bug/2062521

Change-Id: Iad3614ba0aeeeab48f809e4f7b185474039905f3
  • Loading branch information
rudi authored and jmarchel7bulls committed May 17, 2024
1 parent 4557a44 commit 2cefd9b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ spec:
secretKeyRef:
name: {{ include "nebulous-optimiser-controller.fullname" . }}-secrets
key: ACTIVEMQ_PASSWORD
- name: APP_ACTIVEMQ_HOST
value: "{{ .Values.app.ACTIVEMQ_HOST }}"
- name: APP_ACTIVEMQ_PORT
value: "{{ .Values.app.ACTIVEMQ_PORT }}"
- name: ONM_IP
value: "{{ .Values.app.ONM_IP }}"
- name: ONM_URL
value: "{{ .Values.app.ONM_URL }}"
# livenessProbe:
# httpGet:
# path: /
Expand Down
6 changes: 6 additions & 0 deletions charts/nebulous-optimiser-controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,11 @@ activemq:
ACTIVEMQ_PORT: 5672
ACTIVEMQ_USER: admin

app:
ONM_IP: '123'
ONM_URL: onm-url''
ACTIVEMQ_HOST: 'nebulous-activemq'
ACTIVEMQ_PORT: '131'

secrets:
ACTIVEMQ_PASSWORD: nebulous
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,34 @@ public class Main implements Callable<Integer> {
@Getter
private static Path logDirectory;

@Option(names = {"--app-activemq-host"},
description = "The hostname of the ActiveMQ server in a deployed app. Can also be set via the @|bold APP_ACTIVEMQ_HOST|@ environment variable.",
paramLabel = "APP_ACTIVEMQ_HOST",
defaultValue = "${APP_ACTIVEMQ_HOST}")
@Getter
private static String appBrokerAddress;

@Option(names = {"--app-activemq-port"},
description = "The port of the ActiveMQ server in a deployed app. Can also be set via the @|bold APP_ACTIVEMQ_PORT|@ environment variable.",
paramLabel = "APP_ACTIVEMQ_PORT",
defaultValue = "${APP_ACTIVEMQ_PORT:-5672}")
@Getter
private static int appBrokerPort;

@Option(names = {"--onm-ip"},
description = "The IP address of the ONM server in a deployed app. Can also be set via the @|bold ONM_IP|@ environment variable. NOTE: will be deprecated soon.",
paramLabel = "ONM_IP",
defaultValue = "${ONM_IP}")
@Getter
private static String onmIp;

@Option(names = {"--onm-url"},
description = "The URL of the ONM server in a deployed app. Can also be set via the @|bold ONM_URL|@ environment variable.",
paramLabel = "ONM_URL",
defaultValue = "${ONM_URL}")
@Getter
private static String onmUrl;

@Option(names = {"--verbose", "-v"},
description = "Turn on more verbose logging output. Can be given multiple times. When not given, print only warnings and error messages. With @|underline -v|@, print status messages. With @|underline -vvv|@, print everything.",
scope = ScopeType.INHERIT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,32 @@ public static void deployApplication(NebulousApp app, JsonNode kubevela) {
.put("cloudId", candidate.getCloud().getId());
});
ObjectNode environment = cluster.withObject("/env-var");
// See https://openproject.nebulouscloud.eu/projects/nebulous-collaboration-hub/wiki/env-variables-necessary-for-nebulous-application-deployment-scripts
environment.put("APPLICATION_ID", appUUID);
// TODO: consider pre-parsing environment variables and storing them
// in the app object instead of reading them from the raw dsl message
// here
if (Main.getAppBrokerAddress() == null || Main.getAppBrokerAddress().equals("")) {
log.warn("ActiveMQ broker address for app (APP_ACTIVEMQ_HOST) is not set, optimistically continuing with 'localhost'");
environment.put("BROKER_ADDRESS", "localhost");
environment.put("ACTIVEMQ_HOST", "localhost");
} else {
environment.put("BROKER_ADDRESS", Main.getAppBrokerAddress());
environment.put("ACTIVEMQ_HOST", Main.getAppBrokerAddress());
}
// Don't warn when those are unset, 5672 is usually the right call
environment.put("BROKER_PORT", Main.getAppBrokerPort());
environment.put("ACTIVEMQ_PORT", Main.getAppBrokerPort());
if (Main.getOnmIp() == null || Main.getOnmIp().equals("")) {
log.warn("Overlay Network Manager address (ONM_IP) is not set, continuing without setting ONM_IP for the app");
} else {
environment.put("ONM_IP", Main.getOnmIp());
}
if (Main.getOnmUrl() == null || Main.getOnmUrl().equals("")) {
log.warn("Overlay Network Manager address (ONM_URL) is not set, continuing without setting ONM_URL for the app");
} else {
environment.put("ONM_URL", Main.getOnmUrl());
}
// TODO: consider pre-parsing environment variables from the app
// message and storing them in the app object instead of reading them
// from the raw JSON here -- but it's not that important
for (final JsonNode v : app.getOriginalAppMessage().withArray("/environmentVariables")) {
if (v.has("name") && v.has("value") && v.get("name").isTextual()) {
// TODO: figure out what to do with the `"secret":true` field
Expand Down

0 comments on commit 2cefd9b

Please sign in to comment.