Kubernetes minikube and kubeadm installation
Minikube installation
This guide provides step-by-step instructions for installing Minikube on Ubuntu. Minikube allows you to run a single-node Kubernetes cluster locally for development and testing purposes.
Pre-requisites
Ubuntu OS
sudo privileges
Internet access
Instance t2.medium
Step 1: Update System Packages
- Update your package lists to make sure you are getting the latest version and dependencies.
sudo apt-get update && sudo apt-get upgrade -y
Step 2: Install Required Packages
- Install some basic required packages.
sudo apt install -y curl wget apt-transport-https
Step 3: Install Docker
- Minikube can run a Kubernetes cluster either in a VM or locally via Docker. This guide demonstrates the Docker method.
sudo apt install -y docker.io && sudo apt install -y docker-compose
- Start and enable Docker.
sudo systemctl enable docker && sudo systemctl start docker
- Add current user to docker group (To use docker without root) and logout (use the
sudo reboot
command) and connect again.
sudo usermod -aG docker $USER && newgrp docker && sudo reboot
Step 4: Install Minikube
- First, download the Minikube binary using
curl
:
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
- Make it executable and move it into your path:
chmod +x minikube
sudo mv minikube /usr/local/bin/
Step 6: Start Minikube
- Now, you can start Minikube with the following command:
minikube start --driver=docker
Step 7: Check Cluster Status
- Check the cluster status with:
minikube status
- You can also use
kubectl
to interact with your cluster:
sudo snap install kubectl --classic
kubectl get nodes
Kubeadm installation
This guide provides step-by-step instructions for installing Kubeadm on Ubuntu. Kubeadm allows you to run a Master and Worker nodes Kubernetes cluster locally for development and testing purposes.
Pre-requisites
Ubuntu OS
sudo privileges
Internet access
Instance t2.medium (2 instances)
Kubeadm Installation
Both master and worker nodes ⬇️
sudo su
apt update -y
apt install docker.io -y
systemctl start docker
systemctl enable docker
curl -fsSL "https://packages.cloud.google.com/apt/doc/apt-key.gpg" | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/kubernetes-archive-keyring.gpg
echo 'deb https://packages.cloud.google.com/apt kubernetes-xenial main' > /etc/apt/sources.list.d/kubernetes.list
apt update -y
apt install kubeadm=1.20.0-00 kubectl=1.20.0-00 kubelet=1.20.0-00 -y
# To connect with cluster execute above commands on master node and worker node respectively
Master node⬇️
sudo su
kubeadm init
# To start using your cluster, you need to run the following as a 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
# Alternatively, if you are the root user, you can run:
export KUBECONFIG=/etc/kubernetes/admin.conf
kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml
kubeadm token create --print-join-command
Note:-Expose port 6443 in the Security group for the Worker to connect to the Master Node
Worker node⬇️
sudo su
kubeadm reset pre-flight checks
-----> Paste the Join command on worker node and append `--v=5` at end
#To verify cluster connection
On master node⬇️
kubectl get nodes
Happy Learning
Thanks For Reading! :)
-Sri Parthu💝💥