Kubernetes Introduction
Nathan Luong | April 15, 2024 |12
What is K8S
- Open-source container orchestration tool
- Developed by Google
- With Increased usage of containers, demanding for a proper way of managing those hundreds of containers
Features
- High Availability
- Salability
- Disaster Recovery → Backup and restore
K8S Components
Node
- Simple a server, a physical machine, or a VM
Pod
- The smallest unit of K8S
- Abstraction over container
- Pods are meant to run only 1 container within it, 1 app/pod
- Each pod is assigned an IP address
- Pods communicate with each others using IP address
- Pods can die easily → When pods die, they got assigned a new IP on creation
Service
- Permanent IP address that can be attached to each pod
- Lifecycle of Pod and Service are not connected
- External Service: Exposed its communication to external sources
- Internal Service: Not exposed to the world
ℹ️
A service can be a Load Balancer
Ingress
- Forward requests to Services
Config Map
- external configuration of the application
❌
Don’t put username and password on Config Map
Secrets
- Used to store secret data
- Base64 encoded
❌
The built-in security is not enabled by default!
Volumes
- Attaches a storage onto the pod
- The storage can be local or remote (outside of the K8S cluster like cloud or on-premise)
- K8S doesn’t manage data persistence
Deployment
- blueprint for my-app pods
- Database can’t be replicate via deployment
StatefulSet
- Deploys for stateful Apps or Databases
K8S Architecture
Worker Machine in K8S cluster
- Each Node has multiple Pods on it
- 3 processes must be installed on every Node
- Worker Nodes do the actual work
Container runtime (Docker) is installed on all nodes
- kubelet
- Processes that schedules the pods
- It interacts with both the container and node
- Nodes are communicate via Services
- Kube Proxy:
- Must be installed on every Nodes
- Forwards the requests to the nodes
- Making sure that the performance is performing with the lowest overheads
Master Processes
- Have 4 processed that run on every master node
- API Server
- Cluster Gateway
- Client interact with the API Server to create/manage new applications
- Act as a validator which authenticate the Client Requests
- Scheduler
- Decide which of the worker node to put the pod in
- See how much resources the application that client want to schedule will need (how much CPU, RAM)
- Choose the Node to schedule it in via Kubelet
- Controller Manager
- When a pod dies on any Node, The Controller Manager request the Scheduler to recover the pods
- etcd
- The cluster Brain.
- Cluster changes get stored in the key value store.
- API Server
- Master Nodes consumes less resources (CPU, RAM, Storage)
Example Cluster Set-Up
Add new Master/Node server
- Get new bare server
- Install all the master/worker node processes
- Add it to the cluster