Prompt

How do I set up load balancing for services in Kubernetes?

Technology / Cloud Infrastructure1 observationLast seen Oct 19, 2026

Latest observation

Oct 19, 2026OpenAI APIWeb search: off

In Kubernetes, “load balancing” usually means one of these:

  1. Inside the cluster: distribute traffic across pods for a service
  2. Outside the cluster: expose a service to clients on the internet or private network
  3. Advanced HTTP routing: path/host-based routing with an Ingress or Gateway

1) Basic service load balancing with a Service

Kubernetes Services automatically load balance traffic across healthy pods that match a selector.

Example Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: app
          image: nginx
          ports:
            - containerPort: 80

Example ClusterIP Service

apiVersion: v1
kind: Service
metadata:
  name: my-app-svc
spec:
  selector:
    app: my-app
  ports:
    - port: 80
      targetPort: 80
  type: ClusterIP

Apply:

kubectl apply -f deployment.yaml
kubectl apply -f service.yaml

This gives you an internal virtual IP. Requests to the Service are balanced across the 3 pods.


2) Expose the service externally

Option A: LoadBalancer Service

If you’re on a cloud provider, use type: LoadBalancer:

apiVersion: v1
kind: Service
metadata:
  name: my-app-lb
spec:
  selector:
    app: my-app
  ports:
    - port: 80
      targetPort: 80
  type: LoadBalancer

Kubernetes asks the cloud provider to provision an external load balancer and route traffic to your service.

Check the external IP:

kubectl get svc my-app-lb

Option B: NodePort

apiVersion: v1
kind: Service
metadata:
  name: my-app-nodeport
spec:
  selector:
    app: my-app
  ports:
    - port: 80
      targetPort: 80
      nodePort: 30080
  type: NodePort

Then access it via http://<node-ip>:30080.

Use this when a cloud load balancer isn’t available, though it’s less ideal for production.


3) HTTP/HTTPS routing with Ingress

If you want to route multiple services by hostname or path, use an Ingress plus an Ingress Controller.

Example Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-app-ingress
spec:
  rules:
    - host: app.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: my-app-svc
                port:
                  number: 80

You must install an Ingress Controller first, such as:

  • NGINX Ingress Controller
  • Traefik
  • HAProxy
  • cloud-specific ingress controller

Ingress is the preferred way for web apps that need host/path routing and TLS termination.


4) Internal-only load balancing

If you want an internal load balancer only, many clouds support annotations on a LoadBalancer Service.

Example for AWS:

apiVersion: v1
kind: Service
metadata:
  name: internal-lb
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-internal: "true"
spec:
  selector:
    app: my-app
  ports:
    - port: 80
      targetPort: 80
  type: LoadBalancer

The exact annotation depends on your cloud provider.


5) Things to verify

  • Your pods are running and Ready
  • The Service selector matches pod labels
  • The target port matches the container port
  • If using Ingress, the controller is installed
  • Cloud firewall / security groups allow traffic

Useful commands:

kubectl get pods
kubectl get svc
kubectl get endpoints
kubectl describe svc my-app-svc
kubectl describe ingress my-app-ingress

6) Choosing the right approach

  • Only inside cluster → ClusterIP
  • Simple external access → LoadBalancer
  • Bare metal / no cloud LB → NodePort or MetalLB
  • Multiple web apps / routing / TLS → Ingress
  • More advanced traffic management → Service Mesh or Gateway API

If you want, I can give you:

  • a full working YAML example
  • setup steps for AWS, GKE, AKS, or bare metal
  • help debugging why your Service isn’t balancing traffic

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.