DEV Community

Cover image for Part-79: ๐Ÿš€ Kubernetes Fundamentals โ€“ Pods, ReplicaSets, Deployments & Services
Latchu@DevOps
Latchu@DevOps

Posted on

Part-79: ๐Ÿš€ Kubernetes Fundamentals โ€“ Pods, ReplicaSets, Deployments & Services

Kubernetes Fundamentals

When learning Kubernetes, the first concepts youโ€™ll hear about are Pods, ReplicaSets, Deployments, and Services. These are the building blocks of every Kubernetes application. Letโ€™s break them down in simple terms.

g2


๐ŸŸข Pod

  • A Pod is the smallest unit in Kubernetes.
  • Think of it as a wrapper around your application container(s).
  • A Pod usually runs one instance of your application.

๐Ÿ‘‰ Example: If you run an Nginx web server, it will live inside a Pod.


๐ŸŸข ReplicaSet

  • A ReplicaSet makes sure the desired number of Pods are always running.
  • If a Pod crashes, the ReplicaSet will create a new one.
  • Helps ensure high availability.

๐Ÿ‘‰ Example: If you want 3 replicas of your Nginx Pod, the ReplicaSet will maintain them.


๐ŸŸข Deployment

  • A Deployment manages ReplicaSets for you.
  • It makes updating applications easier (rolling updates, rollbacks).
  • Best suited for stateless applications.

๐Ÿ‘‰ Example: You deploy an Nginx app with 3 replicas. If you upgrade the version, the Deployment will replace old Pods gradually.


๐ŸŸข Service

  • A Service exposes your Pods to the network.
  • Provides a stable virtual IP (VIP) so you donโ€™t have to worry about Pods changing.
  • Acts as a load balancer in front of Pods.

๐Ÿ‘‰ Example: Even if Pods die and restart, you can still access your app using the Service IP/Name.


๐Ÿ› ๏ธ Kubernetes โ€“ Imperative vs Declarative

When working with Kubernetes, you can interact in two ways:

g1

Approach How it works Example
Imperative You tell Kubernetes what to do step by step using kubectl commands. kubectl run nginx --image=nginx
Declarative You define what you want in a YAML file, and Kubernetes figures out how to make it happen. kubectl apply -f deployment.yaml

Hereโ€™s a simple visual:

  • Imperative Approach โ†’ Uses only kubectl commands.
  • Declarative Approach โ†’ Uses YAML + kubectl.
  • Both work with Pods, ReplicaSets, Deployments, and Services.

โœ… Summary

  • Pod โ†’ Smallest unit, runs your app.
  • ReplicaSet โ†’ Ensures the right number of Pods are running.
  • Deployment โ†’ Manages ReplicaSets, supports upgrades.
  • Service โ†’ Exposes Pods to the network with a stable IP.
  • Imperative vs Declarative โ†’ Choose commands (imperative) or YAML (declarative).

๐ŸŒŸ Thanks for reading! If this post added value, a like โค๏ธ, follow, or share would encourage me to keep creating more content.


โ€” Latchu | Senior DevOps & Cloud Engineer

โ˜๏ธ AWS | GCP | โ˜ธ๏ธ Kubernetes | ๐Ÿ” Security | โšก Automation
๐Ÿ“Œ Sharing hands-on guides, best practices & real-world cloud solutions

Top comments (0)