Till now I have given blogs on k8s objects, services, namespaces, ingress etc. but where to execute and implement all those, yes, we need a k8s cluster for that, if you have it already go n execute, if not, here is the solution for you.
Execute below commands to configure the master node “(# are optional)”
- sudo hostnamectl set-hostname master-node
- sudo apt update
- #clear
- sudo apt install docker.io -y
- sudo systemctl enable docker
- curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
- sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
- sudo apt install kubeadm -y
- sudo swapoff -a
- sudo kubeadm init –pod-network-cidr=10.244.0.0/16
- mkdir -p $HOME/.kube
- sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
- sudo chown $(id -u):$(id -g) $HOME/.kube/config
- sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
- kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml
- #clear
- kubectl get nodes
- watch kubectl get nodes
- kubectl get nodes -o wide
- #history —> for future purpose record
Execute below commands to configure on worker node
- sudo hostnamectl set-hostname node1
- sudo apt update
- #clear
- sudo apt install docker.io -y
- sudo systemctl enable docker
- #clear
- curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
- sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
- sudo apt install kubeadm -y
- sudo swapoff -a
- following command will have different options in your case, that command will comeup on the screen itself #kubeadm join 172.31.36.112:6443 –token sop568.8zzj0emko8sa4o0s –discovery-token-ca-cert-hash sha256:35fc8b66d2e57eb56f73247fa16bcc44220b975994ec99e61af8caa74b22788d
if you want configure multiple worker nodes or master nodes, execute the set of commands respectively in other nodes as well,
if you wantdon’twant toconfigure and manage the cluster, go with cloud managed especially AKS, why cloud managed and why AKS; follow the link for one ofmy previous blog
https://ecanarys.com/Blogs/ArticleID/370/Difference-Between-K8S-vs-Azure-Kubernetes-Service-AKS