Cloud Native 16 min read

Step-by-Step Guide to Installing Kubernetes v1.16.0 on CentOS 7 with Docker and Flannel

This tutorial walks through preparing the environment, installing Docker‑CE 18.09.9, configuring prerequisite settings, deploying Kubernetes v1.16.0 master and node components, initializing the cluster, retrieving join commands, and finally installing Flannel networking to achieve a ready‑state cluster on CentOS 7 virtual machines.

Architecture Digest
Architecture Digest
Architecture Digest
Step-by-Step Guide to Installing Kubernetes v1.16.0 on CentOS 7 with Docker and Flannel

This article documents a complete, hands‑on process for building a Kubernetes v1.16.0 cluster on CentOS 7 virtual machines, starting from Docker‑CE installation to final network configuration.

1. Install Docker‑CE 18.09.9 (All Nodes)

# Install Docker prerequisites
yum install -y yum-utils device-mapper-persistent-data lvm2
# Add Alibaba Cloud Docker repo
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Install specific Docker version
yum install -y docker-ce-18.09.9-3.el7
# Enable and start Docker
systemctl enable docker && systemctl start docker

2. Set Kubernetes Pre‑conditions (All Nodes)

# Disable firewalld
systemctl disable firewalld
systemctl stop firewalld
# Disable SELinux temporarily and permanently
setenforce 0
sed -i 's/SELINUX=permissive/SELINUX=disabled/' /etc/sysconfig/selinux
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
# Turn off swap
swapoff -a
sed -i 's/.*swap.*/#&/' /etc/fstab
# Adjust kernel parameters for networking
cat <
/etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system

3. Install Kubernetes v1.16.0 Master Node

After Docker and the pre‑conditions are ready, configure the Alibaba Cloud Kubernetes repo and install the required binaries.

# Add Alibaba Cloud Kubernetes repo
cat <
/etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
# Install kubeadm, kubelet, kubectl (v1.16.0)
yum install -y kubeadm-1.16.0-0 kubelet-1.16.0-0 kubectl-1.16.0-0
# Enable kubelet service
systemctl enable kubelet && systemctl start kubelet

Initialize the master with a local image repository and the IP address that can be pinged from the node.

kubeadm init \
  --image-repository registry.aliyuncs.com/google_containers \
  --kubernetes-version v1.16.0 \
  --apiserver-advertise-address 192.168.99.104 \
  --pod-network-cidr=10.244.0.0/16 \
  --token-ttl 0

After successful initialization, configure kubectl for the regular user:

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

4. Install Kubernetes v1.16.0 Worker Node

Repeat Docker installation and pre‑condition steps on the worker, then install kubeadm, kubelet, and kubectl (same versions) and enable kubelet.

# Same repo setup as master
cat <
/etc/yum.repos.d/kubernetes.repo
... (same as above) ...
EOF
# Install binaries
yum install -y kubeadm-1.16.0-0 kubelet-1.16.0-0 kubectl-1.16.0-0
systemctl enable kubelet && systemctl start kubelet

Join the node to the cluster using the token command printed by the master (or regenerate it):

kubeadm token create --print-join-command

Execute the returned kubeadm join … command on the worker.

5. Install Flannel Networking (Master)

Apply the modified Flannel manifest (with quay‑mirror URLs) to the cluster:

kubectl apply -f kube-flannel.yml

After Flannel is deployed, the master and node should transition to the Ready state.

6. Completion

Verify the cluster status with kubectl get nodes ; all nodes should be Ready, indicating a functional Kubernetes v1.16.0 environment.

DockerKubernetesK8sCluster SetupCentOSFlannelv1.16
Architecture Digest
Written by

Architecture Digest

Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.