X
    Categories: Devops

Kubernetes: Installation and Overview on CentOS 8

Introduction
Kubernetes, often abbreviated as K8s, is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. Originally developed by Google and now maintained by the Cloud Native Computing Foundation (CNCF), Kubernetes has become the de facto standard for container orchestration. This article provides an overview of Kubernetes and a step-by-step guide on how to install it on a CentOS 8 server.

Kubernetes Overview
Key Concepts
Before diving into the installation process, it’s essential to understand some fundamental Kubernetes concepts:

Nodes: Kubernetes clusters consist of one or more physical or virtual machines known as nodes. There are two types of nodes:

Master Node: Controls and manages the Kubernetes cluster.
Worker Node: Runs containers and workloads.
Pods: The smallest deployable unit in Kubernetes. A pod can contain one or more containers that share the same network namespace and storage.

Services: Provide a stable IP address and DNS name for a set of pods, allowing them to communicate with each other.

ReplicaSets: Ensure that a specified number of replicas (pods) are running at any given time.

Deployment: A higher-level resource that manages ReplicaSets, making it easier to deploy and update applications.

ConfigMaps and Secrets: Used to manage configuration data and sensitive information, respectively, as key-value pairs.

Namespaces: Used to organize and isolate resources within a cluster.

Kubernetes Architecture
Kubernetes follows a master-node architecture:

Master Node: The control plane of the cluster, consisting of several components, including the API Server (exposes the Kubernetes API), etcd (a distributed key-value store for configuration data), the Scheduler (assigns pods to nodes), and the Controller Manager (ensures the desired state of the system).

Worker Nodes: These are where your containers run. They contain the Kubelet (manages the containers on a node), the Kube Proxy (manages network traffic), and the Container Runtime (such as Docker or containerd).

Installation of Kubernetes on CentOS 8
Installing Kubernetes on CentOS 8 involves several steps. We’ll go through the process step by step:

Step 1: Prerequisites
Before you begin, ensure you have the following:

  1. A CentOS 8 server (physical or virtual) with root access.
  2. At least 2GB of RAM (though 4GB or more is recommended).
  3. A static IP address for your server.
  4. Docker installed on your server.


Step 2: Disable SELinux
Kubernetes doesn’t work well with SELinux in enforcing mode. Temporarily set it to permissive mode by editing /etc/selinux/config:

SELINUX=permissive

Reboot the server to apply the changes:


Step 3: Install Kubernetes Components
Kubernetes components like kubelet, kubeadm, and kubectl can be installed using the package manager yum. First, add the Kubernetes repository:


cat < /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
EOF


Then, install the required packages:

yum install -y kubelet kubeadm kubectl

Step 4: Start and Enable Services
Enable and start the kubelet service:


systemctl enable kubelet
systemctl start kubelet


Step 5: Initialize the Kubernetes Cluster
On the master node, run the following command to initialize the cluster. Replace with your server’s IP address:


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


After the command completes, it will provide instructions on how to set up the kubectl configuration for your user. Follow these instructions.

Step 6: Install a Pod Network Plugin
To enable pod-to-pod communication within the cluster, you need to install a pod network plugin. A popular choice is Calico:

kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml


Step 7: Join Worker Nodes
On each worker node, run the kubeadm join command provided after running kubeadm init on the master node.

Step 8: Verification
To verify that your cluster is up and running, run:


kubectl get nodes


You should see your master node and worker nodes listed and in the “Ready” state.

Conclusion
Kubernetes is a powerful container orchestration platform that can help you manage and scale your containerized applications effectively. While the installation process may seem complex at first, following the steps outlined in this essay should help you set up a Kubernetes cluster on a CentOS 8 server. Once your cluster is up and running, you can start deploying and managing containerized workloads with ease, unlocking the full potential of containerization in your environment.

LinuxAdmin.io
0 0 votes
Article Rating
LinuxAdmin.io:
Related Post