Getting Started with Kube #1 - Base Software
Method 1 - Docker Desktop
Easiest way is to use Docker Desktop 3.2.1 and enable kubernetes in the preferences, but if you want to see whats happening under the hood I prefer to use this old Virtualbox/Vagrant method.
Method 2 - VirtualBox Vagrant
Tested on Mac (x86_64) 11.2.2 Big Sur Virtualbox 6.1.18 Vagrant 2.2.14 Kubectl 1.16.3
First install Virtualbox, Kubectl and Vagrant from their respective websites.
Clone this repo: https://github.com/justmeandopensource/kubernetes
1git clone https://github.com/justmeandopensource/kubernetes
...then go into the vagrant-provisioning sub-folder and type
1vagrant up
We should see virtualbox VMs like this:
Now we'll jump into the master node of the cluster to do some admin and get kubectl working with the cluster.
1vagrant ssh kmaster
2
3 mkdir -p $HOME/.kube
4 sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
5 sudo chown $(id -u):$(id -g) $HOME/.kube/config
6
7cat $HOME/.kube/config
Copy contents of the $HOME/.kube/config file inside the cluster to your dev (host) machine.
(Careful about merging these config files, to keep things simple I copy seperate versions of the config file per "cluster" I manage)
To check everything works, try running a kubectl get nodes command.
You should see something like this:
1NAME STATUS ROLES AGE VERSION
2kmaster Ready control-plane,master 57m v1.20.0
3kworker1 Ready <none> 54m v1.20.0
4kworker2 Ready <none> 51m v1.20.0
...and last but not least, to close down your cluster, type
1vagrant suspend
Method 3 - Minikube/Virtualbox
Tested on Mac (x86_64) 11.2.2 Big Sur Virtualbox 6.1.18
Install by doing on MacOSX:
1brew install minikube
To start a new cluster we do:
1minikube start --driver=virtualbox
This preps a new VM called Minikube which is effectively a one-node kubernetes cluster. Test kubectl again by:
1kubectl get nodes
2
3NAME STATUS ROLES AGE VERSION
4minikube Ready control-plane,master 30s v1.20.0
...and shutdown we do
1minikube stop