You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Kubernetes LoadBalancer一直Pending,为何视频中正常而我的不行?

Why Your Kubernetes LoadBalancer is Stuck in Pending (And How to Fix It)

Hey Chris! Let’s break down why your WordPress LoadBalancer service is stuck showing <pending> for the external IP, while the one in your tutorial works smoothly.

The Root Cause

Docker Desktop for Mac’s built-in Kubernetes cluster doesn’t include a native LoadBalancer implementation out of the box. Unlike cloud providers (like AWS or GCP) that automatically provision a load balancer when you create a LoadBalancer type service, the local Docker Desktop cluster has no way to assign a real external IP unless you add a third-party tool to handle this.

The tutorial you’re following likely had this tool pre-configured, or used an older version of Docker Desktop where this functionality was handled differently. That’s why their LoadBalancer got an external IP without extra steps.

Fixing It (Based on the Docker for Mac Issue #2445)

The author of that issue got it working by using MetalLB—a tool designed to provide LoadBalancer capabilities for local Kubernetes clusters. Here’s how to set it up:

  1. Verify your Kubernetes cluster is running
    First, confirm your Docker Desktop Kubernetes cluster is up and accessible:

    kubectl cluster-info
    

    You should see output pointing to your local Kubernetes control plane.

  2. Install MetalLB
    MetalLB needs a dedicated namespace and core resources to run:

    • Create the namespace:
      kubectl create namespace metallb-system
      
    • Apply MetalLB’s core deployment manifest (you can get this from MetalLB’s official release files, save it as metallb.yaml first):
      kubectl apply -f metallb.yaml
      
  3. Configure an IP Address Pool
    MetalLB needs a range of IP addresses it can assign to your LoadBalancer services. These should be within the subnet that Docker Desktop uses for its virtual machine.

    • Create a file named metallb-config.yaml with this content (adjust the IP range to match your Docker Desktop subnet—common ranges are 192.168.64.0/24 or 192.168.1.0/24):
      apiVersion: v1
      kind: ConfigMap
      metadata:
        namespace: metallb-system
        name: config
      data:
        config: |
          address-pools:
          - name: default
            protocol: layer2
            addresses:
            - 192.168.64.100-192.168.64.150
      
    • Apply the config:
      kubectl apply -f metallb-config.yaml
      
  4. Check Your WordPress Service
    After setting up MetalLB, wait a minute or two, then check your service again:

    kubectl get service wordpress
    

    You should now see an external IP assigned from the range you configured instead of <pending>.

Why the Tutorial Worked

Chances are the tutorial either:

  • Used an older version of Docker Desktop that had a built-in LoadBalancer simulator,
  • Pre-configured MetalLB behind the scenes,
  • Or actually used a NodePort service (which exposes ports directly on the cluster nodes) but referred to it as a LoadBalancer for simplicity.

Give these steps a try, and your LoadBalancer should get an external IP in no time!

内容的提问来源于stack exchange,提问作者Chris G.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:42:35