Day 1 - First Half



Course Materials: 
Docker Hub: 

Workshop 1: Install minikube

Install Oracle VirtualBox or DockerToolbox first.

$ brew cask install minikube
$ kubectl get-k8s-versions
$ minikube config set kubernetes-version v1.9.0
$ minikube start --vm-driver=virtualbox profile=minikubelab1
$ kubectl config get-contexts
$ kubectl config use-context minikube

Kubernetes tends to be stable at every other minor versions i,e. v1.7.0, 1.9.0, 1.11.0, ...

If minikube stucks at 'Starting cluster components...', check out this solution.

$ minikube status
$ minikube ip
$ minikube ssh
  $ docker version
$ kubectl get nodes
$ kubectl get cs

Kubectl command syntax are kubectl Verb Object vs. docker Object Verb 

$ kubectl run webtest --image=labdocker/nginx:latest --port=80
$ kubectl expose deployment webtest --target-port=80 --type=NodePort
$ kubectl get pods
$ kubectl get deployment
$ kubectl get svc
$ kubectl describe svc
$ kubectl get svc webtest
$ kubectl describe svc webtest
$ curl

To enable autocomplete for kubectl, check out this guide.

Cloud Native Landscape

CNCF Cloud Native Interactive Landscape

Kubernetes is now a project of CNCF, after Google invented it.

Cloud Native Landscape Diagram (Full Resolution)

What are the best Docker orchestration tools?

In Thailand, the green bank is going for OpenShift while purple bank is going for Kubernetes.

Alternative Playground


What is Orchestrator

  • Align business request with Application/Data/Infrastructure
  • Centralized management for:
    • Resource Pool
    • Automated Workflow
    • Provisioning
    • Scale Up/Down
    • Monitoring
    • etc.

Why is Orchestrator

  • Production must be cluster
  • Microservices architecture
  • Stateful applications will run on stateless architecture
  • Scale up/down

Kubernetes Introduction

Kubernetes Features

  • Automatic Binpacking
    • If a pod reaches memory limit, it will be terminated and will be restarted on another pod if restart flag was set.
  • Horizontal Pods Autoscaling (HPA)
    • Docker Swarm on Desktop does not have HPA. But Swarm on all cloud providers have HPA.
  • Automated Rollout and Rollbacks
    • Ensue no downtime when upgrading /downgrading
  • Storage Orchestrator
    • Local/Network/Cloud
    • Support dynamic provisioning of storage class
  • Self-healing
    • By Replication Controller
  • Service Discovery and Load Balancing
    • Load balance by kube-proxy
  • Secret and Configuration Management
    • ConfigMap allows environment configurable

Kubernetes Architecture 



Etcd (Open-source): Key-value database for keep state of nodes/Pods/Container


  • Docker engine works with kubelet (Kubernetes agent)

Kubernetes creates 'default' namespace when install.

  • Declarative commands are always kept and maintained, unlike Imperative commands.
  • Health check
    • Liveness = Pod is alive
    • Readiness = Pod is ready to accept more work
  • Updates from the latest version 1.11

Pod, Container, Service

Pods vs Container

  • Docker’s view point:
    • 1 Container: 1 Application, 1 Component of Microservice
    • So for micro service we need multi container
      • Cache component
      • Web component
      • Database component
      • Etc
  • Kubernetest’s view point:
    • 1 Pods = 1 Container
    • 1 Pods = N Container (Container on the same context, Work closely)
    • So we can have 1 Pods for container more than 1 container
  • All container on same Pods will share:

    • Process ID (PID)

    • Network access (Communicate to each other via “localhost”)

    • Internal Process Command (IPC)

    • Unix Time-Sharing (UTS)

    • Hostname

    • IP Address/Ports

  • Use Case for Multiple Pods:

    • Apache (1 Container) +Tomcat (1 Container)

    • Apache(1 Container) + PHP (1 Container)

    • Nginx (Cache: 1 Container) + Apache/PHP (1 Container)

    • Web Server (1 Container) + Data Volume(Cache: 1 Container)

  • Pods will can create replicas of 1000+ set on cluster system


  • Check documentation on which apiVersion to use
  • Service will send traffics to pods with label(s) matched by selector
  • Service type NodePort = bind to a random port of the node
  • YAML to JSON converter
  • Created by kubectl create -f <yaml_file>
  • YAML file can be on the network

Basic Commands

kubectl logs <Pods name> –c <container name>  = See log of a container
kubectl exec –it <Pods name> –c <container name> sh = Shell in side a container
kubectl describe <Pods/SVC/etc> <Name> = See detail