Technology to quickly set up a Kubernetes cluster locally to learn how to use Kubernetes.
Installation
How to install on a fresh Ubuntu installation:
Install prerrequisites and kubectl
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
Prepare kubectl to make it executable
cd /usr/bin
sudo chmod +x ./kubectl
Here you can either install a Hypervisor or Docker. I’m going with Docker.
# remove old versions
sudo apt-get remove docker docker-engine docker.io containerd runc
# docker prerrequisites
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
# add docker key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# setup stable repository
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# install docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
# verify docker installation
sudo docker run hello-world
(optional) run docker without sudo
sudo groupadd docker
sudo gpasswd -a $USER docker
Install Minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
&& chmod +x minikube
sudo mv minikube /usr/bin
# add user to docker group
sudo usermod -aG docker $USER && newgrp docker
# confirm installation
minikube start
minikube dashboard
Commands
minikube start
minikube stop
minikube status
minikube ip
minikube logs
minikube ssh
minikube help
Launch single node K8s cluster
# start VM with cluster running inside
minikube start --wait=false
# cluster details and health status
kubectl cluster-info
# shows nudes in the cluster
kubectl get nodes
kubectl create deployment first-deployment --image=katacoda/docker-http-server
kubectl expose deployment first-deployment --port=80 --type=NodePort
This starts a VM for you with a K8s cluster running inside. This cluster can be interacted with using kubectl
. This is the main approach for managing K8s and the apps running on top of the cluster.
Launch multi cluster
# create a cluster for dev environment
minikube start -p dev
# see a list of all profiles
minikube profile list
# change to dev profile
minikube profile dev
Reference(s)
https://docs.docker.com/engine/install/ubuntu/
https://k8s-docs.netlify.app/en/docs/tasks/tools/install-minikube/
https://minikube.sigs.k8s.io/docs/start/
https://katacoda.com/courses/kubernetes/launch-single-node-cluster