Need To allow these ports in firewall.If you are deploying the cluster in Cloud you need to allow the port in network security group inbound rule.
firewall-cmd --permanent --add-port=6443/tcp
firewall-cmd --permanent --add-port=2379-2380/tcp
firewall-cmd --permanent --add-port=10250/tcp
firewall-cmd --permanent --add-port=10251/tcp
firewall-cmd --permanent --add-port=10252/tcp
firewall-cmd --permanent --add-port=10255/tcp
firewall-cmd –-reload
modprobe br_netfilter
echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables
Disable Swap and Selinux.
swapoff -a
setenforce 0
sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
Install Docker-ce
# dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
# dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
# dnf install docker-ce
# systemctl enable docker
# systemctl start docker
Install Kubernets (Kubeadm)
Add Kubernetes repositories manually.
# 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
EOF
With the package repo now ready, We can go ahead and install kubeadm package.
# dnf install kubeadm -y
# systemctl enable kubelet
# systemctl start kubelet
Create A Control-plane master with Kubeadm.
# kubeadm init
Setup Pod Networks.
# export kubever=$(kubectl version | base64 | tr -d '\n')
# kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$kubever
SAMPLE DEPLOYMENT EXAMPLE
*******************************************************************
# nginx-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
labels:
app: nginx
tier: dev
spec:
containers:
- name: nginx-container
image: nginx
*******************************************************************
2. Create and display Pods
# Create and display PODs
kubectl create -f nginx-pod.yaml
kubectl get pod
kubectl get pod -o wide
kubectl get pod nginx-pod -o yaml
kubectl describe pod nginx-pod
*******************************************************************
3. Test & Delete
# To get inside the pod
kubectl exec -it nginx-pod -- /bin/sh
# Create test HTML page
cat <<EOF > /usr/share/nginx/html/test.html
<!DOCTYPE html>
<html>
<head>
<title>Testing..</title>
</head>
<body>
<h1 style="color:rgb(90,70,250);">Hello, Kubernetes...!</h1>
<h2>Congratulations, you passed :-) </h2>
</body>
</html>
EOF
exit
# Expose PODS using NodePort service
kubectl expose pod nginx-pod --type=NodePort --port=80
# Display Service and find NodePort
kubectl describe svc nginx-pod
# Open Web-browser and access webapge using
http://nodeip:nodeport/test.html
# Delete pod & svc
kubectl delete svc nginx-pod
kubectl delete pod nginx-pod
*******************************************************************
0 on: "Setup Kubernetes In Centos 8"