Deploy Kubernetes With Kubeadm on CentOS 7

Overview

This article is meant to help you get a Kubernetes cluster up and running with kubeadm in no time. This guide will be deploying two servers, one master and one worker, however you can deploy as many servers as you would like.

What is kubeadm?

Kubeadm is a tool developed by Kubernetes which allows you to get a minimum viable cluster up and running by following best practices. It will only bootstrap your cluster, not provision machines. Things such as addons, the Kubernetes dashboard, monitoring solutions and so on are not something kubeadm will do for you.

Prerequisites

There are a few requirements for the servers we will deploy. One or more machines running a deb/rpm-compatible OS. We will be using CentOS.

  • 2 GB or more of RAM per machine
  • 2 CPUs or more on the master

Full network connectivity among all machines in the cluster

The two servers deployed in this guide are the following: - 1 CPU 2GB RAM with CentOS 7 (Worker node) - 2 CPU 4GB RAM with CentOS 7 (Master node)

With this amount of RAM on both servers, Kubernetes will have plenty of room to breathe.

Configuring the worker and master

Here are the steps we will have to take on both the master and worker node:

  • Yum update & packages
  • Install docker
  • Disable selinux
  • Disable swap
  • Disable Firewall
  • Update IPTables
  • Install kubelet/kubeadm/kubectl

Installing Docker

We'll be using version 1.14 of Kubernetes in this tutorial. For this version, Kubernetes recommends running Docker version 18.06.2. Be sure to check the recommended Docker version for your version of Kuberenetes

We will be adding the Docker repository to yum and specifically installing 18.06.2. Once Docker is installed, we'll need to configure the docker daemon to the settings recommended by Kubernetes.

###Add yum-utils, if not installed already
yum install yum-utils

###Add Docker repository.
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

###Install Docker CE.
yum update && yum install docker-ce-18.06.2.ce

###Create /etc/docker directory.
mkdir /etc/docker

###Setup daemon.
cat > /etc/docker/daemon.json <<EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ]
}
EOF

mkdir -p /etc/systemd/system/docker.service.d

###Restart Docker
systemctl daemon-reload
systemctl enable docker.service
systemctl restart docker

Disable SELinux

Since we are using CentOS we need to disable SELinux. This is necessary to allow containers access to the host filesystem.

setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=disable/' /etc/selinux/config

Disable Swap

Swap needs to be disabled to allow kubelet to work properly.

sed -i '/swap/d' /etc/fstab
swapoff -a

Disable Firewall

Kubernetes uses IPTables to handle inbound and outbound traffic - so to avoid any issues we disable firewalld.

systemctl disable firewalld
systemctl stop firewalld

Update IPTables

Kubernetes recommends that we ensure net.bridge.bridge-nf-call-iptables is set to 1. This is due to issues where REHL/CentOS 7 has had issues with traffic being rerouted incorrectly due to bypassing iptables.

cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system

Install kubelet/kubeadm/kubectl

We will need to add the kubernetes repo to yum. Once we do that we just need to run the install command and enable kubelet.

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[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
exclude=kube*
EOF

yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
systemctl enable --now kubelet

Now we have fully configured both our master and worker node. We can now initialize our master node and join our worker nodes to the master!

Note If you wanted to add more worker nodes the process above would have to be done on all of those nodes as well.

Master Node setup

We want to initialize our master node by running the following command. You'll want to substitute your master node's IP address in the command below. Additionally, we'll pass in the pod-network-cidr to make it easier for us later when we install the Flannel network overlay.

kubeadm init --apiserver-advertise-address=YOUR_IP_HERE --pod-network-cidr=10.244.0.0/16

This may take a while to complete but once it is completed you will see something similar at the end of the output like the following.

kubeadm join YOUR_IP:6443 --token 4if8c2.pbqh82zxcg8rswui \
--discovery-token-ca-cert-hash sha256:a0b2bb2b31bf7b06bb5058540f02724240fc9447b0e457e049e59d2ce19fcba2

This command is what your worker nodes need to execute to join the cluster, so take note of it.

Next up is Flannel. Flannel is what allows pod to pod communication. There are various other types of network overlays that you can install but for simplicity this guide will use Flannel.

Copy the kube/config file over to your $Home so you can execute kubectl commands.

mkdir $HOME/.kube
cp /etc/kubernetes/admin.conf $HOME/.kube/config

One final step on the master node is to install Flannel. Run the following command.

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

With this config copied over you will be able to run kubectl get cs and get a response.

NAME                 STATUS    MESSAGE             ERROR
scheduler            Healthy   ok
controller-manager   Healthy   ok
etcd-0               Healthy   {"health":"true"}

Your master node is set and ready to go. Onto the worker node!

Worker Node

At this point there is no extra work that is necessary on the worker node. All we need to do is run the kubeadm join command that we got from our kubeadm init output.

If by some chance you misplaced the kubeadm join command you can generate another one on the master node by running kubeadm token create --print-join-command

Once you run the kubeadm join command, if you run kubectl get nodes on master you will see a similar output to the following.

NAME          STATUS   ROLES    AGE    VERSION
k8-master   Ready    master   107m   v1.14.2
k8-worker   Ready    <none>   45m    v1.14.2

Wrapping up

Just like that you have bootstrapped a Kubernetes cluster using kubeadm. You could also do this with private networks. Vultr, as well as other cloud providers, allow for private networks. Also, if you want to execute kubectl commands from your local machine against your cluster, you can accomplish this by having kubectl installed locally and pull down the .kube/config file from the cluster to your local machine in $HOME/.kube/config.

Hopefully this guide helps you traverse kubeadm and gets you playing with kubernetes in no time!

Useful links:



Cómo instalar MODX Revolution en un CentOS 7 LAMP VPS

Cómo instalar MODX Revolution en un CentOS 7 LAMP VPS

¿Usando un sistema diferente? MODX Revolution es un sistema de gestión de contenido (CMS) de nivel empresarial rápido, flexible, escalable, gratuito y de código abierto escrito i

Configure su propia red privada con OpenVPN

Configure su propia red privada con OpenVPN

Vultr le ofrece una increíble conectividad de red privada para servidores que se ejecutan en la misma ubicación. Pero a veces quieres dos servidores en diferentes países.

How to Install and Configure CyberPanel on Your CentOS 7 Server

How to Install and Configure CyberPanel on Your CentOS 7 Server

Using a Different System? Introduction CyberPanel is one of the first control panels on the market that is both open source and uses OpenLiteSpeed. What thi

Install eSpeak on CentOS 7

Install eSpeak on CentOS 7

Using a Different System? ESpeak can generate text-to-speech (TTS) audio files. These can be useful for many reasons, such as creating your own Turin

Cómo instalar Thelia 2.3 en CentOS 7

Cómo instalar Thelia 2.3 en CentOS 7

¿Usando un sistema diferente? Thelia es una herramienta de código abierto para crear sitios web de comercio electrónico y administrar contenido en línea, escrito en PHP. Código fuente de Thelia i

Monitoree sus dispositivos usando LibreNMS en CentOS 7

Monitoree sus dispositivos usando LibreNMS en CentOS 7

¿Usando un sistema diferente? LibreNMS es un completo sistema de monitoreo de red de código abierto. Utiliza SNMP para obtener los datos de diferentes dispositivos. Una variedad

Cómo instalar Cacti 1.1 en CentOS 7

Cómo instalar Cacti 1.1 en CentOS 7

Cacti es una herramienta de gráficos y monitoreo de red de código abierto y libre escrita en PHP. Con la ayuda de RRDtool (herramienta de base de datos Round-Robin), Cacti se puede usar t

Cómo usar Sudo en Debian, CentOS y FreeBSD

Cómo usar Sudo en Debian, CentOS y FreeBSD

Usar un usuario sudo para acceder a un servidor y ejecutar comandos a nivel raíz es una práctica muy común entre Linux y Unix Systems Administrator. El uso de un sud

Cómo supervisar de forma segura los servidores remotos con Zabbix en CentOS 7

Cómo supervisar de forma segura los servidores remotos con Zabbix en CentOS 7

¿Usando un sistema diferente? Zabbix es un software gratuito y de código abierto listo para empresas que se utiliza para monitorear la disponibilidad de sistemas y componentes de red.

Cómo instalar MODX CMS y Nginx en CentOS 7

Cómo instalar MODX CMS y Nginx en CentOS 7

MODX es un sistema de gestión de contenido gratuito y de código abierto escrito en PHP. Utiliza MySQL o MariaDB para almacenar su base de datos. MODX está diseñado para el negocio i

Cómo instalar YOURLS en CentOS 7

Cómo instalar YOURLS en CentOS 7

YOURLS (Your Own URL Shortener) es una aplicación de análisis de datos y acortamiento de URL de código abierto. En este artículo, cubriremos el proceso de instalación

Setup Nginx-RTMP on CentOS 7

Setup Nginx-RTMP on CentOS 7

Using a Different System? RTMP is great for serving live content. When RTMP is paired with FFmpeg, streams can be converted into various qualities. Vultr i

Cómo instalar LimeSurvey en CentOS 7

Cómo instalar LimeSurvey en CentOS 7

LimeSurvey es una herramienta de encuestas en línea gratuita y de código abierto que se utiliza ampliamente para publicar encuestas en línea y para recopilar comentarios de encuestas. En este artículo, voy a

Cómo instalar Vanilla Forum en CentOS 7

Cómo instalar Vanilla Forum en CentOS 7

¿Usando un sistema diferente? Vanilla forum es una aplicación de foro de código abierto escrita en PHP. Es totalmente personalizable, fácil de usar y admite dispositivos externos.

Instalación de Netdata en CentOS 7

Instalación de Netdata en CentOS 7

¿Usando un sistema diferente? Netdata es una estrella en ascenso en el campo del monitoreo de métricas del sistema en tiempo real. En comparación con otras herramientas del mismo tipo, Netdata:

Cómo instalar el servidor Just Cause 2 (JC2-MP) en CentOS 7

Cómo instalar el servidor Just Cause 2 (JC2-MP) en CentOS 7

En este tutorial, aprende bien cómo configurar un servidor multijugador Just Cause 2. Requisitos previos Asegúrese de que el sistema esté completamente actualizado antes de comenzar

Cómo instalar Starbound Server en CentOS 7

Cómo instalar Starbound Server en CentOS 7

¿Usando un sistema diferente? En este tutorial, explicaré cómo configurar un servidor Starbound en CentOS 7. Requisitos previos Necesitas tener este juego contigo

Instalación y configuración de ZNC en CentOS 7

Instalación y configuración de ZNC en CentOS 7

ZNC es un enlace IRC gratuito y de código abierto que permanece permanentemente conectado a una red para que los clientes puedan recibir mensajes enviados mientras están desconectados. Thi

Cómo instalar Django en CentOS 7

Cómo instalar Django en CentOS 7

Django es un marco de Python popular para escribir aplicaciones web. Con Django, puede crear aplicaciones más rápido, sin reinventar la rueda. Si tu quieres

Cómo configurar ionCube Loader en CentOS 7

Cómo configurar ionCube Loader en CentOS 7

ionCube Loader es una extensión PHP que permite que un servidor web ejecute archivos PHP que han sido codificados usando ionCube Encoder y es necesario para ejecutar

¿Puede la IA luchar con un número cada vez mayor de ataques de ransomware?

¿Puede la IA luchar con un número cada vez mayor de ataques de ransomware?

Los ataques de ransomware van en aumento, pero ¿puede la IA ayudar a lidiar con el último virus informático? ¿Es la IA la respuesta? Lea aquí, sepa que la IA es una bendición o una perdición

ReactOS: ¿Es este el futuro de Windows?

ReactOS: ¿Es este el futuro de Windows?

ReactOS, un sistema operativo de código abierto y gratuito, está aquí con la última versión. ¿Puede satisfacer las necesidades de los usuarios de Windows de hoy en día y acabar con Microsoft? Averigüemos más sobre este estilo antiguo, pero una experiencia de sistema operativo más nueva.

Manténgase conectado a través de la aplicación de escritorio WhatsApp 24 * 7

Manténgase conectado a través de la aplicación de escritorio WhatsApp 24 * 7

Whatsapp finalmente lanzó la aplicación de escritorio para usuarios de Mac y Windows. Ahora puede acceder a Whatsapp desde Windows o Mac fácilmente. Disponible para Windows 8+ y Mac OS 10.9+

¿Cómo puede la IA llevar la automatización de procesos al siguiente nivel?

¿Cómo puede la IA llevar la automatización de procesos al siguiente nivel?

Lea esto para saber cómo la Inteligencia Artificial se está volviendo popular entre las empresas de pequeña escala y cómo está aumentando las probabilidades de hacerlas crecer y dar ventaja a sus competidores.

La actualización complementaria de macOS Catalina 10.15.4 está causando más problemas que resolver

La actualización complementaria de macOS Catalina 10.15.4 está causando más problemas que resolver

Recientemente, Apple lanzó macOS Catalina 10.15.4, una actualización complementaria para solucionar problemas, pero parece que la actualización está causando más problemas que conducen al bloqueo de las máquinas Mac. Lee este artículo para obtener más información

13 Herramientas comerciales de extracción de datos de Big Data

13 Herramientas comerciales de extracción de datos de Big Data

13 Herramientas comerciales de extracción de datos de Big Data

¿Qué es un sistema de archivos de diario y cómo funciona?

¿Qué es un sistema de archivos de diario y cómo funciona?

Nuestra computadora almacena todos los datos de una manera organizada conocida como sistema de archivos de diario. Es un método eficiente que permite a la computadora buscar y mostrar archivos tan pronto como presiona buscar.

Singularidad tecnológica: ¿un futuro lejano de la civilización humana?

Singularidad tecnológica: ¿un futuro lejano de la civilización humana?

A medida que la ciencia evoluciona a un ritmo rápido, asumiendo muchos de nuestros esfuerzos, también aumentan los riesgos de someternos a una singularidad inexplicable. Lea, lo que la singularidad podría significar para nosotros.

Una mirada a 26 técnicas analíticas de Big Data: Parte 1

Una mirada a 26 técnicas analíticas de Big Data: Parte 1

Una mirada a 26 técnicas analíticas de Big Data: Parte 1

El impacto de la inteligencia artificial en la atención médica 2021

El impacto de la inteligencia artificial en la atención médica 2021

La IA en la salud ha dado grandes pasos desde las últimas décadas. Por tanto, el futuro de la IA en el sector sanitario sigue creciendo día a día.