tczekajlo / kube-consul-register

a tool to register Kubernetes PODs as Consul Services
Apache License 2.0
105 stars 50 forks source link

Kubernetes Service registration #3

Closed psyhomb closed 7 years ago

psyhomb commented 7 years ago

Is there any chance to implement Kubernetes Service (with NodePort) registration as Consul Service instead or together with POD registration? These data can be very useful and can be further used to generate HAProxy configuration for external load balancing.

tczekajlo commented 7 years ago

Hi, It sounds like good idea. I'll take a look at this in next week.

psyhomb commented 7 years ago

Great, thanks man.

On Mar 9, 2017 18:57, "tczekajlo" notifications@github.com wrote:

Hi, It sounds like good idea. I'll take a look at this in next week.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tczekajlo/kube-consul-register/issues/3#issuecomment-285428896, or mute the thread https://github.com/notifications/unsubscribe-auth/ABvYai_F_S7jwnDb2aVnwOVVQ5wuiBzxks5rkD2OgaJpZM4MXO1U .

tczekajlo commented 7 years ago

In #5 I added support for Kubernetes Services, but without NodePort as you mentioned. I can't see any sense to register services with NodePort. If I associate correctly, using NodePort causes that an service is exposed on all nodes (or on the selected nodes) on given port, so what is the sense to register an service with NodePort.

Maybe I don't understand something. Can you explain what you mean exactly when you mention registration with NodePort?

psyhomb commented 7 years ago

That's exactly the point of k8s service object with type: NodePort, to expose service port on every node in k8s cluster and to make service publicly (one step from HA) available (incoming traffic will be routed to backend pods by kube-proxy => iptables rules).

Then by using consul-template or confd it will be possible to retrieve this piece of information and use it to generate HAproxy configuration which will have frontend definition with some public network socket (probably floating IP + some port) and backend pool that will be composed from k8s worker nodes and NodePort, that way you will get an external load balancing for your service.

Btw this is something similar you will get with Kubernetes on AWS but far less flexible cause they are using ELB and ELB is not that configurable as HAproxy.

tczekajlo commented 7 years ago

OK. It's more clear for me now. I'll add support for NodePort, probably it'll be in next week.

bobhenkel commented 7 years ago

This is what I'm looking for too, I have an AWS VPC with our legacy services running it and they need to access the new services we migrate over to our AWS VPC running K8s. Luckily we make heavy use of Consul in our legacy VPC and by peering the two VPCs together we can put node ip:node port entries in consul and the legacy services can route to the K8s services.

tczekajlo commented 7 years ago

I've been busy recently, so this issue took a while. In PR #8 I've added support for services with NodePort type. Here you can find the example of service, additionally register_source option has to be set on service.