
Core components: Nodes, Pods, Services, Deployments
Meet the building blocks. Understand the four most important objects in the Kubernetes ecosystem and how they work together to run your apps.
Core Components: Nodes, Pods, Services, and Deployments
When you first open the Kubernetes documentation or look at a dashboard, the sheer number of "Objects" can be overwhelming. There are StatefulSets, ConfigMaps, Ingresses, CRDs, and dozens more.
However, 90% of your time as a Kubernetes engineer will be spent with four core components. If you master these four, you understand the engine of your cluster.
In this lesson, we will break down Nodes, Pods, Services, and Deployments. We will look at how they relate to each other, how they are defined in code, and how they handle a real-world user request.
1. The Node (The Foundation)
A Node is a worker machine in Kubernetes. It can be a physical server in your data center, or more commonly, a Virtual Machine (like an AWS EC2 instance) in the cloud.
Think of a Node as the Hardware.
- It provides the CPU, RAM, and Disk space.
- Kubernetes is a cluster because it pools many Nodes together to form a single giant "Super-computer."
Types of Nodes
- Worker Nodes: These run your applications.
- Control Plane Nodes: These are the "Brains." They don't run your apps; they manage the cluster (we will deep dive into the Control Plane in Module 2).
2. The Pod (The Atomic Unit)
A Pod is the smallest deployable unit in Kubernetes. You don't deploy containers directly to K8s; you deploy Pods.
Think of a Pod as a Spaceship.
- Inside the spaceship, you have one or more astronauts (Containers).
- The Pod provides the environment: an IP address, storage, and networking that all containers inside the Pod share.
Why not just "Containers"?
In 99% of cases, a Pod contains only One container. However, sometimes you need a "Sidecar" container. For example, your main container is a FastAPI app, and your sidecar container is a logging agent that ships logs to AWS CloudWatch. Because they are in the same Pod, they share the same localhost and can talk to each other instantly.
3. The Deployment (The Manager)
You almost never create a Pod manually. Why? Because if a raw Pod dies, it stays dead.
Instead, you create a Deployment. A Deployment is a controller that manages a "Desired Number" of Pods.
Think of a Deployment as the Manager.
- You say: "I want 3 copies of my AI Agent Pod running."
- The Deployment looks at the cluster and says: "Okay, I'll start 3 Pods across the available Workers."
- If one Pod crashes, the Deployment notices and starts a replacement.
4. The Service (The Access Point)
Pods are mortal. They die and are reborn with new IP addresses. If you have a Frontend (Next.js) trying to talk to a Backend (FastAPI), how does the Frontend know where the Backend is?
The Service provides a stable, permanent IP address and DNS name that points to a group of Pods.
Think of a Service as the Receptionist.
- When a request comes in for
backend-service, the Receptionist (Service) looks at the available Pods and forwards the call to one of them. - It also acts as a Load Balancer, spreading traffic evenly across all pods.
5. Visualizing the Hierarchy
This Mermaid diagram shows how these four components sit inside one another.
graph TD
subgraph "Kubernetes Cluster"
subgraph "Worker Node (EC2)"
NodeResources["CPU / RAM / Disk"]
subgraph "Pod 1"
C1["App Container (FastAPI)"]
end
subgraph "Pod 2"
C2["App Container (FastAPI)"]
end
end
Svc["Service (Stable IP: 10.0.0.5)"]
Deploy["Deployment (Manager)"]
end
UserRequest["User Request"] --> Svc
Svc --> Pod1
Svc --> Pod2
Deploy -.->|Controls| Pod1
Deploy -.->|Controls| Pod2
style Svc fill:#f9f,stroke:#333
style Deploy fill:#bbf,stroke:#333
6. Practical Example: A LangChain "Summary" Microservice
Let's see these four objects in action with a real-world Python/AI application.
The App Logic (FastAPI)
We will create an API that uses AWS Bedrock to summarize text.
# app.py
from fastapi import FastAPI
from langchain_aws import ChatBedrock
import os
app = FastAPI()
# Initialize the Bedrock client
# In K8s, we pass credentials via Secrets or IAM Roles
llm = ChatBedrock(model_id="anthropic.claude-3-haiku")
@app.post("/summarize")
async def summarize(text: str):
response = llm.invoke(f"Summarize this: {text}")
return {"summary": response.content}
The Kubernetes Manifest (manifest.yaml)
This single YAML file will define our Deployment and our Service.
---
# 1. THE DEPLOYMENT (The Manager of Pods)
apiVersion: apps/v1
kind: Deployment
metadata:
name: summary-ai-deployment
spec:
replicas: 2 # Maintain 2 Pods
selector:
matchLabels:
app: summary-ai
template:
metadata:
labels:
app: summary-ai
spec:
containers:
- name: summary-ai-container
image: myrepo/summary-ai:latest
ports:
- containerPort: 8000
# Passing AWS config via env vars (K8s Best Practice)
env:
- name: AWS_REGION
value: "us-east-1"
---
# 2. THE SERVICE (The Stable Access Point)
apiVersion: v1
kind: Service
metadata:
name: summary-ai-service
spec:
selector:
app: summary-ai # Point this Service at any Pod with this label
ports:
- protocol: TCP
port: 80 # External Port
targetPort: 8000 # The port inside the container
type: LoadBalancer # Expose to the Internet
7. How the Request Flows (Step-by-Step)
- The User visits the IP of the Service (
http://72.x.x.x/summarize). - The Service (The Receptionist) sees the request. It checks its list of healthy Pods.
- The Service forwards the request to Pod 2 running on Worker Node 1.
- The Pod receives the request at the Container level. The FastAPI app processes it.
- The Deployment (The Manager) watches from the sidelines. If Pod 2 suddenly crashes, the Deployment will immediately trigger the creation of Pod 3 so that the "Desired State" of 2 replicas is always met.
8. Summary and Key Takeaways
- Node: The physical or virtual machine.
- Pod: One or more containers; the smallest unit K8s manages.
- Service: The permanent gateway that provides networking and load balancing to Pods.
- Deployment: The controller that ensures the right number of Pods are running and healthy.
These four objects form the "Holy Quadrant" of Kubernetes. Once you can comfortably create and link these four, you can deploy almost any application in the world.
9. SEO Metadata & Keywords
Focus Keywords: Kubernetes Core Components, Nodes vs Pods, K8s Services vs Deployments, Kubernetes objects tutorial, Kubernetes beginner guide, Scaling FastAPI on K8s.
Meta Description: Learn the 4 essential components of Kubernetes: Nodes, Pods, Services, and Deployments. Understand how they interact to provide a resilient, scalable, and manageable infrastructure for your modern AI and Web applications.