Minikube Workshop by Alfie Chen
Description
This is workshop material for beginners looking forward to learning Docker and Minikube. We're modifying Get Started Tutorial from Docker, then deploying the app on Minikube.
Prerequisites
Install Docker
-
- Requires Windows 10 Pro with Hyper-V or Windows Server 2016
-
- Requires Mac 2010 hardware model or newer
- Requires MacOS El Capitan 10.11 or newer
- Requires at least 4GB RAM
You may choose between Stable or Edge versions.
-
Docker Toolbox
If your Windows or Mac system doesn't meet the above requirements, this is what you'll need.
Docker Toolbox comes with VirtualBox and Git, and launches a virtual machine (Docker Machine) where Docker will be installed and run. -
Docker For Linux systems, Docker CE supports CentOS, Debian, Fedora, and Ubuntu.
The easiest way to intall Docker on these systems is a single curl as below:$ curl -fsSL "https://get.docker.com/" | sh $ sudo systemctl start docker
Install VirtualBox
If you've installed Docker via Docker Toolbox, you may skip this section.
VirtualBox is the default hypervisor for running Minikube. Although there are multiple hypervisor choices across systems that Minikube supports, we'll be using VirtualBox for the simplisity of this workshop.
Install packages:
- Windows (v5.2.8)
- Mac (v5.2.10)
- Linux - Download the package according to your Linux distribution.
For other release versions of VirtualBox, please refer to this link.
Install kubectl
kubectl is the CLI binary for interacting with Kubernetes API.
For specific release versions of kubectl, please refer to further instructions here.
Find out the latest stable version here.
-
Windows
Download executable (kubectl v1.10.0). -
MacOS
$ brew install kubectl
-
Linux
$ curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl $ chmod +x ./kubectl $ sudo mv ./kubectl /usr/local/bin/kubectl
Install Minikube
-
Windows
Download executable and rename it tominikube.exe
. -
MacOS
$ brew cask install minikube
-
Linux
$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
Quickstart
Download workshop contents
- For Windows, unzip this file.
- For MacOS or Linux, simply
If you don't have GIT installed, check out this link.
$ git clone https://github.com/acinwinstack/minikube-intro-workshop.git
Build Docker image
$ cd minikube-intro-workshop
$ docker build -t helloworld:v1 ./build/
Start Minikube and deploy services
$ minikube start
Starting local Kubernetes v1.9.4 cluster...
Starting VM...
SSH-ing files into VM...
Setting up certs...
Starting cluster components...
Connecting to cluster...
Setting up kubeconfig...
Kubectl is now configured to use the cluster.
$ kubectl apply -f lab1/redis_pod.yml
pod "redis" created
$ kubectl get po -o wide
NAME READY STATUS RESTARTS AGE IP NODE
redis 1/1 Running 0 6s 172.17.0.9 minikube
Write down the pod IP of redis (usually something like 172.17.0.9
) then use your favorite text editor to replace redis_pod_ip
in lab2/web_deploy.yml
with the pod IP. Once redis_pod_ip
is configured correctly, hello-world
is ready to go.
**By default, web_deploy.yml
uses image acinwinstack/hello_world:minikube-intro-workshop
, which is an equivalent to helloworld:v1
we built earlier. Feel free to replace it with helloworld:v1
.
$ kubectl apply -f lab2/web_deploy.yml
deployment "hello-world-deploy" created
$ kubectl get po -o wide
NAME READY STATUS RESTARTS AGE IP NODE
hello-world-deploy-59d978b59c-476t2 1/1 Running 0 8s 172.17.0.4 minikube
hello-world-deploy-59d978b59c-kf9s6 1/1 Running 0 8s 172.17.0.2 minikube
hello-world-deploy-59d978b59c-pb5f9 1/1 Running 0 8s 172.17.0.7 minikube
hello-world-deploy-59d978b59c-qpcsk 1/1 Running 0 8s 172.17.0.8 minikube
hello-world-deploy-59d978b59c-tpjh2 1/1 Running 0 8s 172.17.0.5 minikube
redis 1/1 Running 0 2m 172.17.0.9 minikube
$ kubectl expose deploy hello-world-deploy --type NodePort --port 80 --target-port 80 --name hello-world-svc
service "hello-world-svc" exposed
$ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hello-world-svc NodePort 10.100.183.112 <none> 80:30943/TCP 19s
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 26m
$ curl 192.168.99.100:30943
<h3>Hello world!</h3><b>Hostname:</b> hello-world-deploy-5bfb58896b-ptsk5<br/><b>Total Visits:</b> 1<br/><b>Visits since connected to Redis:</b> 1
Notes
- The content of this workshop is basically a modification of Docker Get Started without the visualizer.
- LAB1 counts visits upon each hello-world pod, and stores the total value in redis.
- LAB2 mounts a persistent local storage from
minikube:/webvol/
to each hello-world pod (at locationcontainer:/home/app/
, and reads/writes the total visit-count incount.txt
.