Skip to content

Commit

Permalink
Update kube configuration for standalone mode
Browse files Browse the repository at this point in the history
  • Loading branch information
DaSpood committed Jul 31, 2024
1 parent 1ca5296 commit 7f5d3fc
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.lang.management.ManagementFactory;
import java.net.Inet4Address;
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Set;
Expand All @@ -36,8 +38,10 @@

import com.enioka.jqm.client.api.JobRequest;
import com.enioka.jqm.jdbc.DbConn;
import com.enioka.jqm.jdbc.DbManager;
import com.enioka.jqm.jdbc.NoResultException;
import com.enioka.jqm.model.Deliverable;
import com.enioka.jqm.model.GlobalParameter;
import com.enioka.jqm.model.Node;

import jakarta.servlet.ServletContext;
Expand Down Expand Up @@ -285,8 +289,7 @@ public String enqueue(@FormParam("applicationname") String applicationName, @For
@GET
@Path("localnode/health")
@Produces(MediaType.TEXT_PLAIN)
public String getLocalNodeHealth() throws MalformedObjectNameException
{
public String getLocalNodeHealth() throws MalformedObjectNameException, UnknownHostException {
// Local service only - not enabled when running on top of Tomcat & co.
Node n = getLocalNodeIfRunningOnJqm();
if (n == null)
Expand Down Expand Up @@ -331,6 +334,13 @@ public String getLocalNodeHealth() throws MalformedObjectNameException
throw new ErrorDto("JQM node has is not working as expected", "", 11, Status.SERVICE_UNAVAILABLE);
}

return "Pollers are polling";
final var standaloneMode = Boolean.parseBoolean(
GlobalParameter.getParameter(DbManager.getDb().getConn(), "wsStandaloneMode", "false"));

if (standaloneMode) {
return "Pollers are polling - IP: " + Inet4Address.getLocalHost().getHostAddress();
} else {
return "Pollers are polling";
}
}
}
11 changes: 4 additions & 7 deletions kubernetes-dbless/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ database is not the intended use for it, and as such, some limitations are requi

- Each individual node still requires a local database to function. For now, only in-memory HSQLDB is supported.

- Web Service Authentication is ***disabled***.

- Each individual node requires a unique IPv4 address. This IPv4 will be used by the node to assign job IDs. A node may
only enqueue up to 1 million jobs, after that threshold, behavior is undefined and may lead to malfunctions, so the
node should be restarted to clear its database. The `1789` port of each node needs to be exposed to other nodes.
Expand Down Expand Up @@ -91,10 +93,5 @@ Other useful commands:

When changing kubernetes yml's, only the corresponding `kubectl apply` commands need to be run.

## WIP

At the moment, all probes on JQM are disabled because the app does not work. We need the probes turned off otherwise the
load balancer will not route any request to the pods even if the queried container is not the one struggling.

Also, the load balancer currently redirects to port 80, which belongs to NGINX. This is only to test if we do get a
successful connection when calling the load balancer with `curl`. JQM is unavailable.
To check that JQM is running, you can use `curl http://localhost:80/ws/simple/localnode/health` (or the load balancer's
EXTERNAL IP if ingress is disabled), it should reply with "Pollers are polling - IP: <pod ip>".
12 changes: 6 additions & 6 deletions kubernetes-dbless/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WORKDIR /jqm-all

RUN apt update && apt install unzip

#COPY ./docker/windows/nexus/settings.xml ./jqm-all ./ # FIXME: settings needed ?
#COPY ./docker/windows/nexus/settings.xml ./jqm-all ./ # FIXME: Nexus settings needed ?
COPY ./jqm-all ./

RUN --mount=type=cache,target=/root/.m2/repository mvn install -DskipTests=${SKIP_TESTS} ${MVN_SETTINGS}
Expand All @@ -29,7 +29,6 @@ ENV JAVA_OPTS="-Xms128m -Xmx512m -XX:MaxMetaspaceSize=128m" \
JQM_ROOT="/jqm" \
JQM_NODE_NAME="ContainerNode" \
JQM_NODE_WS_INTERFACE="0.0.0.0" \
#JQM_CREATE_NODE_TEMPLATE=TEMPLATE_WEB \
JQM_INIT_MODE=SINGLE \
JQM_POOL_CONNSTR="jdbc:hsqldb:file:db/jqmdatabase;shutdown=true;hsqldb.write_delay=false" \
JQM_POOL_USER="sa" \
Expand All @@ -47,12 +46,13 @@ VOLUME /jqm/hotdeploy/ \
WORKDIR /jqm

# Import initial config
RUN java -jar jqm.jar Update-Schema ; java -jar jqm.jar Import-ClusterConfiguration -f selfConfig.standalone.xml ; java -jar jqm.jar Import-JobDef -f ./jobs/jqm-demo ; rm -f .\logs\* ; chmod 700 /jqm/bin/*.sh ;
RUN java -jar jqm.jar Update-Schema
RUN java -jar jqm.jar Import-ClusterConfiguration -f selfConfig.standalone.xml
RUN java -jar jqm.jar Import-JobDef -f ./jobs/jqm-demo
RUN rm -f .\logs\*
RUN chmod 700 /jqm/bin/*.sh

# Run node on startup
ENTRYPOINT /jqm/bin/node.sh

# Healthcheck is equivalent to calling Node.AllPollersPolling
# Kubernetes already has probes
#HEALTHCHECK --interval=30s --start-period=91s --retries=2 --timeout=10s CMD curl --connect-timeout 2 -q --http1.1 -4 -s -S ${JQM_HEALTHCHECK_URL}
STOPSIGNAL SIGINT
5 changes: 5 additions & 0 deletions kubernetes-dbless/docker/node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ then
# Jobs
echo "### Importing local job definitions inside database"
java -jar jqm.jar Import-JobDef -f ./jobs/

# WS
echo "### Disabling WS auth"
java -jar jqm.jar Set-WebConfiguration -c ENABLE_HTTP_GUI
java -jar jqm.jar Set-WebConfiguration -c DISABLE_AUTHENTICATION
else
echo "### Node ${JQM_NODE_NAME} already exists inside database configuration, skipping config"
fi
Expand Down
32 changes: 13 additions & 19 deletions kubernetes-dbless/jqm-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
labels:
app: jqm
spec:
replicas: 1
replicas: 4
selector:
matchLabels:
app: jqm
Expand All @@ -19,26 +19,20 @@ spec:
app: jqm
spec:
containers:
- name: nginx # FIXME: To test reachability. Simply change which port the LB redirects to
image: nginx:latest
imagePullPolicy: Always
ports:
- containerPort: 80
- name: jqm
image: enioka/jqm-standalone
imagePullPolicy: IfNotPresent
ports:
- containerPort: 1789
# FIXME: Probes disabled until the code can properly compile. The NGINX server will be unreachable until both containers are ok
# livenessProbe:
# httpGet:
# path: /ws/simple/localnode/health
# port: 1789
# initialDelaySeconds: 15
# periodSeconds: 15
# readinessProbe:
# httpGet:
# path: /ws/simple/localnode/health
# port: 1789
# initialDelaySeconds: 5
# periodSeconds: 10
livenessProbe:
httpGet:
path: /ws/simple/localnode/health
port: 1789
initialDelaySeconds: 15
periodSeconds: 15
readinessProbe:
httpGet:
path: /ws/simple/localnode/health
port: 1789
initialDelaySeconds: 5
periodSeconds: 10
2 changes: 1 addition & 1 deletion kubernetes-dbless/jqm-lb-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ spec:
ports:
- port: 1789 # Keep in mind the ingress can only reach one port of your service
protocol: TCP
targetPort: 80 # FIXME: 80 for NGINX, 1789 for JQM
targetPort: 1789
selector:
app: jqm

0 comments on commit 7f5d3fc

Please sign in to comment.