HOW to install kubernetes on Virtual BOX with Centos 7 : Working perfectly
Setting up the Kubernetes Master
This setup will work on Virtual host labs:
The following actions will be executed on the Kubernetes Master.
- Disable swap
swapoff -a - Edit:
/etc/fstabvi /etc/fstab - Comment out swap
#/root/swap swap swap sw 0 0 - Add the Kubernetes repo
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 exclude=kube* EOF - Disable SELinux
setenforce 0 - Permanently disable SELinux:
vi /etc/selinux/config - Change enforcing to disabled
SELINUX=disabled - Install Kubernetes
yum install -y kubelet kubeadm kubectl kubernetes-cni-0.6.0 --disableexcludes=kubernetes - Start and enable the Kubernetes service
systemctl start kubelet && systemctl enable kubelet - Create the
k8s.conffile:cat << EOF > /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call- iptables = 1 EOF sysctl --system Assuming your Network is 192.168.1.1/16- Initialize Kuberneteskubeadm init --pod-network-cidr=192.168.1.
0/16 - Copy
admin.confto your home directorymkdir -p $HOME/.kube cp -i /etc/kubernetes/admin.conf $HOME/.kube/config chown $(id -u):$(id -g) $HOME/.kube/config - Install calico
curl \ https://docs.projectcalico.org/v3.5/getting-started/kubernetes/installation/hosted/kubernetes-datastore/calico-networking/1.7/calico.yaml \ -Okubectl apply -f calico.yaml - Then reolad kubelete
systemctl restart kubelet
Setting up the Kubernetes Worker nodes
Now that the setup for the Kubernetes master is complete, we will begin the process of configuring the worker node. The following actions will be executed on the Kubernetes worker.
- Disable swap
swapoff -a - Edit:
/etc/fstabvi /etc/fstab - Comment out swap
#/root/swap swap swap sw 0 0 - Add the Kubernetes repo
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 exclude=kube* EOF - Disable SELinux
setenforce 0 - Permanently disable SELinux:
vi /etc/selinux/config - Change enforcing to disabled
SELINUX=disabled - Install Kubernetes
yum install -y kubelet kubeadm kubectl kubernetes-cni --disableexcludes=kubernetes - Start and enable the Kubernetes service
systemctl start kubelet && systemctl enable kubelet - Create the
k8s.conffile:cat << EOF > /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call- iptables = 1 EOF sysctl --system - Use the join token to add the Worker Node to the cluster:
kubeadm join < MASTER_IP >:6443 --token < TOKEN > --discovery-token-ca-cert-hash sha256:< HASH > On the master node, test to see if the cluster was created properly.
- Get a listing of the nodes:
kubectl get nodes - Note : If your token is expired issue below command :: kubeadm token create
Comments