首页 > 解决方案 > 不能使用节点资源组之外的静态 IP 地址

问题描述

我正在尝试按照此处的指南为在节点资源组之外创建的仪表板使用静态 IP 地址,但它不起作用。(这适用于受防火墙保护的仅开发集群,不会投入生产。)

到目前为止我做了什么:

  1. 在 resourcegroup1 中创建了一个公共 IP 地址
  2. 在与 Azure 广告应用程序绑定的资源组 1 中创建 AKS 群集。
  3. 将 azure 广告应用程序的服务主体添加为 resourcegroup1 中的“网络参与者”。
  4. 添加service.beta.kubernetes.io/azure-load-balancer-resource-group: resourcegroup1到我的 service.yaml 文件中。
  5. 使用步骤 1 中的 IP 地址添加了 loadBalancerIP。

每当我应用 service.yaml 时,服务都会说它处于挂起状态。当我运行时kubectl describe service,它显示以下输出:

Name:                        kubernetes-dashboard
Namespace:                   kube-system
Labels:                      <none>
Annotations:                 externalTrafficPolicy=Local
                             service.beta.kubernetes.io/azure-load-balancer-resource-group=resourcegroup1
Selector:                    k8s-app=kubernetes-dashboard
Type:                        LoadBalancer
IP:                          10.0.42.112
IP:                          <IP FROM STEP 1>
Port:                        <unset>  80/TCP
TargetPort:                  9090/TCP
NodePort:                    <unset>  31836/TCP
Endpoints:                   10.244.0.6:9090
Session Affinity:            None
External Traffic Policy:     Cluster
LoadBalancer Source Ranges:  <SNIPPED>
Events:
  Type     Reason                      Age               From                Message
  ----     ------                      ----              ----                -------
  Normal   EnsuringLoadBalancer        38s (x6 over 3m)  service-controller  Ensuring load balancer
  Warning  CreatingLoadBalancerFailed  38s (x6 over 3m)  service-controller  Error creating load balancer (will retry): failed to ensure load balancer for service kube-system/kubernetes-dashboard: user supplied IP Address <IP FROM STEP 1> was not found

这是我的 service.yaml

apiVersion: v1
kind: Service
metadata:
  name: kubernetes-dashboard
  namespace: kube-system
  annotations:
    service.beta.kubernetes.io/azure-load-balancer-resource-group: resourcegroup1
spec:
  type: LoadBalancer
  loadBalancerIP:  <IP FROM STEP 1>
  ports:
  - port: 80
    protocol: TCP
    targetPort: 9090
  selector:
    k8s-app: kubernetes-dashboard
  loadBalancerSourceRanges:
  - <SNIP>
  - <SNIP>

标签: azure-aks

解决方案


resourcegroup1对于您收到的错误,这意味着在与 AKS 相同的区域中找不到公共 IP 。不同的地区会导致像你这样的错误:

在此处输入图像描述

因此,您应该在与您的 AKS 相同的区域中创建公共 IP。然后它会为你工作。


推荐阅读