Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • JS7 can be set up for use with a Kubernetes cluster. Using the Linux based JS7 images for Docker® containers which ship with a current Alpine base image and OpenJDK.
  • Users deploy JS7 components by creating a Kubernetes deployment object from a deployment YAML file.
    • To this purpose users have to first install and set up the Kubernetes cluster see JS7 - How to install a Kubernetes Cluster.
    • With the Kubernetes cluster being up and running users can use the YAML deployment YAML files to deploy JS7 components.

Deployment Files

The YAML sample YAML files for use with deployment to Kubernetes are attached to the article.

...

The archive includes the following files.

Deployment of JS7 components:

...

js7-deployment.yaml

...

Code Block
languageyml
titleExample for js7-deployment.yaml
linenumberstrue

...

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: js7joc
  name: js7joc
spec:
  volumes:
  - name: hibernate-config
    configMap:
        name: hibernate-config
  containers:
  - image: sosberlin/js7:joc-2-5-1
    name: js7joc
    ports:
    - containerPort: 4446
    volumeMounts:
    - name: hibernate-config
      mountPath: /var/sos-berlin.com/js7/joc/resources/joc/
  
    env:
    - name: RUN_JS_JAVA_OPTIONS
      value: "-Xmx256m"
    - name: RUN_JS_USER_ID
      value:  "0:0"
    - name: RUN_JS_ID
      value:  "jobscheduler"
      
  - image: sosberlin/js7:controller-2-5-1
    name: js7con
    ports:
    - containerPort: 4444
    env:
    - name: RUN_JS_JAVA_OPTIONS
      value: "-Xmx256m"
    - name: RUN_JS_USER_ID
      value:  "0:0"
    - name: RUN_JS_ID
      value:  "jobscheduler"
      
  - image: sosberlin/js7:agent-2-5-1
    name: js7agent
    ports:
    - containerPort: 4445

...


The YAML file describes a single Pod

...

for deployment to Kubernetes

...

which is a group of one or more containers and a

...

ConfigMap. The Pod includes three containers:

  1. The js7joc container runs thejoc-2-5-1image and exposes port 4446. It also uses a ConfigMap named with the name hibernate-config as to specify a volume , mounted at to the /var/sos-berlin.com/js7/joc/resources/joc/ directory. The container sets several deployment file specifies a number of environment variables, including RUN_JS_JAVA_OPTIONS, RUN_JS_USER_ID, and RUN_JS_ID.
  2. The js7con container runs the controller-2-5-1 image and exposes port 4444. It sets the environment variables RUN_JS_JAVA_OPTIONS, RUN_JS_USER_ID, and RUN_JS_ID.
  3. The js7agent container runs the agent-2-5-1 image and exposes port 4445. It sets the environment variables RUN_JS_JAVA_OPTIONS, RUN_JS_USER_ID, and RUN_JS_ID.

The Pod

...

includes three containers:

  • Each container runs a different image from the sosberlin/js7 repository and is assigned a unique port.
  • Each container

...

  • defines environment variables

...

  • which control

...

  • a number of runtime parameters for the application such as:

    • RUN_JS_JAVA_

...

    • OPTIONS : see JS7 - FAQ - Which Java Options are recommended
    • RUN_JS_USER_ID: specifies the numeric User ID and Group ID - separated by a colon - of the run-time account used for the related JS7 component. A value 0:0 indicates the root account and root group, a value 1000:1000 specifies a user account with the given User ID and Group ID.
    • RUN_JS_ID

...

    • : specifies the Controller ID which is a unique identifier for a Standalone Controller or Controller Cluster.
  • The volumeMounts element specifies the hibernate-config ConfigMap which is mounted to the /var/sos-berlin.com/js7/joc/resources/joc

...

  •  directory in the js7joc container.

Configuration for port forwarding: js7-service.yaml

...

Code Block
languageyml
titleExample for js7-service.yaml
linenumberstrue

...

...

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    run: js7joc
  name: js7joc
spec:
  ports:

  - name: js7joc
    port: 4446
    protocol: TCP
    targetPort: 4446

  - name: js7agent
    port: 4445
    protocol: TCP
    targetPort: 4445

  - name: js7controller
    port: 4444
    protocol: TCP
    targetPort: 4444
  
  selector:
    run: js7joc
  type: LoadBalancer
status:
  loadBalancer: {}

Hibernate Configuration: hibernate.cfg.xml

...

This file includes the Hibernate configuration for connections to the JS7 - Database. Find the following example for use with a MySQL® database

...

:

Code Block
languageyml
titleExample for js7-service.yaml
linenumberstrue

...

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<hibernate-configuration>
 <session-factory>
  <property name="hibernate.connection.driver_class">org.mysql.jdbc.Driver</property>
  <property name="hibernate.connection.password">jobscheduler</property>
  <property name="hibernate.connection.url">jdbc:mysql://mysqlsrv:3306/jobscheduler</property>
  <property name="hibernate.connection.username">jobscheduler</property>
  <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
  <property name="hibernate.show_sql">false</property>
  <property name="hibernate.connection.autocommit">false</property>
  <property name="hibernate.format_sql">true</property>
  <property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>
  <property name="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</property>
  <property name="hibernate.hikari.maximumPoolSize">10</property>
 </session-factory>
</hibernate-configuration>

Step-by-Step Instructions

To operate JOC Cockpit in a Kubernetes cluster Cluster with the JS7 database users adjust the hibernate.cfg.xml file that specifies the database connection and that holds credentials for database access. Find further examples from the JS7 - Database article.

...