Create Kubernetes Cluster with Kubeadm using ansible on CentOS 8
Kubernetes is a container orchestration system that manages containers at scale.
Kubeadm automates the installation and configuration of Kubernetes components such as the API server, Controller Manager, and Kube DNS.
-
- Install python3
sudo yum install python3
- Install git
sudo yum install git
- Install ansible
sudo yum install epel-release
,sudo yum install ansible
- Set Passwordless authentication between master and hosts (kuberenetes nodes)
ssh-keygen
,ssh-copy-id root@IP_address
- Add inventory file has all hosts
[masters] master ansible_host=node_IP ansible_user=root [workers] worker1 ansible_host=node_IP ansible_user=root
- Install python3
-
- in
/etc/hosts
add
master_IP master masternode_hostname worker_IP worker workernode_hostname
- in
-
These configurations are done on both master and worker Kubernetes nodes
- Disable
SELinux
service - Disable
Swapping on
- Install
CRI-O
a Container runtime - Install
Kubeadm
a CLI tool that will install and configure the various components of a cluster. - Install
kubelet
a system service that runs on all nodes and handles node-level operations. - Install
kubectl
a CLI tool used for issuing commands to the cluster through its API Server.
- Disable
-
- Initialize the cluster by running
kubeadm init
- Create a
.kube
directory at/home/cloud
. This directory will hold configuration information such as the admin key files, which are required to connect to the cluster, and the cluster’s API address.
note: cloud is a non-root user should be added before - Copy the
/etc/kubernetes/admin.conf
file that was generated fromkubeadm init
to your non-root cloud user’s home directory. - Run
kubectl apply
to installFlannel
.
- Initialize the cluster by running