Need for Kubernetes (k8s)
Consider the below application
Concerns Regarding containers
- Are they production ready
- What happens when the Docker host fails or container crashes
- How to make container available 24×7
- How to handle peak times
- How to update parts/complete application without having downtime
- How do i manage storage (volumes) in the stateful applications
To address the above concerns we need a system which has knowledge of containers and which helps in running production grade containers.
The system mentioned in the above statement are generally called as orchestration
We need a container orchestration. Lets examine different container orchestration tools
- Docker swarm
- Apache mesos
To the container orchestration tools we specify desired outcome which we will be referring as desired state.
- It is written by Google and then it is made available as Opensource
- K8s is based on years of vast experience of Google to run the containers. Google has interal products called as Borg and Omega. K8s has all the best practices and learning taken from both of these tools.
- Kubernetes runs literally anywhere
- Physical Servers
- Virtual machines
- Rasberry Pi
Basic Working Style on K8s
- Create manifests (Specification) with minimal information which will be your desired state. These manifest are written in YAML
- Input the Manifests to k8s and wait the actual state
What is K8s
- k8s is a portable, extensible platform for managing containerized workloads and services.
First view of K8s Architecture
- User connects with k8s master via commandline or API where he describes the desired state
- In the case of command line the tool used is kubectl and to this kubectl a declarative way of desired state is provided as input in the format of YAML files
- K8s exposes JSON based Rest API which can be interacted from code
- K8s master assigns the workloads (to acheive desired state) on the nodes.
When working on k8s we need to adapt the cattle mindset not pet’s
What k8s can do for us
- Automatic scaling
- microservices (best approach)
- Handle Persitent storage (Volumes => AWS EBS, Azure Disks, thirdparty virtual disks)
- Zero down time deployments
- Effecient Loadbalancer integrations
- Decent monitoring interfaces.