不能使用节点资源组之外的静态 IP 地址

Cannot Use a static IP address outside of the node resource group

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

到目前为止我做了什么:

  1. 在资源组 1 中创建了一个 public IP 地址
  2. 在 resourcegroup1 中创建一个与 azure ad 应用程序关联的 AKS 集群。
  3. 将 Azure 广告应用程序的服务主体添加为资源组 1 中的 "Network Contributer"。
  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>

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

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

我的 AKS 集群是 1.9.x,比要求的 1.10.x 早。我正在使用 Terraform 创建集群,但似乎存在一个关于如何处理丢失的 kubernetes_version 的错误。我在他们的回购协议中提交了一个问题。