Concepts
- Why Kubernete: manual deployment of containers is hard to maintain, error-prone and annoying.
- Containers might crash/go down and need to be replaced. We need to monitor and replace containers.
- We might need more container instances upon traffic spikes
- Incoming traffic should be distributed equally
- Kubernetes Configuration can run on any cloud provider. Extensible and standardized.
Kubernetes is a collection of concepts and tools. It works with Docker containers.
Pod: a pod holds containers. Multiple Pods can be created and removed to scale your app.
- Worker node: worker nodes are your machines (virtual instances) that runs the container of your application. A worker node can have multiple pods running.
- Proxy / Config: Control the network.
- Master node (The Control Plane): The master node controls your deployment. (i.e. all Worker Nodes). Send instructions to cloud provider API to create required infrastructures.
- Cluster: A set of Node machines which are running the Containerized Application (Worker Nodes) or control other Nodes (Master Node)
- kublet: Communication between Master and Worker node
- kube-proxy: Managed Node and Pod network communication
Master Node
- API Server: API for the kublets to communicate
- Scheduler: watches for new pods, select Worker Nodes to run them on
- Kube-Controller-Manager: watches and controls Worker Nodes, correct number of Pods & more
- Cloud-Controller-Manager: like Kube-Controller-Manager BUT for a specific Cloud Provider: knows how to interact with Cloud Provider resources
Objects
- Kubernetes works with Objects (Pods, Deployments, Services, Volumeā¦)
- Objects can be created in 2 ways: Imperatively or Declaratively
- Pod
- the smallest unit Kubernetes interacts with. The most common use case is One container per pod
- Can also contain shared resources (i.e. Volumes) for all Pod container
- Has a cluster-internal IP by default: Containers inside a Pod can communicate via localhost
- For Pods to be managed for you, you need a Controller (i.e. a Deployment)
- Deployment
- Controls multiple Pods
- You set a desired state, Kubernetes then changes the actual state
Publish local image to dockerhub
1 | docker tab <APP NAME> <REPOSITORY NAME> |
1 | kubectl create deployment first-app --image=<REPOSITORY NAME> |