# Services, Ingress and Network Policy

> Expose pods reliably inside and outside the cluster and control which pods can talk to each other. Free notes, key concepts, resources and a mini project.

Canonical: https://www.internhack.in/roadmaps/tracks/devops/k8s-networking
Last updated: 2026-11-28

Expose pods reliably inside and outside the cluster and control which pods can talk to each other.

Intermediate · about 8 hours · difficulty 3/5

Learn first: [Workloads, Probes and Autoscaling](https://www.internhack.in/roadmaps/tracks/devops/k8s-workloads), [Load Balancing and Proxies](https://www.internhack.in/roadmaps/tracks/devops/load-balancing-proxies)

Pods come and go and change IPs, so Kubernetes provides stable networking abstractions on top of them.

### The pod network

Every pod gets its own IP and can reach every other pod by default. A **CNI plugin** (Calico, Cilium, the cloud VPC CNI) implements this.

### Services

- **ClusterIP**: a stable virtual IP and DNS name (`my-svc.my-ns.svc.cluster.local`) that load balances to pods matching a label selector.
- **NodePort** exposes a port on every node; **LoadBalancer** asks the cloud for an external load balancer.
- **Headless** services (no cluster IP) for StatefulSets and client-side discovery.
- `kubectl get endpointslices` shows which pods a service actually routes to. Empty endpoints usually means a selector or readiness problem.

### Ingress and Gateway API

- An **Ingress** object plus an **ingress controller** (ingress-nginx, Traefik, cloud controllers) routes HTTP by host and path and terminates TLS.
- **cert-manager** automates certificates.
- The newer **Gateway API** separates infrastructure and route ownership and is the direction the ecosystem is moving.

### NetworkPolicy

Default-allow is risky. **NetworkPolicies** (enforced by the CNI) let you default-deny and allow only, for example, frontend to backend on port 8080.

**Good enough to move on:** you can expose two services on different hostnames with TLS, debug a service with no endpoints, and lock a namespace down with a default-deny policy.

## Key concepts

- **Pod networking and CNI**
- **ClusterIP, NodePort, LoadBalancer**
- **Cluster DNS**
- **Ingress controllers**
- **cert-manager**
- **Gateway API**
- **NetworkPolicies**

## Mini project

On a local cluster, install ingress-nginx and cert-manager, expose two apps on different hostnames with TLS, then add a default-deny NetworkPolicy and allow only the traffic each app needs.

## Check yourself

Your service exists but requests hang. kubectl get endpointslices shows no endpoints. What two things would you check first?

## Free resources

- [Services, load balancing and networking](https://kubernetes.io/docs/concepts/services-networking/) (kubernetes.io)
- [Gateway API](https://gateway-api.sigs.k8s.io/) (Kubernetes SIGs)
- [cert-manager](https://cert-manager.io/docs/) (cert-manager)

Previous: [Workloads, Probes and Autoscaling](https://www.internhack.in/roadmaps/tracks/devops/k8s-workloads) · Next: [Configuration, Secrets, Storage and RBAC](https://www.internhack.in/roadmaps/tracks/devops/k8s-config-storage)

## More in Orchestrating Containers with Kubernetes

- [Kubernetes Architecture and kubectl](https://www.internhack.in/roadmaps/tracks/devops/kubernetes-architecture)
- [Workloads, Probes and Autoscaling](https://www.internhack.in/roadmaps/tracks/devops/k8s-workloads)
- [Services, Ingress and Network Policy](https://www.internhack.in/roadmaps/tracks/devops/k8s-networking)
- [Configuration, Secrets, Storage and RBAC](https://www.internhack.in/roadmaps/tracks/devops/k8s-config-storage)
- [Packaging with Helm and Kustomize](https://www.internhack.in/roadmaps/tracks/devops/helm)
- [Operators and Custom Resources](https://www.internhack.in/roadmaps/tracks/devops/k8s-operators)
- [Service Mesh](https://www.internhack.in/roadmaps/tracks/devops/service-mesh)
- [Beyond Kubernetes: Nomad and ECS](https://www.internhack.in/roadmaps/tracks/devops/nomad-ecs)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [DevOps Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/devops)
