如何为Kubernetes负载均衡器指定静态IP地址? [英] How to specify static IP address for Kubernetes load balancer?

查看:673
本文介绍了如何为Kubernetes负载均衡器指定静态IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行在Google Compute Engine上的Kubernetes集群,我想为我的外部服务(type: LoadBalancer)分配静态IP地址.我不确定目前是否可行.我在该主题上找到了以下来源:

I have a Kubernetes cluster running on Google Compute Engine and I would like to assign static IP addresses to my external services (type: LoadBalancer). I am unsure about whether this is possible at the moment or not. I found the following sources on that topic:

  • Kubernetes服务文档可让您定义一个外部IP地址,但失败,因为无法将对象解组为[] v1.LoadBalancerIngress
  • 类型的Go值
  • publicIPs字段似乎让我指定了外部IP,但这似乎也不起作用
  • 此Github问题指出,我尝试执行的操作尚不支持,但将在Kubernetes v1.1中使用
  • clusterIP字段还允许我指定一个IP地址,但失败,并显示"提供的IP不在有效范围内"
  • Kubernetes Service Documentation lets you define an external IP address, but it fails with cannot unmarshal object into Go value of type []v1.LoadBalancerIngress
  • The publicIPs field seems to let me specify external IPs, but it doesn't seem to work either
  • This Github issue states that what I'm trying to do is not supported yet, but will be in Kubernetes v1.1
  • The clusterIP field also lets me specify an IP address, but fails with "provided IP is not in the valid range"

我觉得在设置Web服务时,使用静态IP非常重要.我在这里想念什么吗?如果有人能在这里启发我,我将不胜感激!

I feel like the usage of static IPs is quite important when setting up web services. Am I missing something here? I'd be very grateful if somebody could enlighten me here!

为澄清起见:我没有使用Container Engine,而是使用Compute Engine的官方安装说明自行设置了群集.与我的k8s服务关联的所有IP地址都标记为临时",这意味着重新创建kubernetes服务可能会导致使用不同的外部IP地址(这就是为什么我需要将它们设为静态)的原因.

For clarification: I am not using Container Engine, I set up a cluster myself using the official installation instructions for Compute Engine. All IP addresses associated with my k8s services are marked as "ephemeral", which means recreating a kubernetes service may lead to a different external IP address (which is why I need them to be static).

推荐答案

Kubernetes v1.1将进行一些更改.

Kubernetes v1.1 will make a few changes.

首先,GCE中的所有负载均衡器都将获得静态IP.这使我们可以模拟GCE不支持的更新"操作.

First, all load-balancers in GCE will get static IPs. This allows us to simulate "update" operations that GCE does not support.

其次, https://github.com/kubernetes/kubernetes/pull/13005 提出了一个新字段明确设置负载均衡器的IP.

Second, https://github.com/kubernetes/kubernetes/pull/13005 proposes a new field to explicitly set the IP of a load balancer.

请注意,只要您的服务"存在,您的临时" IP就是您的.这大致类似于AWS对ELB名称(随机分配的,直到您释放它为止,您都使用它)的方式.

Note though that your "ephemeral" IP is yours as long as your Service exists. This is roughly akin to what AWS does with ELB names (randomly assigned, yours until you release it).

publicIP(或v1中已弃用的PublicIP)将被语义非常相似的externalIP取代.这些是非托管" IP-Kubernetes不会使用它们来建立负载均衡器,但是它将接受它们的流量.

publicIPs (or deprecatedPublicIPs in v1) will be replaced with externalIPs with very similar semantics. These are "unmanaged" IPs - kubernetes will not establish a load-balancer using them, but it will accept traffic for them.

clusterIP是一个集群内地址,通常在集群或项目"或VPC(以GCE或AWS术语)之外不可用

clusterIP is an in-cluster address and generally is not available outside of the cluster or "project" or VPC (in GCE or AWS terms)

这篇关于如何为Kubernetes负载均衡器指定静态IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆