In this tutorial we will discuss installation
and configuration of Kubernetes cluster on CentOS-7 / RHEL7. This tutorial
assuming you have already installed docker on your machine.
1) Add Kubernetes repo file to target VM.
vi /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://yum.kubernetes.io/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
2) Install required kube packages.
yum install kubeadm kubectl kubelet
kubernetes-cni -y
3) Run below commands to enable Kubelet
service.
systemctl enable kubelet
systemctl start kubelet
sed -i
"s/cgroup-driver=systemd/cgroup-driver=cgroupfs/g"
/etc/systemd/system/kubelet.service.d/10-kubeadm.conf
systemctl daemon-reload
systemctl restart kubelet
4) Update below configuration to auto-create
iptables rules.
vi /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
sysctl --system
5) Initialize Kubernetes cluster
kubeadm init
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf
$HOME/.kube/config
sudo chown $(id -u):$(id -g)
$HOME/.kube/config
export KUBECONFIG=/etc/kubernetes/admin.conf
6) Please check the node status. It will be
NotReady state as we didn't enable network configuration.
kubectl get nodes
7) Install weave network
export kubever=$(kubectl version | base64 |
tr -d '\n')
kubectl apply -f https://cloud.weave.works/k8s/net?k8s-version=$kubever
To install any other network: https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/
8) Please check node status now
kubectl get nodes
It should be in ready state.
9) To extend cluster please follow 1-4 steps
in worker nodes and run the join command to add nodes to cluster.
To get join command please run below command
on Master node.
kubeadm token create --print-join-command
No comments:
Post a Comment