DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. 5 Important Kubernetes Concepts Made Easy

5 Important Kubernetes Concepts Made Easy

Getting Started with Kubernetes is NOT easy. This article will help you understand some of the most important concepts of Kubernetes.

Ranga Karanam user avatar by
Ranga Karanam
CORE ·
Oct. 05, 22 · Analysis
Like (2)
Save
Tweet
Share
6.04K Views

Join the DZone community and get the full member experience.

Join For Free

Kubernetes is the most popular open-source container orchestration solution.

Getting Started with Kubernetes is NOT easy.

This article will help you understand some of the most important concepts of Kubernetes.

  1. Why do we need Container Orchestration?
  2. What is Container Orchestration?
  3. What is Kubernetes?
  4. What are the most important Kubernetes concepts?
    1. What is a Cluster?
    2. Let’s Deploy a microservice
    3. What is a Pod?
    4. What is a ReplicaSet?
    5. What is a Deployment?
    6. A Quick Review - Deployment vs Replica Set
    7. What is a Service?
  5. Next Steps

1. Why Do We Need Container Orchestration?

Most enterprises are adopting microservices architectures.

Microservices provide the flexibility to innovate.

However, microservices don’t come for free. Instead of deploying a few applications, we are deploying hundreds of microservices. This results in increased complexity.

Containers can help simplify your deployment and observability challenges. However, there are still challenges with respect to managing your infrastructure and deployments. Example: I want 10 instances of microservice A container, 15 instances of microservice B container, .. and so on for multiple microservices. In addition, I want a number of other features for my microservices. A few typical features include:

  • 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 the most technical features needed by microservices architectures. You will be able to create a cluster of multiple VM instances and deploy microservices to the cluster. The container orchestration solution will manage the clusters and deployments.

container orchestration

3. What Is Kubernetes?

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

4. What Are the Most Important Kubernetes Concepts?

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

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

Let’s now look at each of these in depth.

4.1. What Is a Cluster?

A cluster is a group of virtual machines. In the cluster, there are two types of nodes:

  • Master Node(s) - Manages the cluster. You send all your deployment instructions to the master node.
  • Worker Node(s) - All microservices run on the worker nodes.

Here are some of the important Master Node (Control plane) components:

  • API Server - Handles all communication for a K8S cluster (from nodes and outside)
  • Scheduler - Decides placement of pods
  • Control Manager - Manages deployments & replica sets
  • etcd - Distributed database storing the cluster state

The job of a worker node is to run your microservices. In addition, a Kubernetes component called a Kubelet runs on each pod. Kubelet enables worker nodes to communicate with the master node(s).

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 a number of instances for it is similar to what you see below:

Shell
 
**create deployment** hello-world-rest-api --image=in28min/hello-world-rest-api:0.0.1.RELEASE
scale deployment hello-world-rest-api --replicas=5


This would deploy v1 of your microservice A with 5 instances to the Kubernetes cluster.

Internally, Kubernetes would create

  • A Deployment
  • A ReplicaSet and
  • 5 Pods

Why does Kubernetes do this?

Let’s dig deeper.

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.

If I have 10 instances of Microservice A and 12 instances of microservice B running in a Kubernetes cluster, then I would have a total of 10 + 12 = 22 pods running.

4.4. What Is a ReplicaSet?

We deployed microservice A with 5 instances to the 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 replaces unhealthy pods. How does Kubernetes do this?

This is the job of a ReplicaSet.

A ReplicaSet ensures that a specified number of pods are always running. In the above example, a ReplicaSet ensures that 5 instances of microservice A are always running.

4.5. What Is Deployment?

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

A deployment ensures that you have flexibility when you release new versions of your microservices.

A deployment represents all the versions of your microservice.

Currently, we have just one version of the microservice. However, you can deploy a new version. Let’s say, I want to deploy V2 of microservice without any downtime.

That’s the job of a Deployment.

When you deploy a new version of an existing microservice, the Deployment would create a new ReplicaSet for V2 of microservice A.

You will have:

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

Deployment UK

4.6. A Quick Review - Deployment vs Replica Set

Shell
 
kubectl create deployment microservice1 --image=microservice1:v1


A deployment is created for each microservice. A Deployment represents a microservice (with all its releases). A Deployment manages new releases ensuring zero downtime.

A Replica set ensures that a specific number of pods are running for a specific microservice version. Even if one of the pods is killed, the replica set will launch a new one.

Shell
 
kubectl set image deployment microservice1 microservice1=microservice1:v2


When you deploy a V2 of microservice, a new ReplicaSet (V2 ReplicaSet) is created.

Deployment updates V1 Replica Set and V2 Replica Set based on the release strategies configured.

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 the microservice is deployed and all existing pods of the old release are replaced by ones of the new release

Solution: Create a Service.

Shell
 
expose deployment name --type=LoadBalancer --port=80


A service exposes your deployments to the outside world using a stable IP address. This ensures that your users are not impacted as pods go down and come up.

There are three types of services:

  • 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 Balancers 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

  • Try Kubernetes Playground
  • 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 the free tier as of now!).
Kubernetes Concepts (C++) Docker (software) microservice pods

Published at DZone with permission of Ranga Karanam, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Seamless Integration of Azure Functions With SQL Server: A Developer's Perspective
  • Old School or Still Cool? Top Reasons To Choose ETL Over ELT
  • Running Databases on Kubernetes
  • What Is Automated Testing in Software Testing?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: