Networking and storage are the two parts of Kubernetes that confuse people the most. The Pod model is simple once you learn it. Then you hit a question like, how does one Pod reach another, and how does data survive when a Pod is replaced? This post covers the networking model in plain terms, then Ingress, then storage.
How Pod networking works
Every Pod gets its own IP address. Every Pod can reach every other Pod by that IP, with no address translation in between. A Pod can also reach a Service by name. Kubernetes DNS resolves the Service name to the Service IP, and the Service forwards traffic to a healthy Pod behind it. You should never hardcode a Pod IP in your application config. Pod IPs change. Service names do not.
There are two other networking details worth knowing early.
First, each Pod has its own network namespace, but containers inside the same Pod share it. That means containers in one Pod talk to each other on localhost. If a main container listens on port 8080, a sidecar in the same Pod reaches it at localhost:8080.
Second, traffic between Pods in the same cluster is flat. There is no built-in firewall between them by default. Any Pod can reach any other Pod. That is convenient while you are learning, and it is a problem in production. Network Policies fix it, and they are covered in the final article of this series.
Service types, revisited
The first article introduced ClusterIP, NodePort, and LoadBalancer. Here is how to choose between them.
Use ClusterIP for traffic inside the cluster. A frontend Pod calling an API Pod should go through a ClusterIP Service. It is the default, it is private, and it is the right choice for most service to service traffic. Use NodePort only for quick tests. Use LoadBalancer when you need a public entry point from the cloud provider. On AKS, EKS, and GKE, a LoadBalancer Service creates a cloud load balancer for you. That is simple, but it creates one load balancer per Service, which gets expensive when you have many services. That is the problem Ingress solves.
A headless Service is a fourth type worth knowing. Set clusterIP: None and Kubernetes returns the Pod IPs directly through DNS instead of a single Service IP. Some applications need to find each Pod by name, like a database cluster where each member must talk to a specific peer.
Ingress: one door for many services
Ingress is the standard way to expose HTTP traffic to the internet. Instead of one cloud load balancer per Service, you run one Ingress controller and one load balancer, and the Ingress rules decide which Service gets each request based on the host name or the URL path.
The flow is: internet traffic hits the cloud load balancer, the load balancer sends it to the Ingress controller, and the controller routes it to the right Service based on the rules you wrote.
Here is an Ingress that routes two paths to two Services:
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: web-ingress annotations: nginx.ingress.kubernetes.io/rewrite-target: / spec: ingressClassName: nginx rules: - http: paths: - path: / pathType: Prefix backend: service: name: web port: number: 80 - path: /api pathType: Prefix backend: service: name: api port: number: 8080 A few points about this file. The ingressClassName picks the controller that will handle it. Common controllers are NGINX Ingress and the cloud providers own controllers. You must install a controller before Ingress rules do anything. Creating the Ingress object alone does not create a load balancer or route traffic.
The pathType: Prefix means any path starting with /api goes to the API Service. Path based routing is the simplest pattern. Host based routing is the other common pattern, where api.example.com goes to one Service and app.example.com goes to another.
TLS is where Ingress earns its keep. You can terminate TLS at the Ingress controller with a tls block and a Secret holding the certificate. In practice, most teams use cert-manager to issue and renew certificates automatically. You add an annotation to the Ingress, cert-manager requests a certificate, stores it in the Secret, and renews it before it expires.
Check your Ingress the same way you check everything else:
kubectl get ingress kubectl describe ingress web-ingress kubectl get svc -n ingress-nginx If traffic is not reaching your app, check in order: the Ingress controller Pods are running, the controller Service has an external IP, the Ingress rules match the host and path you are requesting, and the backend Service has endpoints. Most Ingress problems are in that short list.
Storage: why Pods lose data
A Pod is disposable, and its filesystem goes with it. If a container writes a file and the Pod restarts, the file is gone. That is fine for stateless apps, which keep their state in a database or an external service. It is a problem for anything that needs files to survive a restart.
Kubernetes solves this with volumes. A volume is storage attached to a Pod. The simplest volume is emptyDir. It is an empty directory that lives as long as the Pod lives. Containers in the Pod can share it, and data survives a container restart inside the same Pod. But when the Pod is deleted, the data goes with it. emptyDir is useful for caches, scratch space, and files shared between containers in one Pod. It is not persistent storage.
For data that must survive a Pod restart, you need a PersistentVolumeClaim, usually shortened to PVC. A PVC is a request for storage. You ask for a size and an access mode, and the cluster gives you a PersistentVolume, or PV, that meets the request.
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: data spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi storageClassName: standard ReadWriteOnce means the volume can be mounted read and write by one node. That is the most common mode, and it fits most single Pod workloads. ReadWriteMany allows many nodes to mount the same volume, which is what you need for shared file storage, but not every storage provider supports it. Check your provider before you design around it.
The storageClassName picks the type of storage. On managed Kubernetes, the cloud provider supplies storage classes for its block and file storage. A StorageClass also controls dynamic provisioning: when you create a PVC, the provisioner creates the underlying disk automatically. You do not create the disk by hand.
Attach the claim to a Pod by name:
spec: containers: - name: app image: myapp:1.0 volumeMounts: - name: data mountPath: /data volumes: - name: data persistentVolumeClaim: claimName: data Now the data in /data survives a Pod restart, because the volume lives outside the Pod. Delete the Pod and the Deployment creates a new one, and the new Pod mounts the same volume.
StatefulSets: when identity matters
A Deployment is the right tool for stateless apps, where every replica is identical and interchangeable. Some apps are not like that. A database cluster has members with distinct roles. Each member needs its own storage, its own stable name, and its own network identity. A StatefulSet is built for that case. It gives each Pod a stable name, like db-0, db-1, and db-2, a stable address through a headless Service, and its own PVC through a volume claim template, so db-0 always mounts the same volume even after a restart. StatefulSets also roll out in order, one Pod at a time.
A practical note: many teams run databases outside Kubernetes, on a managed database service, and keep Kubernetes for stateless apps. That is a reasonable choice. Running a database inside Kubernetes is doable, but backups, upgrades, and recovery need real planning. Plan the backup and restore process first.
ConfigMaps and Secrets
Applications need config, and config should not live inside the container image. A ConfigMap holds plain config as key value pairs or files. A Secret holds sensitive values, like passwords and API keys, in the same shape.
apiVersion: v1 kind: ConfigMap metadata: name: app-config data: LOG_LEVEL: "info" FEATURE_FLAG: "on" apiVersion: v1 kind: Secret metadata: name: app-secrets type: Opaque stringData: DB_PASSWORD: "change-me-in-production" Mount them as environment variables or as files:
spec: containers: - name: app image: myapp:1.0 envFrom: - configMapRef: name: app-config - secretRef: name: app-secrets Two things to know about Secrets. First, they are base64 encoded, not encrypted, by default. Anyone with permission to read the Secret in the cluster can decode it. That means access control matters, and you should not commit Secret files to Git. The GitOps article in this series covers how to handle that. Second, changing a ConfigMap does not automatically restart the Pods that use it. Pods read the config at start, so roll the Deployment after a config change.
Debugging networking and storage
When something does not connect, work through the layers in order. Start at the Pod, then the Service, then the Ingress. Check the Pod is running and listening: kubectl logs deployment/api and kubectl exec -it deployment/api -- curl localhost:8080/health. Check the Service has endpoints with kubectl get endpoints api. If the endpoints list is empty, the Service selector does not match any Pod labels. That is the most common Service problem, and it is a label problem, not a networking problem. Check DNS from inside a Pod with kubectl exec -it deployment/api -- nslookup web. For storage, check the claim status with kubectl get pvc and kubectl describe pvc data. A PVC stuck in Pending usually means there is no StorageClass, the StorageClass has no provisioner, or the requested size is not available.
Checklist
- [ ] I can explain how Pods reach each other and how DNS resolves Service names
- [ ] I have created an Ingress and reached an app through it
- [ ] I know the difference between ClusterIP, NodePort, and LoadBalancer
- [ ] I know when to use
emptyDirand when to use a PVC - [ ] My StatefulSets use a headless Service and a volume claim template
- [ ] Config lives in ConfigMaps, secrets live in Secrets, and neither is baked into the image
- [ ] I can trace a failed request from Pod to Service to Ingress
Closing
Networking in Kubernetes is a Service name and a set of labels. Storage is a claim for a volume that outlives the Pod. Keep the debugging order in mind, Pod, Service, Ingress, and most problems sort themselves into one of those layers.
Next article: GitOps in practice. Helm, Kustomize, and Argo CD, and how to deploy from Git without touching kubectl in production.

