Versions Compared

Key

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

...

Introduction

  • JS7 can be set up using for use with a Kubernetes cluster on a Server. Using the Linux - based JS7 images for Docker® containers which ship with a current Alpine base image and OpenJDK. in the articles listed below.
  • Users deploy JS7 components You can run an application by creating a Kubernetes Deployment object, and you can describe a Deployment in a YAML file. To do so we need to first install and set up the Kubernetes cluster, once it is completed you can use the deployment YAML files to deploy JS7.

...

There are several ways how to set up a Kubernetes Clustercluster. Find an example for the basic steps to install a Kubernetes cluster on CentOS  7 from the following chapters.The basic step which can be followed to install the Kubernetes cluster on Centos are:

Setting up a Kubernetes Cluster

Install Docker on

...

CentOS 7

...

  1. Update the package database

    Code Block
    sudo yum check-update
  2. Install the dependencies

    Code Block
    sudo yum install -y yum-utils device-mapper-persistent-data lvm2
  3. Add and enable the

    official

    Docker Repository

    to

    for CentOS

    7

    Code Block
    sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  4. Install the latest Docker version

    on

    for CentOS

    7

    Code Block
    sudo yum install docker-ce
  5. A

    After successful installation the output will

    be concluded with a

    include the string  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

    A fingerprint can look like this, if you consider the fingerprint being correct, accept it

    .

    :

    Code Block
    060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
  6. Manage Docker service

    Now

    With Docker

    is

    being installed

    , but

    the

    service is not yet running

    systemd service has to be started. Start and enable Docker from systemd using the following commands

    :

    Code Block
    sudo systemctl start docker
    sudo systemctl enable docker
  7. To

    confirm

    check that Docker is

    active

    up and running

    ,

    use the command:

    Code Block
    sudo systemctl status docker

Set up the Kubernetes Repository

  1. Since the Kubernetes packages aren’t present in the official CentOS 7 repositories

    , we will need

    users have 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
  2. 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.

Install

...

kubelet on CentOS 7

...

kubelet is the first core module

...

to

...

be installed on every Kubernetes cluster node

...

. Use the following command

...

:

Code Block
sudo yum install -y kubelet

Install kubeadm and kubectl on CentOS 7

  1. kubeadm

    ,

    is the next core module

    , which

    that has to be installed. Use the following command:

    Code Block
    sudo yum install -y kubeadm
    (

    Note that kubeadm automatically installs kubectl as a dependency

    )

    .


  2. Disable swap

    For Kubelet to work, we also need to disable swap. The swap can be disabled using

    by use of the below commands:

    Code Block
    sudo swapoff -a
    sudo sed -i '/ swap / s/^/#/' /etc/fstab

Initialize

...

kubeadm and start the Kubernetes cluster

  1. When

    we initialize the

    initializing kubeadm directly

    ,

    then

    the

    kubeadm

    throws

    might raise 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”
  2. To resolve the above

    error, it is required to

    problem users should delete the config.tomal file and restart

    contained

    containerd using the

    below steps

    following commands:

    Code Block
    sudo rm /etc/containerd/config.toml
    systemctl restart containerd
  3. Initialize

    Kubeadm and Create

    kubeadm, create required directories and

    start managing

    manage Kubernetes cluster configuration:

    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
  4. Enable and restart

    docker

    Docker and Kubernetes services from systemd.

    Code Block
    sudo systemctl enable docker.service
    sudo service kubelet restart
    sudo chown -R centos:centos kubernetes/
    
  5. Set up

    Pod

    pod network for the

    Cluster

    Kubernetes cluster.

    Code Block
    kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml
    kubectl get nodes

Following With the above steps , the setup of the Kubernetes cluster is successful. Now you completed. In a next step users can create the Kubernetes YAML files and to deploy JS7 components to 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:

    1. js7-deployment.yaml – This file is the deployment file for the JS7

      Code Block
      languageyml
      titleExample js7-deployment.yaml
      linenumberstrue
      collapsetrue
      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
    2. js7-service.yaml – This includes the configuration of port forwarding

      Code Block
      languageyml
      titleExample js7-service.yaml
      linenumberstrue
      collapsetrue
      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: {}
    3. hibernate.cfg.xml – This is the hibernate file for connection to the database.

      Code Block
      languageyml
      titleExample js7-service.yaml
      linenumberstrue
      collapsetrue
      <?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>

...

The zip file, including the above configuration files, is js7-kubernetes.zip. After downloading the attached file, follow the below steps to deploy the container:

...

Further Resources

...

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 create the service of the JS7 configuration, you need to run the js7-service.yaml file:

Code Block
kubectl create -f js7-deployment.yaml

...

To create the deployment of 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 can get the pod's status. The Kubectl Get Pod is a command that displays the pods running in the Kubernetes cluster.

Code Block
kubectl get pods

...

Once both the YAML files are executed successfully, you can describe Pod and check each step in the YAML file is executed successfully or not. The Kubectl Describe Pod is a command that describes any resource in Kubernetes. It shows data on a single or even a collection of resources.

Code Block
kubectl describe pods

To check the IP and Port of the running JOC Cockpit, execute the kubectl get service command.

...