Kubernetes Deployments and Services: Separation of Concerns

Day 47 of #100DaysOfDevOps My first instinct was to combine everything into one YAML file and call it done. Kubernetes had other plans. The task: deploy Grafana on a K8s cluster and expose it externally via a NodePort service on port 32000. Sounds straightforward — until you realize a Deployment and a Service aren't just "two sections in a file." They're two completely separate contracts. The Deployment's only job is to keep your pods alive and match a desired state. The Service's only job is to route traffic to those pods — using label selectors as the bridge between them. Break that label chain, and your service is just shouting into the void. Got it running with grafana/grafana:latest, container port 3000, NodePort 32000. Clean, separate YAMLs. Verified with kubectl get all and hit the UI at <node-ip>:32000. The real lesson: in Kubernetes, separation of concerns isn't just good practice — it's the architecture. Deployments manage lifecycle. Services manage access. They don't overlap, and they shouldn't. One mislabeled selector = silent failure with zero helpful errors. Labels are load-bearing. #100DaysOfDevOps #KodeKloud #Kubernetes #DevOps #CloudNative #K8s

To view or add a comment, sign in

Explore content categories