Install Kubernetes On Centos
In Kubernetes setup we have one master node and multiple slave nodes. Cluster nodes is known as worker node or Minion. From the master node we manage the cluster and its nodes using ‘kubeadm‘ and ‘kubectl‘ command. In this tutorial we will show you how to install kubernetes on centos 7. For you don’t know kubernetes, kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.
Kubernetes is an open-source system used for automating the deployment, scaling, and management of containerized applications. Kubernetes is enterprise-ready and can be installed on various platforms. I've already touched on how to get Kubernetes up and running on Ubuntu Server (see 'How to quickly install Kubernetes on Ubuntu'). This time around, I'm going to walk you through the process of setting up a Kubernetes cluster on CentOS 7. This makes for an outstanding one-two punch for your containerized applications.
SEE: Quick glossary: Storage (Tech Pro Research)
What you'll need
I'll be demonstrating with three CentOS 7 servers (at the following IP addresses):
- kubemaster: 192.168.1.99
- kube2: 192.168.1.109
- kube3: 192.168.1.167
Make sure to change the IP addresses to fit your needs. You'll also need root access on all three servers. I do suggest first testing this on virtual machines, before attempting the installation on production servers.
With that said, let's install.
Pre-installation configuration
The first thing you want to do is configure your /etc/hosts file, so that each machine can ping one another via hostname. So on each machine, issue the su command (to change to the root user) and then edit the file with the command nano /etc/hosts. At the end of the file, append the following (again, adjusting the IP addresses to fit your needs):
Save and close that file.
Disable SELinux and swap
Now we need to disable both SELinux and swap. On all three machines, issue the following commands:
Next, disable swap (on all three machines) with the following command:
We must also ensure that swap isn't re-enabled during a reboot on each server. Open up the /etc/fstab and comment out the swap entry like this:
Enable br_netfilter
For our next trick, we'll be enabling the br_netfilter kernel module on all three servers. This is done with the following commands:
Install Docker-ce
Kubernetes Vs Docker Swarm
It's time to install the necessary Docker tool. On all three machines, install the Docker-ce dependencies with the following command:
Next, add the Docker-ce repository with the command:
Install Docker-ce with the command:
Install Kubernetes
This is also done on all three servers. First we need to create a repository entry for yum. To do this, issue the command nano /etc/yum.repos.d/kubernetes.repo and then add the following contents:
Save and close that file. Install Kubernetes with the command:
Once the installation completes, reboot all three machines. As soon as each machine has rebooted, log back in and su to the root user.
Cgroup changes
Now we need to ensure that both Docker-ce and Kubernetes belong to the same control group (cgroup). By default, Docker should already belong to cgroupfs (you can check this with the command docker info | grep -i cgroup). To add Kubernetes to this, issue the command:
Restart the systemd daemon and the kubelet service with the commands:
Initialize the Kubernetes cluster
We're now ready to initialize the Kubernetes cluster. This is done on kubemaster (and only on that machine). On kubemaster, issue the command (again, adjusting the IP addresses to fit your needs):
When this completes (it'll take anywhere from 30 seconds to 5 minutes), the output should include the joining command for your nodes (Figure A).
Figure A
Once that completes, head over to kube2 and issue the command (adjusting the IP address to fit your needs):
Where TOKEN and DISCOVERY_TOKEN are the tokens displayed after the initialization command completes.
Configuring Kubernetes
Before Kubernetes can be used, we must take care of a bit of configuration. Issue the following three commands (to create a new .kube configuration directory, copy the necessary configuration file, and give the file the proper ownership):
Deploy flannel network
Now we must deploy the flannel network to the cluster with the command:
Checking your nodes
Once the deploy command completes, you should be able to see both nodes on the master, by issuing the command kubectl get nodes (Figure B).
Figure B
All ready
Congratulations, you now have a Kubernetes cluster ready for pods. I'll be demonstrating how to deploy your first pod when next we visit the Kubernetes topic. Until then, happy clustering!
Also see
- How to deploy NGINX on a Kubernetes cluster (TechRepublic)
- 10 Kubernetes tips for getting the most out of the open source container system (TechRepublic)
- How to use Antsle to quickly deploy a virtual machine (TechRepublic)
- How to easily edit a network connection on a CentOS 7 minimal installation (TechRepublic)
- Red Hat introduces Kubernetes Operators software development toolkit (ZDNet)
In this blog post, I’ll show you how to install Minikube on CentOS. Minikube is a platform you can use to test kubernetes clusters on your local machine or in a virtual machine.
Let’s start off with a fresh Install of CentoOS 7 on a virtual machine using a minimal install. If you need some help getting a Linux VM us, check out my Pluralsight course here to help you with that. You will want to ensure this virtual machine has the resource you want to run the container/pods scenarios you’d like to worth with. My configuration is dual vCPU with 10GB of RAM.
Since we’re running a hypervisor inside a VM, you will need to enable nested virtualization in your virtual machine configuration. Cloud friends, this will not apply to you as most cloud providers do not have this enabled.
Let’s get started with some prerequisites!
SSH into your virtual machine. I don’t have DNS internally…so I am using the IP address of the virtual machine
demo:~ aen$ ssh aen@192.168.1.69
sudo yum group install “Virtualization Host”
Once the installation is complete, confirm the KVM kernel module is loaded by listing the running kernel modules with lsmod then grepping for the string kvm.
lsmod | grep kvm
kvm_intel 183720 0
kvm 578558 1 kvm_intel
irqbypass 13503 1 kvm
Next we’ll install the KVM2 Driver Plugin for minikube
curl -Lo docker-machine-driver-kvm2 https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2
&& chmod +x docker-machine-driver-kvm2
&& sudo cp docker-machine-driver-kvm2 /usr/local/bin/
&& rm docker-machine-driver-kvm2
Now, that we have the prep work out of the way, let’s install kubectl. This is the command line utility you will use to interact with your Kubernetes cluster.
sudo yum install kubernetes-client
Next we’ll Install Minikube on our VM
sudo curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.29.0/minikube-linux-amd64
&& chmod +x minikube
&& sudo cp minikube /usr/local/bin/
&& rm minikube
With everything installed, let’s launch minikube – this will download the Minicube ISO, which is a virtual machine containing the minikube cluster.
[aen@k8s1 ~]$ minikube start –vm-driver kvm2
Starting local Kubernetes v1.10.0 cluster…
Starting VM…
Downloading Minikube ISO
171.87 MB / 171.87 MB [] 100.00% 0s
Getting VM IP address…
Moving files into cluster…
Downloading kubeadm v1.10.0
Downloading kubelet v1.10.0
Finished Downloading kubelet v1.10.0
Finished Downloading kubeadm v1.10.0
Difference Between Kubernetes And Docker
Setting up certs…
Connecting to cluster…
Setting up kubeconfig…
Starting cluster components…
Kubectl is now configured to use the cluster.
Kubernetes And Docker
Loading cached images from config file.
Install Kubernetes On Centos
Finally lets check on your cluster configuration to ensure everything is online.
[aen@k8s1 ~]$ kubectl cluster-info
Kubernetes master is running at https://192.168.39.134:8443
CoreDNS is running at https://192.168.39.134:8443/api/v1/proxy/namespaces/kube-system/services/kube-dns
To further debug and diagnose cluster problems, use ‘kubectl cluster-info dump’.
With that, you have a functioning Kubernetes cluster inside your virtual machine which you can use for testing and development of your Kubernetes based solutions.
The post Installing minikube on CentOS appeared first on Centino Systems Blog.