Load Balancers

When you create a Kubernetes Ingress or Service, Spot automatically provisions a managed load balancer that distributes traffic to your pods. This provides an externally-accessible IP address that routes traffic to the correct ports on your cluster nodes. This doc talks about gen1 LB which is applicable for Generation-1 Data-centers and gen2 LB which is applicable for Generation-2 Data-centers .

Load Balancer Pricing:

$10 per month per load balancer. This includes:

  • Simple pricing: Fixed cost regardless of traffic volume
  • Managed infrastructure: Fully managed with no manual configuration required
  • High availability: Built-in redundancy and automatic failover capabilities
  • Standard protocols: Support for HTTP, HTTPS, TCP, and other standard protocols

Prerequisites:

Before you begin, ensure you have:

  • A Rackspace Spot Kubernetes cluster (Cloudspace) running
  • kubectl installed
  • Your cloudspace kubeconfig file downloaded and configured (Access your Cloudspace via kubectl)

Creating a Network Load Balancer Service:

Protocol Support

Rackspace Spot Load Balancers support multiple protocols. Choose the appropriate protocol based on your application needs:

  • TCP: Default protocol for most applications (HTTP, HTTPS, database connections)
  • UDP: For applications requiring UDP traffic (DNS, gaming, streaming, VoIP)

Basic HTTP/HTTPS LoadBalancer Service

To create an external load balancer for HTTP traffic, add type: LoadBalancer to your Service manifest:

YAML
Copy

UDP LoadBalancer Service

For applications that require UDP traffic (such as DNS servers, game servers, or streaming applications):

YAML
Copy

Creating via kubectl

You can alternatively create a LoadBalancer service using kubectl:

Bash
Copy

Deploying Your Application:

Create a deployment to work with your LoadBalancer service:

YAML
Copy

Finding Your Load Balancer IP:

Once your LoadBalancer Service is created, get the external IP address:

Bash
Copy

Look for the LoadBalancer Ingress field in the output, which contains your external IP address. It may take a few minutes for the load balancer to be provisioned and the IP address to be assigned.

You can also check the status with:

Bash
Copy

Configuration Options:

Traffic Policies

Control how traffic is distributed using externalTrafficPolicy:

YAML
Copy
  • Cluster (default): Traffic may be routed to any healthy pod, potentially causing an extra network hop
  • Local: Traffic is only routed to pods on the same node, preserving source IP but potentially causing uneven distribution

Generation 1 vs Generation 2 Load Balancers

Rackspace Spot offers two generations of load balancers depending on your data center region:

FeatureGen1 Load BalancersGen2 Load Balancers
ProtocolsHTTP, TCP, UDPHTTP, TCP, UDP
Source IP PreservationX-Forwarded-For header onlyX-Forwarded-For + PROXY protocol
Access Lists (Source Ranges)✅ Supported✅ Supported
HTTPS Support✅ Supported✅ Supported
RegionsGen1 data centersGen2 data centers (SJC-1, DFW-2)

Source IP Preservation

By default, the original client source IP is obscured. To preserve client source IP, you have different options depending on your load balancer generation:

For Both Gen1 and Gen2 Load Balancers:

X-Forwarded-For Header Method:

YAML
Copy

⚠️ Note: X-Forwarded-For is limited to HTTP-based services only and does not work with HTTPS.

For Gen2 Load Balancers Only:

PROXY Protocol Method (Recommended):

YAML
Copy

⚠️ Note: When enabling PROXY protocol, your application must be configured to handle PROXY protocol. See NGINX example configuration for reference.

Access Lists (Source Ranges)

Both Gen1 and Gen2 Load Balancers allow you to restrict external access by specifying allowed IP address ranges. This is useful for limiting access to internal networks or specific client IPs.

Method 1: Using loadBalancerSourceRanges (Recommended)

YAML
Copy

Method 2: Using annotations

YAML
Copy

Real-World Examples:

Example 1: Game Server (UDP)

For a multiplayer game server that uses UDP:

YAML
Copy

Example 2: DNS Server (UDP)

For a custom DNS server:

YAML
Copy

Example 3: Mixed Protocol Service

For applications that need both TCP and UDP:

YAML
Copy

Clean Up:

To avoid charges, delete LoadBalancer services when no longer needed:

Bash
Copy

This removes the Kubernetes service and deprovisions the load balancer.

Monitoring and Troubleshooting:

Checking Service Status

Monitor your LoadBalancer service:

Bash
Copy

Common Issues

  1. Pending External IP: If the external IP shows as <pending>, wait a few minutes for provisioning to complete
  2. Connection timeouts: Verify your application is listening on the correct port and your Service targetPort matches the container port
  3. 503 errors: Check that your pods are running and healthy

Best Practices

  1. Use health checks: Ensure your application responds to health check requests
  2. Monitor costs: Each LoadBalancer service costs $10/month, view pricing breakdown in the Cost Explorer
  3. Use meaningful names: Choose descriptive names for your services and load balancers
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard