Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Services and Networking  ›  Lesson

External Access to Services

External Access to Services 12 minClusterIP Services stay internal, NodePort opens a port on every node, LoadBalancer requests an external address, and Ingress routes HTTP by host and path through an ingress controller.

External Access to Services

Inside the cluster, notes-web works. Your users, however, are on the internet, and the cluster IP means nothing to them. Kubernetes has a ladder of options for letting traffic in.

The rule

ClusterIP stays in, NodePort opens a port, LoadBalancer gets an address, Ingress routes by URL.

The Service type decides how far a Service reaches:

  • ClusterIP (the default) — reachable only inside the cluster.
  • NodePort — also opens the same port, from 30000–32767 by default, on every node. http://<any-node-ip>:30080 reaches the app. Fine for testing; awkward for real users.
  • LoadBalancer — on a cloud cluster, also asks the provider for an external load balancer with its own public address. Simple, but usually one load balancer, and one bill, per Service.
apiVersion: v1
kind: Service
metadata:
  name: notes-web-public
  namespace: notes
spec:
  type: LoadBalancer
  selector:
    app: notes-web
  ports:
    - port: 80
      targetPort: 8080

Ingress works one level up. It is not a Service type but a separate object with HTTP rules: route by host name and path to different Services, and terminate TLS, all behind one address.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: notes
  namespace: notes
spec:
  ingressClassName: nginx
  rules:
    - host: notes.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: notes-web
                port:
                  number: 80

An Ingress does nothing on its own. An ingress controller — a program running in the cluster, such as ingress-nginx or Traefik — must be installed to read the rules and route the traffic.

The shortcut

Ask "how many apps, and does the URL matter?" One app, any protocol → LoadBalancer. Many HTTP apps behind one address, split by host or path → Ingress. Just testing → port-forward or NodePort.

Opening notes to the worldStep 1 of 4
  1. Testing on kind

    kubectl port-forward service/notes-web 8080:80 — private, quick, done.

Drills

Answer fast — trust the rule.

quick drill

Which Service type is reachable only from inside the cluster?

quick drill

A NodePort Service uses port 30080. Where can it be reached?

quick drill

You want notes.example.com/ and notes.example.com/api to go to two Services behind one address. What fits?

quick drill

You applied an Ingress but no traffic ever reaches notes-web. What is the most likely missing piece?

Remember

  • ClusterIP stays in, NodePort opens a port on every node, LoadBalancer gets an address, Ingress routes by URL.
  • One app → LoadBalancer; many HTTP apps behind one address → Ingress; testing → port-forward.
  • Trap: an Ingress without a controller does nothing.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainLet users in

The notes team now runs notes-web and an admin site and wants both public at notes.example.com and admin.notes.example.com. Compare using LoadBalancer Services with using an Ingress, and recommend one.