Page History
Table of Contents |
---|
Introduction
- JS7 can be set up using for use with a Kubernetes cluster on a ServerCluster. 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
- products can be found
- from the JS7 - Installation for Containers article series.
- Users deploy JS7 products You can run an application by creating a Kubernetes Deployment object, and you can describe a Deployment in a deployment object from a deployment YAML file. To do so we need
- To this purpose users have to first install and set up the Kubernetes
Setting up a Kubernetes Cluster
There are several ways how to set up a Kubernetes Cluster. Find an example from the following chapters.
The basic step which can be followed to install the Kubernetes cluster on Centos are:
...
Install Docker on all CentOS 7 VMs
Update the package database
Code Block sudo yum check-update
Install the dependencies
Code Block sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Add and enable the official Docker Repository to CentOS 7
Code Block sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Install the latest Docker version on CentOS 7
Code Block sudo yum install docker-ce
A successful installation output will be concluded with a
Complete!
You may be prompted to accept the GPG key. This is to verify that the fingerprint matches. The format will look as follows. If correct, accept it.Code Block 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
Manage Docker service
Now Docker is installed, but the service is not yet running. Start and enable Docker using the commands.Code Block sudo systemctl start docker sudo systemctl enable docker
To confirm that Docker is active and running, use:
Code Block sudo systemctl status docker
Set up the Kubernetes Repository
...
Since the Kubernetes packages aren’t present in the official CentOS 7 repositories, we will need to add a new repository file. Use the following command to create the file and open it for editing:
Code Block |
---|
sudo vi /etc/yum.repos.d/kubernetes.repo |
Once the file is open, press the I key to enter insert mode and paste the following contents:
Code Block |
---|
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg |
Once pasted, press escape to exit insert mode. Then enter :x
to save the file and exit.
- Cluster see JS7 - How to install a Kubernetes Cluster.
- With the Kubernetes Cluster being up and running users can use YAML deployment files to deploy JS7 products.
Deployment Files
The YAML sample files for deployment to
...
Install Kubelet on CentOS 7
The first core module that we need to install on every node is Kubelet. Use the following command to do so:
Code Block sudo yum install -y kubelet
Install kubeadm and kubectl on CentOS 7
kubeadm, the next core module, which has to be installed. Use the following command:
Code Block |
---|
sudo yum install -y kubeadm |
(Note that kubeadm automatically installs kubectl as a dependency)
...
Disable swap
For Kubelet to work, we also need to disable swap. The swap can be disabled using the below commands:
Code Block sudo swapoff -a sudo sed -i '/ swap / s/^/#/' /etc/fstab
...
Initialize Kubeadm and start the Kubernetes cluster
When we initialize the kubeadm directly, then the kubeadm throws the error:
Code Block Some fatal errors occurred: [ERROR CRI]: container runtime is not running Status from runtime service failed” err=”rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.RuntimeService”
To resolve the above error, it is required to delete the config.tomal file and restart contained using the below steps:
Code Block sudo rm /etc/containerd/config.toml systemctl restart containerd
Initialize Kubeadm and Create required directories and start managing Kubernetes cluster
Code Block sudo kubeadm init mkdir $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config export KUBECONFIG=/etc/kubernetes/admin.conf
Enable and restart docker and Kubernetes services.
Code Block sudo systemctl enable docker.service sudo service kubelet restart sudo chown -R centos:centos kubernetes/
Set up Pod network for the Cluster.
Code Block kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml kubectl get nodes
Following the above steps, the setup of the Kubernetes cluster is successful. Now you can create the Kubernetes YAML files and deploy the JS7 on this Kubernetes cluster.
Deploying JS7 on Kubernetes
The example YAML files of Kubernetes are attached to the article.
Download the attached zip file. The folder structure includes three files:archive file: js7-kubernetes.zip
The archive includes the following files.
Deployment of JS7 Products: js7-deployment.yaml
...
Code Block | |||||
---|---|---|---|---|---|
|
...
| ||
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 |
...
" - 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 env: - name: RUN_JS_JAVA_OPTIONS value: "-Xmx256m" - name: RUN_JS_USER_ID value: "0:0" |
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:
- The
js7joc
container runs thejoc-2-5-1
image and exposes port4446
. It uses a ConfigMap with the namehibernate-config
to specify a volume mounted to the/var/sos-berlin.com/js7/joc/resources/joc
directory. The deployment file specifies a number of environment variables, includingRUN_JS_JAVA_OPTIONS
,RUN_JS_USER_ID
, andRUN_JS_ID
. - The
js7con
container runs thecontroller-2-5-1
image and exposes port4444
. It sets the environment variablesRUN_JS_JAVA_OPTIONS
,RUN_JS_USER_ID
, andRUN_JS_ID
. - The
js7agent
container runs theagent-2-5-1
image and exposes port4445
. It sets the environment variablesRUN_JS_JAVA_OPTIONS
,RUN_JS_USER_ID
, andRUN_JS_ID
.
The following implications apply:
- 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 recommendedRUN_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 product. A value0:0
indicates the root account and root group, a value1000:1000
specifies a user account with the given User ID and Group ID. For details see JS7 - Running Containers for User Accounts.RUN_JS_ID
: specifies the Controller ID which is a unique identifier for a Standalone Controller or Controller Cluster.
For the
js7joc
container the volumeMounts element specifies thehibernate-config
ConfigMap which is mounted to the/var/sos-berlin.com/js7/joc/resources/joc
directory.
Configuration for Port Forwarding: js7-service.yaml
...
Code Block | |||||
---|---|---|---|---|---|
|
...
| ||
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 | |||||
---|---|---|---|---|---|
|
...
| ||
<?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 with the JS7 database users To make the Kubernetes cluster run according to your database environment, you can adjust the hibernate.cfg.xml
file with your database credentials. The default file is MySql. You can use the hibernate.cfg.xml files of the other database from JS7 - Database.
The zip file, including the above configuration files, is that specifies the database connection and that 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 ConfigMap and to pass the
Open CMD from the folder where you unzip the attached ZIP.To create a config map and pass the and to pass this
hibernate.cfg.xml
file to the mount directory of the container, follow the below command.Code Block kubectl create configmap hibernate-config --from-file=hibernate.cfg.xml
To Run the
js7-deployment.yaml
file to create the service of deployment for the JS7 configuration, you need to run the js7-service.yaml file:Code Block kubectl create -f js7-deployment.yaml
To Run the
js7-service.yaml
file to create the deployment of service for the JS7 configuration, you need to run the js7-deployment.yaml file:Code Block kubectl create -f js7-service.yaml
Once both the YAML files are executed successfully, you users can get check the podPods' s status. The Kubectl Get Pod is a following command that displays the pods Pods running in the Kubernetes clusterCluster.
Code Block kubectl get pods
Once both the YAML files are executed successfully, you users can describe Pod and check each step in check the steps from the YAML file is executed successfully or not. The Kubectl Describe Pod is a command that describes any resource executed to create the Pod. The following command displays resources used in Kubernetes. It shows data on from a single or even resource and from a collection of resources.
Code Block kubectl describe pods
To The following command can be executed to check the IP address and Port of the running JOC Cockpit, execute the kubectl get service commandport of JS7 products.
Code Block kubectl get service
Further Resources
- JS7 - How to install a Kubernetes Cluster
- JS7 - Running Containers for User Accounts
- JS7 - Build Container Images