1. K8s overview

+ Tạo image, pull lên docker hub
+ Tạo K8s cluster bằng minikube: minikube start, một cluster gồm 1 master node và 1 worker node, master node cung cấp cho bạn khả năng điều khiển, worker node cung cấp khả năng chạy các container.
+ Viết config file .yaml 
+ Tạo K8s object

2. Important Kubernetes Terminology

+ Kubernetest Cluster: A collections of worker node to run container and a master to manage them
+ Node worker: A virtual machine that will run our containers
+ Pod: More or less a running container. A Pod can run multiple containers
+ Deployment: Monitors a set of Pods, make sure they are running and restarts them if they crash
+ Service: Provides an easy-to-remember URL to access a running container

3. Note on config file

 + Config file tells K8s about the different Deployments, Pods, and Services (Object) we want to create.
+ Written in YAML syntax

4. Creating a Pod

+ Build image from Dockerfile: docker build -t tdn134/blog-posts:0.0.1 .
+ Create config file
apiVersion: v1 - K8s is extensible - we can add in our own custom objects. This specifies the set of objects we want K8s to look at. 
kind: Pod - The type of object we want to create
metadata: - Config options for the object we are about to create
    name: blog-posts-v0.0.1 - When the pod is created, give it a name of  'posts'
spec: - The exact attributes we want to apply to the object we are about to create
    containers: - We can create many containers in a single pod
        - name: blog-posts - Make a container with a name of 'posts'
          image: tdn134/blog-posts:0.0.1

5. Common command around Deployment

+ kubectl get deployments: List all running deployment
+ kubectl describe deployment [depl name]
+ kubectl apply -f [config file name]: create deployment out of config file 
+ kubectl delete deployment [depl name]

6. Updating the image used by a deployment

+ Make a change to project code 
+ Rebuild the image, specifying new version for image
+ Update version of image in config file
+ kubectl apply -f [config file] 

7. Another method to update

+ Using lastest tag
+ Make update to code
+ kubectl rollout restart deployment [depl name]

8. Network with service

Q: How to we make a request to deployment ?
A: Using service
Services provide networking between pods

9. Type of services

+ Cluster IP: sets up an easy-to-remember URL to access a pod. Only exposes pods in the cluster (sets up communication between cluster)
+ Node Port: Makes a pod accessible from outside the cluster. Usually only used for dev purposes. 
+ Load Banlancer: Makes a pod accessible from outside the cluster. This is the right way to expose a pod to the outside world.
+ External Name: Redirects an in-cluster request to a CNAME url...

10. Goals Moving Forward

+ Build an image for the Event Bus
+ Push the image to the docker hub
+ Create a deployment for Event Bus
+ Create a Cluster IP Service for Event Bus and Posts
+ Wire it all up

11. Load Balancer Service

+ Tell K8s to reach out to its provider and provision a load balancer. Get traffic to a single pod
+ Ingress: A pod with a set of routing rules to distribute traffic to other service

12. Skaffold

+ Auto update image, any change in our code to deployment service