Page History
Table of Contents |
---|
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, for details see JS7 - How to deploy to a Kubernetes Cluster
There are several ways how to set up a Kubernetes cluster. Find an example for the basic steps to install a Kubernetes cluster on CentOS 7 from the following chapters.
Setting up a Kubernetes Cluster
Install Docker on CentOS 7
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 Docker Repository for CentOS
Code Block sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Install the latest Docker version for CentOS
Code Block sudo yum install docker-ce
After successful installation the output will include the string
Complete!
You may be prompted to accept the GPG key. This is to verify that the fingerprint matches. 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
Manage Docker service
With Docker being installed the 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
To check that Docker is up and running use the command:
Code Block sudo systemctl status docker
Set up the Kubernetes Repository
Since the Kubernetes packages aren’t present in the official CentOS 7 repositories 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
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
kubeadm
is the next core module that has to be installed. Use the following command:Code Block sudo yum install -y kubeadm
Note that
kubeadm
automatically installskubectl
as a dependency.Disable swap 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
When initializing
kubeadm
directly thenkubeadm
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”
To resolve the above problem users should delete the
config.tomal
file and restart containerd using the following commands:Code Block sudo rm /etc/containerd/config.toml systemctl restart containerd
Initialize
kubeadm
, create required directories and 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
Enable and restart Docker and Kubernetes services from systemd.
Code Block sudo systemctl enable docker.service sudo service kubelet restart sudo chown -R centos:centos kubernetes/
Set up pod network for the Kubernetes cluster.
Code Block kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af15c65e414cf26827915/Documentation/kube-flannel.yml kubectl get nodes
With the above steps the setup of the Kubernetes cluster is completed. In a next step users can create the Kubernetes YAML files to deploy JS7 components to the Kubernetes cluster.