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.
π’ 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:
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)