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

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

问题描述

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

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 地址,但它失败了,cannot unmarshal object into Go value of type []v1.LoadBalancerIngress
  • 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).

publicIPs(或 v1 中已弃用的PublicIPs)将被替换为具有非常相似语义的 externalIPs.这些是非托管"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天全站免登陆