5 Important Kubernetes Concepts Made Easy

Kubernetes is the most popular open source container orchestration solution. Getting Started with Kubernetes is NOT easy.

Originally source: https://medium.com/@in28minutes/5-important-kubernetes-concepts-made-easy-956b1b666043

  • 1: Why do we need Container Orchestration?
  • 2: What is Container Orchestration?
  • 3: What is Kubernetes?
  • 4: What are the most important Kubernetes concepts?
  • 4.1: What is a Cluster?
  • 4.2: Let’s Deploy a Microservice
  • 4.3: What is a Pod?
  • 4.4: What is a ReplicaSet?
  • 4.5: What is a Deployment?
  • 4.6: A Quick Review — Deployment vs Replica Set
  • 4.7: What is a Service?
  • 5: Next Steps

1: Why do we need Container Orchestration?

  • Auto Scaling — Scale containers based on demand
  • Service Discovery — Help microservices find one another
  • Load Balancer — Distribute load among multiple instances of a microservice
  • Self Healing — Do health checks and replace failing instances
  • Zero Downtime Deployments — Release new versions without downtime

2: What is Container Orchestration?

Container orchestration solutions provide most technical features need by microservices architectures. You will be able to create a cluster of multiple vm instances and deploy microservices to the cluster. Container orchestration solution will manage the clusters and deployments.

3: What is Kubernetes?

There are a number of container orchestration platforms: Docker Swarm, Mesosphere, Kubernetes among others. In the last few years, Kubernetes has emerged as the winners in the container orchestration space.

4: What are the most important Kubernetes concepts?

Let’s say you want to setup a microservices architecture with Kubernetes. Here’s how the workflow would look like:

  • Step 1: Create a Kubernetes cluster with multiple nodes (or virtual machines)
  • Step 2: Deploy and configure your first Microservice
  • Step 3: Deploy and configure your second Microservice

4.1: What is a Cluster?

  • Master Node(s) — Manages the cluster. You send all your deployment instructions to master node.
  • Worker Node(s) — All microservices run on the worker nodes.
  • API Server — Handles all communication for a K8S cluster (from nodes and outside)
  • Scheduler — Decides placement of pods
  • Control Manager — Manages deployments & replicasets
  • etcd — Distributed database storing the cluster state

4.2: Let’s Deploy a Microservice

Let’s say I want to deploy 5 instances of V1 of microservice A. The command to issue to create a deployment and set number of instances for it is similar to what you see below:

**create deployment** hello-world-rest-api --image=in28min/hello-world-rest-api:0.0.1.RELEASE
scale deployment hello-world-rest-api --replicas=5
  • A Deployment
  • A ReplicaSet and
  • 5 Pods

4.3: What is a Pod?

A pod is the smallest deployable unit in Kubernetes. A pod represents an instance of your microservice. Each Pod is assigned an ephemeral IP address.

4.4: What is a ReplicaSet?

We deployed microservice A with 5 instances to Kubernetes cluster. This would mean that you have 5 pods running. Let’s say you kill one of the pods. Kubernetes would automatically recognize this and create a replacement pod. Kubernetes monitors the health of your pods and replace unhealthy pods. How does Kubernetes do this?

4.5: What is a Deployment?

If a ReplicaSet ensures specific number of pods, what is the role of Deployment?

  • One Deployment representing the Microservice A
  • One ReplicaSet for V1 of Microservice A
  • One ReplicaSet for V2 of Microservice A

4.6: A Quick Review — Deployment vs Replica Set

kubectl create deployment microservice1 --image=microservice1:v1
kubectl set image deployment microservice1 microservice1=microservice1:v2

4.7: What is a Service?

In Kubernetes, each Pod has its own IP address. How do you ensure that external users are not impacted when:

  • Either a pod fails and is replaced OR
  • A new version of microservice is deployed and all existing pods of old release are replaced by ones of new release
expose deployment name --type=LoadBalancer --port=80
  • ClusterIP: Exposes Service on a cluster-internal IP. Use case: You want your microservice only to be available inside the cluster (Intra cluster communication).
  • LoadBalancer: Exposes Service externally using a cloud provider’s load balancer. Use case: You want to create individual Load Balancer’s for each microservice.
  • NodePort: Exposes Service on each Node’s IP at a static port (the NodePort). Use case: You DO not want to create an external Load Balancer for each microservice (You can create one Ingress component to load balance multiple microservices).

5: Next Steps

  • 1: Try Kubernetes Playground — https://labs.play-with-k8s.com/
  • 2: Create a Kubernetes cluster in one of the cloud platforms and play with it (GKE has a free tier. You can try AKS and EKS but they are not part of free tier as of now!)

Leave a Reply

Your email address will not be published. Required fields are marked *