无法在节点资源组之外使用静态IP地址

时间:2019-02-22 22:01:13

标签: azure-kubernetes

我正在尝试根据位于here上的指南在节点资源组之外创建的仪表板使用静态ip地址,但是它无法正常工作。 (这是针对带防火墙的仅开发人员的群集,不会投入生产。)

到目前为止我所做的:

  1. 在resourcegroup1中创建了一个公共IP地址
  2. 在与天蓝色广告应用程序绑定的resourcegroup1中创建AKS集群。
  3. 在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

这是我的服务。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>

2 个答案:

答案 0 :(得分:1)

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

enter image description here

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

答案 1 :(得分:0)

我的AKS群集为1.9.x,比所需的1.10.x还要旧。我正在使用Terraform创建集群,似乎存在一个有关如何处理丢失的kubernetes_version的错误。我在他们的仓库中提交了一个问题。