Introduction
- 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.
- Docker® images for JS7 are publicly available from https://hub.docker.com/r/sosberlin/js7.
- Instructions on how to run containers for JS7 components can be found from the JS7 - Installation for Docker Containers article series.
- 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 deployment YAML files to deploy JS7 components.
Deployment Files
The sample YAML files for use with Kubernetes are attached to the article.
Download the archive file: js7-kubernetes.zip
The archive includes the following files:
js7-deployment.yaml – This file is the deployment file for JS7 components.
This YAML file describes a Pod in Kubernetes, which is a group of one or more containers and a config map.
The Pod has three containers:
- The js7joc container runs the joc-2-5-1 image and exposes port 4446. It also uses a ConfigMap named hibernate-config as a volume, mounted at /var/sos-berlin.com/js7/joc/resources/joc/. The container sets several environment variables, including RUN_JS_JAVA_OPTIONS, RUN_JS_USER_ID, and RUN_JS_ID.
- 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.
- 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.
Each container runs a different image from the sosberlin/js7 repository and is assigned a unique port.
Each container has environment variables defined, which control various runtime parameters for the application such as:
- RUN_JS_JAVA_OPTIONS
- RUN_JS_USER_ID
- RUN_JS_ID
A volumeMounts to the configMap is used named hibernate-config which is mounted to the /var/sos-berlin.com/js7/joc/resources/joc/ directory in the js7joc container.
js7-service.yaml – This file includes the configuration for port forwarding.
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.
Step-by-Step Instructions
To operate JOC Cockpit in a Kubernetes cluster with the JS7 database users adjust the hibernate.cfg.xml
file that specifies the database connection and holds credentials for database access. Find further examples from the JS7 - Database article.
- Download the archive file: js7-kubernetes.zip. Open a console window from the directory where you downloaded the .zip archive and extract the archive.
Execute the below command to create a config map and to pass the
hibernate.cfg.xml
file to the mount directory of the container.kubectl create configmap hibernate-config --from-file=hibernate.cfg.xml
Run the
js7-deployment.yaml
file to create the deployment for the JS7 configuration.kubectl create -f js7-deployment.yaml
Run the
js7-service.yaml
file to create the service for the JS7 configuration.kubectl create -f js7-service.yaml
Once both YAML files are executed successfully, users can check the pod's status. The following command displays pods running in the Kubernetes cluster.
kubectl get pods
Once both YAML files are executed successfully, users can check the steps from the YAML file executed to create the pod. The following command displays resources used in Kubernetes. It shows data from a single resource and from a collection of resources.
kubectl describe pods
The following command can be executed to check the IP address and port of JS7 components.
kubectl get service