简体   繁体   English

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

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

In Azure, i am using helm to deploy a service (type=loadbalancer)在 Azure 中,我使用 helm 部署服务(type=loadbalancer)

Below is the manifest file下面是清单文件

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

Is it possible to tell kubernetes cluster to use a specific ip every time as an External IP.是否可以告诉 kubernetes 集群每次都使用特定的 ip 作为外部 IP。 Whenever I deploy the service?每当我部署服务时?

/*-- EDITED-- */ /*-- 已编辑-- */

Every time the loadbalancer service is deployed, a new External ip is allocated, in my case wanted to specify to use the same ip, and assume that ip address is not used within the network.每次部署负载均衡器服务时,都会分配一个新的 External ip,在我的情况下,想指定使用相同的 ip,并假设 ip 地址未在网络内使用。

/*---- */ /*---- */

My understanding is the Kubernetes cluster will allocate an External Ip everytime its deployed, it not specified in the manifest file.我的理解是 Kubernetes 集群每次部署时都会分配一个外部 Ip,它没有在清单文件中指定。

There is an Azure documentation which details on how to use a static Ip within the manifest file and demo link .有一个 Azure 文档,其中详细介绍了如何在清单文件和演示链接中使用 static Ip。

I'm just quoting from the 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.如果您想将特定 IP 地址与内部负载均衡器一起使用,请将 loadBalancerIP 属性添加到负载均衡器 YAML 清单。 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.在这种情况下,指定的 IP 地址必须与 AKS 群集位于同一子网中,并且不得已分配给资源。 For example, you shouldn't use an IP address in the range designated for the Kubernetes subnet.例如,您不应在为 Kubernetes 子网指定的范围内使用 IP 地址。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM