What is Kubernates
- Open source container orchastration
- Developed by Google
- Help manage Containers in different deployment environment : Physical, Virtual Environment
- Use of Microservice increased use of container
- Modern app comproises of 100s of container managed via script which lead to need of orchastration tool
Orchestration
In system administration, orchestration is the automated configuration, coordination, and management of computer systems and software.
Advantage
- Availability
- Scalability/High Performance
- Backup & Recovery
Componnets of Kubernates
Node is a Physical or Virtual Server hosting kubernates
Master Node
Each Master have 4 Process
- API Server:
- Cluster gateway
- Communicate with Server to update or query from cluster.
- Request API server to start or schedule a Pod
- Scheduler
- Get request from API server
- Intelligently decide where to schedule Pod based on Node Load
- Send request to Kubelet to start Application Pod
- Controller Manager
- Detect Which Pod died and restart
- Detect state change of Pod and try to recover state of pod
- Send request to Scheduler to restart a Pod
- etcd
- Cluster brain-> Hold Cluster state which are used by Master processes
- Cluster changes get stored in key value pair
- Hold data for Scheduler, Server and Controller Manager
- Distributed Storage across all master nodes.
- Need less resource
Worker node/ Node
Each Node must have 3 process
- Container run time: eg. Docker
- Kubelets Service: Interface for interacting with node and container
- Kube Proxy: intellegent forward request.
- Does the actual Job hence need more resource
- Each Worker Node can have multiple Pods
Pod
-
Smallest Unit of K8s
-
Abstraction over container.
-
Each Pod get own Internal IP address so that Pods can communicate.
-
When Pod get respawn a new IP address is assigned
-
1 App per Pod eg 1 pod for DB and 1 Pod for Node App in 1 Node
Service
- Attach to Pod and Balance Load of Pod
- Give each pod have a permanent IP address
- Service and IP address is not affaected by life cycle of Pod
- External Service
- Service open comunication with external sources eg App on Browser
- Internal Service
- Service not open to Browser eg DB on Browser
- External Service
Ingress
Forward request to service by changing URL to meaningful address instead of host number
ConfigMap
- External config to your application
- Kubernates automatically adjust DB url based on Config App
Secret
- Used to store credential and certificate in base64 encoded
Volumes
- Storage on Local or remote cluster persist data
- K8 dont manage data persistance
- Pod generates data which gone after pod restart, Volume help with persisting data.
Deployment
- Help wih App Pod replication.
- Blueprint used to create Pod, replicate them and Scale them.
- Abstarction on Top of Pods
- Replicate App in another node
- All Pods are connected with service
- Service will balance load and if one pod dies it pass request to other pod
- We cant replicate database with Deployment.
Stateful Set
- Help wih Database Pod replication.
- Databases must be created with Statefulset not with deployment.
- Take care of creating DB Pods, replicating them and scale them.
- Need to take care of DB inconsitancy of DB RW between Stateful sets.
Test Setup
Install Minikube: https://minikube.sigs.k8s.io/docs/start/
Requirement
- 2 CPUs or more
- 2GB of free memory
- 20GB of free disk space
- Internet connection
- Container or virtual machine manager, such as: Docker, Hyperkit, Hyper-V, KVM, Parallels, Podman, VirtualBox, or VMWare
Minikube
- Virtualize Master and Worker Node Setup
- Simulate Production Setup of Master and Worker Nodes for Testing
- Open Source Tool created a Virtual Box on Laptop
- 1 Node k8s Cluster with Master and Worker Process along with Docker container preinstalled
Kubectl
- Create various Kubernet componnet in MiniKube via CLI
- Api Server is the Entry Point which can be communicated via KubeCtl on MiniKube to create and delete component
- Kubectl can communiate with any type of Cube cluster
