A Kubernetes setup is made up of multiple layers, from the overall cluster down to the containers actually running your application. This diagram shows the relationships between clusters, namespaces, deployments, services, pods, and containers, and explains how manifest files (deployment.yaml and service.yaml) control what’s deployed.
+===============================================================+
| CLUSTER |
+===============================================================+
| A complete Kubernetes environment, containing: |
| - Control Plane (API Server, Scheduler, Controller Manager) |
| - Worker Nodes (run workloads in Pods) |
| Manages the state of workloads and networking across all nodes |
+===============================================================+
|
v
(Many logical partitions per cluster)
+-------------------+ +-------------------+
| NAMESPACE: A | | NAMESPACE: B | ...
+-------------------+ +-------------------+
| Logical partition inside a cluster to organize & isolate |
| resources. Useful for separating apps, teams, or environments |
+----------------------------------------------------------------+
|
| Deploy resources into a namespace:
| kubectl apply -f deployment.yaml [-n A]
| kubectl apply -f service.yaml [-n A]
v
+----------------------+ +----------------------+
| deployment.yaml | | service.yaml |
| Kind: Deployment | | Kind: Service |
| apiVersion: apps/v1 | | apiVersion: v1 |
| Defines desired | | Exposes Pods to |
| Pods & replicas | | internal/external |
+----------+-----------+ +----------+-----------+
| creates | selects Pods by label
v (e.g., app=web)
+--------------------+ |
| Deployment |--------------------+
+--------------------+ |
| Ensures desired number of Pod replicas run |
| Updates Pods in a controlled, rolling manner |
+-------------------------------------------------+
| creates
v
+--------------------+
| ReplicaSet |
+--------------------+
| Tracks a set of Pods created from the same spec |
| Created/managed automatically by a Deployment |
+-------------------------------------------------+
| spawns N replicas
v
+--------------------+
| Pod |
| +--------------+ |
| | Container | |
| +--------------+ |
| | Container | |
| +--------------+ |
+--------------------+
| Smallest deployable unit in Kubernetes. |
| Holds one or more containers that share storage, |
| network, and specs. |
+--------------------------------------------------+
^
| labels (e.g., app=web, tier=fe)
+----------------------------------+
|
+-------------+
| Service |
+-------------+
| Stable networking endpoint that routes to Pods via label selector |
| Types: ClusterIP, NodePort, LoadBalancer, etc. |
+-------------------------------------------------------------------+
deployment.yaml)apiVersion: apps/v1kind: Deploymentservice.yaml)service.yaml and deployment.yaml related ?They’re Linked via Labels/Selectors
deployment.yaml → Pod template metadata has labels (e.g., app: web).service.yaml → spec.selector must match those labels (e.g., app: web).kubectl get deploymentskubectl get podskubectl get eventskubectl configuration - kubectl config viewkubectl logs <pod name>kubectl expose deployment <deployment name> --type=LoadBalancer --port=<port number>kubectl get servicesminikube addons listminikube addons enable <add-on name>kubectl delete service <service name>
kubectl delete deployment <deployment name>
kubectl scale -n <namespace> deployment <deployment name> --replicas=<no.of replicas (i.e., 10,20.....)>minikube dashboard