阅读背景:

将流量路由到AWS EC2上的公共Kubernetes服务

来源:互联网 

I have a kubernetes (0.15) cluster running on CoreOS instances on Amazon EC2

我在Amazon EC2上的CoreOS实例上运行了kubernetes(0.15)集群

When I create a service that I want to be publicly accessible, I currently add some private IP addresses of the EC2 instances to the service description like so:

当我创建一个我想要公开访问的服务时,我目前将EC2实例的一些私有IP地址添加到服务描述中,如下所示:

{
  "kind": "Service",
  "apiVersion": "v1beta3",
  "metadata": {
    "name": "api"
  },
  "spec": {
    "ports": [
      {
        "name": "default",
        "port": 80,
        "targetPort": 80
      }
    ],
    "publicIPs": ["172.1.1.15", "172.1.1.16"],
    "selector": {
      "app": "api"
    }
  }
}

Then I can add these IPs to an ELB load balancer and route traffic to those machines.

然后我可以将这些IP添加到ELB负载均衡器并将流量路由到这些机器。

But for this to work I need to have a maintain the list of all the machines in my cluster in all the services that I am running, which feels wrong.

但为了实现这一点,我需要在我运行的所有服务中维护集群中所有机器的列表,这感觉不对。

What's the currently recommended way to solve this?

目前推荐的解决方法是什么?

  • If I know the PortalIP of a service is there a way to make it routable in the AWS VPC infrastructure?
  • 如果我知道某项服务的PortalIP有可能使其在AWS VPC基础架构中可路由吗?

  • Is it possible to assign external static (Elastic) IPs to Services and have those routed?
  • 是否可以将外部静态(弹性)IP分配给服务并进行路由?

(I know of createExternalLoadBalancer, but that does not seem to support AWS yet)

(我知道createExternalLoadBalancer,但这似乎还不支持AWS)

2 个解决方案

#1


If someone will reach this question then I want to let you know that external load balancer support is available in latest kubernetes version.

如果有人会遇到这个问题,那么我想告诉您,最新的kubernetes版本中提供了外部负载均衡器支持。

Link to the documentation

链接到文档

#2


You seem to have a pretty good understanding of the space - unfortunately I don't have any great workarounds for you.

你似乎对这个空间有了很好的理解 - 不幸的是,我没有任何出色的解决方法。

CreateExternalLoadBalancer is indeed not ready yet - it's taking a bit of an overhaul of the services infrastructure to get it working for AWS because of how differently AWS's load balancer is from GCE's and Openstack's load balancers.

CreateExternalLoadBalancer确实还没有准备好 - 由于AWS的负载均衡器与GCE和Openstack的负载均衡器有多么不同,它正在对服务基础架构进行一些改进以使其适用于AWS。

Unfortunately, there's no easy way to have the PortalIP or an external static IP routable directly to the pods backing the service, because doing so would require the routing infrastructure to update whenever any of the pods gets moved or recreated. You'd have to have the PortalIP or external IP route to the nodes inside the cluster, which is what you're already effectively doing with the PublicIPs field and ELB.

遗憾的是,没有简单的方法可以将PortalIP或外部静态IP直接路由到支持该服务的pod,因为这样做需要路由基础设施在任何pod被移动或重新创建时进行更新。您必须拥有到集群内节点的PortalIP或外部IP路由,这是您已经有效地使用PublicIPs字段和ELB。

What you're doing with the load balancer right now is probably the best option - it's basically what CreateExternalLoadBalancer will do once it's available. You could instead put the external IPs of the instances into the PublicIPs field and then reach the service through one of them, but that's pretty tightly coupling external connectivity to the lifetime of the node IP you use.

你现在用负载均衡器做的事情可能是最好的选择 - 它基本上就是CreateExternalLoadBalancer一旦可用就会做的事情。您可以将实例的外部IP放入PublicIPs字段,然后通过其中一个到达服务,但这非常紧密地将外部连接耦合到您使用的节点IP的生命周期。


分享到: