Blog was initially published in “https://medium.com/goglides/kubernetes-how-it-works-bc27daf20e4c“
Note: If you already know how Kubernetes works you might me interested in my previous blog post Stop using kubeconfig with admin access
Kubernetes short form k8s is an open-source tool that was originally designed by Google and is now maintained by the Cloud Native Computing Foundation (CNCF). Kubernetes combine a bunch of virtual machines or physical machines and transform them into unified API surfaces. API which is presented as JSON based API, through which developers can interact with containers and orchestrate their applications, scale it without knowing about the machine that lies below.
Kubernetes defines a set of building blocks (API endpoints). Some of the cores ones are,
- A pod is a collection of containers co-located on a single machine.
- Service is a load balancer that can route traffic down to a collection of pods.
- Deployment which under the hood uses a replica set which is used for replicating a container multiple times for availability or scale.
Besides that, there are many other objects likes
- Configmap and Secrets
- and others…
All of these primitives collectively work together to provides mechanisms that deploy, maintain and scale applications based on CPU, memory, labels, taint, tolerations, and other custom metrics.
Pods combine one or more than one container which is going to deploy in the same machine. We can directly create pods object using pods manifest or we can use deployment manifest to create pods.
A Deployment runs multiple replicas of the same pods, deployment makes sure it always matches the number of replicas mentioned in deployment manifest, it also automatically replaces any instances that fail or become unresponsive.
In Kubernetes, a Service is an abstraction that defines a logical set of Pods. In simple terms, it is a loadbalancer. Users or other applications can use Service objects to talk to pods.
We can use external load balancer like ELB, NLB or ALB in AWS, Cloud Load Balancer in google cloud or any other load balancer. Users can use an external load balancer to connect with applications.