After this lesson, you will be able to: Distinguish Service types (ClusterIP, NodePort, LoadBalancer) and configure Ingress to route external traffic to services by hostname/path.
Services route traffic INSIDE the cluster. Ingress is how requests from the INTERNET reach the right Service. This lesson covers both.
ClusterIP (default): an IP inside the cluster only. Service-to-service traffic. The right choice 95% of the time. NodePort: opens a port (30000-32767) on EVERY node. Mostly used for local dev / kind clusters. LoadBalancer: provisions a cloud LB (AWS ALB, GCP LB) and points it at the Service. ONE per public endpoint. Expensive at scale. ExternalName: a DNS CNAME alias to an external host. Used to abstract third-party endpoints behind a friendly internal name.
ClusterIP for internal; LoadBalancer for one-off public exposure.
# Internal serviceapiVersion: v1kind: Servicemetadata:name: apispec:type: ClusterIPselector: { app: api }ports:- port: 80 # what callers connect totargetPort: 8000 # what the Pod listens on---# Public service via cloud LBapiVersion: v1kind: Servicemetadata:name: web-publicspec:type: LoadBalancerselector: { app: web }ports:- port: 80targetPort: 3000# After applying, kubectl get svc shows an EXTERNAL-IP (your public LB).
One LoadBalancer per public endpoint = expensive (each is a real cloud LB). Ingress is a Kubernetes object that says 'route traffic from a single LB to many Services based on hostname or path'. One LB at the edge + an Ingress controller (nginx-ingress, traefik, AWS ALB controller) + N Ingress objects = many public endpoints, one bill. Modern alternative: Gateway API (the next-gen replacement; still gaining adoption).
Routes example.com to web, api.example.com to api.
apiVersion: networking.k8s.io/v1kind: Ingressmetadata:name: app-ingressannotations:cert-manager.io/cluster-issuer: letsencrypt-prodspec:ingressClassName: nginxtls:- hosts: [example.com, api.example.com]secretName: app-tlsrules:- host: example.comhttp:paths:- path: /pathType: Prefixbackend:service:name: webport: { number: 80 }- host: api.example.comhttp:paths:- path: /pathType: Prefixbackend:service:name: apiport: { number: 80 }
One LoadBalancer Service per app. The cloud bill balloons. Use Ingress. Forgetting the `ingressClassName`. Without it, no controller picks up the Ingress. Skipping cert-manager. Manual TLS renewal in K8s is a maintenance nightmare. Hostname mismatch in TLS section vs rules. Cert request fails. Routing by IP. Stick to hostname or path; IP routing is brittle.
Pick the cost-effective architecture.
Sign in and purchase access to unlock this lesson.