When someone just wants to play around Kubernetes on its local environment without accessing to Cloud provider resources, one can set Kubernetes up on local environment with minikube with single node mode.
This post will provide a simple guideline on how to set up KUbernetes with minikube and docker on Ubuntu.
Before all the steps can be started, you may need to first set up kubectl which is a command line tool to operate on Kubernetes resources.
Post that, can ensure that docker is installed on Ubuntu, in case it's not installed, can follow below steps.
- Update local software repository database
sudo apt-get update​
- (Optional) Uninstall old docker in case it's existing
sudo apt-get remove docker docker-engine docker.io​
- Install docker
sudo apt install docker.io​
- Once installation is done, can set it up to be ran at system start
sudo systemctl start docker sudo systemctl enable docker​
- Check that whether the daemon service is up and docker is available
You should see both client and server information. In case no server information is found and it says permission error, you need to add the current user into user groupk8s@k8s-VirtualBox:~$ docker version Client: Version: 20.10.2 API version: 1.41 Go version: go1.13.8 Git commit: 20.10.2-0ubuntu1~20.04.2 Built: Tue Mar 30 21:24:57 2021 OS/Arch: linux/amd64 Context: default Experimental: true Server: Engine: Version: 20.10.2 API version: 1.41 (minimum version 1.12) Go version: go1.13.8 Git commit: 20.10.2-0ubuntu1~20.04.2 Built: Mon Mar 29 19:10:09 2021 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.3.3-0ubuntu2.3 GitCommit: runc: Version: spec: 1.0.2-dev GitCommit: docker-init: Version: 0.19.0 GitCommit: ​
docker
. By default, only users in docker group can access this information, otherwisesudo
command is needed.
To add the current user into the docker user group, can run below command
Post that, log out as current user and login back(If you are in Virtual Machine, you may need to restart the system)sudo usermod -aG docker $USER​
Once docker is installed, one can proceed to install minikube. Below are the steps to be followed.
- Get the command to install minikube from https://minikube.sigs.k8s.io/docs/start/
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 sudo install minikube-linux-amd64 /usr/local/bin/minikube​
- The command is pretty straightforward, it downloads the minikube binary and install it. Run below command to verify it's installed successfully.
k8s@k8s-VirtualBox:~$ minikube version minikube version: v1.20.0 commit: c61663e942ec43b20e8e70839dcca52e44cd85ae ​
- Next can run minikube start to start the cluster
This tells minikube to use docker as the driver instead of virtualbox(default one).minikube start --driver=docker​
- Once it's started, can run minikube status to check its status.
k8s@k8s-VirtualBox:~$ minikube status minikube type: Control Plane host: Running kubelet: Running apiserver: Running kubeconfig: Configured​
- Next, can just run normal kubectl commands to access the Kubernetes cluster
k8s@k8s-VirtualBox:~$ kubectl get pods NAME READY STATUS RESTARTS AGE hello-minikube-6ddfcc9757-9vl9s 1/1 Running 1 20h =​