Kubernetes - 每次在 AKS 中部署时使用特定 IP 地址的服务类型 LoadBalancer

Kubernetes - service type LoadBalancer to use specific ip address every time deployed in AKS

在 Azure 中,我正在使用 helm 部署服务 (type=loadbalancer)

下面是清单文件

apiVersion: v1
kind: Service
metadata:
  name: {{ template "app.fullname" . }}-service-lb
  labels:
    app: {{ template "app.fullname" . }}-service-lb
  annotations:
    service.beta.kubernetes.io/azure-load-balancer-internal: "true"
spec:
  type: LoadBalancer
  ports:
    - port: {{.Values.appServPort}}
      nodePort: {{.Values.lbPort}}
      protocol: TCP
  selector:
    app: {{ template "app.fullname" . }}-service

是否可以告诉 kubernetes 集群每次都使用特定的 ip 作为外部 IP。何时部署服务?

/*-- 已编辑-- */

每次部署loadbalancer服务时,都会分配一个新的External ip,我的例子想指定使用相同的ip,并假设该ip地址没有在网络内使用。

/*---- */

我的理解是Kubernetes集群每次部署都会分配一个External Ip,并没有在manifest文件中指定。

有一份 Azure 文档,其中详细说明了如何在清单文件中使用静态 IP,demo link

我只是引用 docs

If you would like to use a specific IP address with the internal load balancer, add the loadBalancerIP property to the load balancer YAML manifest. In this scenario, the specified IP address must reside in the same subnet as the AKS cluster and must not already be assigned to a resource. For example, you shouldn't use an IP address in the range designated for the Kubernetes subnet.

apiVersion: v1
kind: Service
metadata:
  name: internal-app
  annotations:
    service.beta.kubernetes.io/azure-load-balancer-internal: "true"
spec:
  type: LoadBalancer
  loadBalancerIP: 10.240.0.25
  ports:
  - port: 80
  selector:
    app: internal-app