Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Support LoadBalancerAddress for mesh gateways #388

Merged
merged 1 commit into from
Mar 26, 2020

Conversation

lkysow
Copy link
Member

@lkysow lkysow commented Mar 17, 2020

Add support for using the external address of Kubernetes load balancer
for the mesh gateway wan address.

This change uses the new consul-k8s load-balancer-address command to get
the address of the load balancer.

It also removes meshGateway.wanAddress.{useNodeIP, useNodeName, host}
config values in favour of meshGateway.wanAddress.{source, static}. The
new source value allows selecting NodeIP, NodeName, LoadBalancerAddress
or Static. This is more extensible than the previous boolean values.

@lkysow lkysow added area/multi-dc Related to running with multiple datacenters enhancement New feature or request labels Mar 17, 2020
@lkysow
Copy link
Member Author

lkysow commented Mar 18, 2020

Reviewers:

@lkysow lkysow marked this pull request as ready for review March 18, 2020 17:03
@lkysow lkysow requested a review from a team March 18, 2020 17:03
Copy link
Contributor

@ishustava ishustava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Luke, I haven't looked at the code yet, but decided to try it out first.

So far, it didn't work because the mesh gateway clusterrole needs to be updated to allow it to read services. The error I get is:

2020-03-19T22:14:46.604Z [ERROR] getting service iryna-consul-mesh-gateway: services "iryna-consul-mesh-gateway" is forbidden: User "system:serviceaccount:default:iryna-consul-mesh-gateway" cannot get resource "services" in API group "" in the namespace "default"

I also had a thought on the UX. I initially looked at the config and tried to figure out which values I need to set to enable the Load Balancer. I set meshGateway.service.enabled to true and meshGateway.service.type to LoadBalancer. But that didn't trigger the mesh gateway deployment to fetch the load balancer address. I then realized that I need to the meshGateway.wanAddress.source to LoadBalancerAddress. I'm wondering if my stupidity is an indicator that the UX could be a bit more obvious. It would be super nice if we could infer from the service settings what you most likely would want.

One idea on how to do that could be enabling service by default and adding an option to wanAddress.source called something like service. This option would imply that we'll use the service for wan address, and perhaps, even the port. It might also make sense to change the default service type from ClusterIP to something else. IIRC routable cluster IPs are pretty niche, and so I'm not sure if this is a sane default for the mesh gateway. Just an idea, but I'm curious what you think (and apologies for the long story).

@lkysow
Copy link
Member Author

lkysow commented Mar 19, 2020

Ack sorry I missed that in my commit, I had it locally. You need

  - apiGroups: [""]
    resources:
      - services
    resourceNames:
      - {{ template "consul.fullname" . }}-mesh-gateway
    verbs:
      - get

I'll update the PR.

@ishustava
Copy link
Contributor

Update: my tests were successful after adding the clusterrole rules. Barring what I said about UX improvements, I think this is good to go, but would like to hear what you think first.

@lkysow lkysow force-pushed the mesh-gateway-lifecycle-sidecar branch from f46a444 to 0474f5d Compare March 20, 2020 19:36
@lkysow lkysow changed the base branch from mesh-gateway-lifecycle-sidecar to wan-federation March 23, 2020 17:46
@lkysow lkysow force-pushed the mesh-gateway-use-loadbalancer-address branch from 4582459 to 8a3e4ef Compare March 23, 2020 22:44
@lkysow
Copy link
Member Author

lkysow commented Mar 23, 2020

Updated to have wanAddress.source=Service be smarter. See values.yaml docs for new behaviour. Needs hashicorp/consul-k8s#235 since we now support ClusterIP services via the load-balancer-address => service-address command

@lkysow lkysow force-pushed the mesh-gateway-use-loadbalancer-address branch 2 times, most recently from 189e10b to 1790a25 Compare March 23, 2020 22:54
@lkysow lkysow requested a review from ishustava March 23, 2020 22:55
@ishustava
Copy link
Contributor

ishustava commented Mar 24, 2020

@lkysow I found a problem with my own suggestion to add wan_ipv4 tagged address 🤦‍♀ . When I tried it on EKS, I got this error in the service-init container:

Address "a143257ad85f14ba6a4e526cf2ae9760-2083317689.us-west-2.elb.amazonaws.com" written to address.txt successfully
Error registering service "mesh-gateway": Unexpected response code: 500 (Service tagged address "wan_ipv4" must be a valid ipv4 address)

Copy link
Contributor

@ishustava ishustava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes to support the different kinds of services! I've left a couple of thoughts so far.

values.yaml Show resolved Hide resolved
values.yaml Outdated Show resolved Hide resolved
values.yaml Outdated Show resolved Hide resolved
values.yaml Outdated Show resolved Hide resolved
@lkysow
Copy link
Member Author

lkysow commented Mar 26, 2020

Removed all _ipv4 addresses. I've also tested on EKS, AKS and GKE now. I've set the default containerPort to be 8443 instead of 443 because I was getting bind permission errors on GKE.

Copy link
Contributor

@ishustava ishustava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good (except for some failing unit tests)!

templates/mesh-gateway-deployment.yaml Outdated Show resolved Hide resolved
Add support for using the external address of Kubernetes load balancer
for the mesh gateway wan address.

This change uses the new consul-k8s service-address command to get
the address of the load balancer.

It also removes meshGateway.wanAddress.{useNodeIP, useNodeName, host}
config values in favour of meshGateway.wanAddress.{source, static}. The
new source value allows selecting NodeIP, NodeName, Service
or Static. This is more extensible than the previous boolean values.

We also change the default containerPort to 8443 from 443 because that
port can't be bound to on GKE.

These are backwards incompatible changes.
@lkysow lkysow force-pushed the mesh-gateway-use-loadbalancer-address branch from 76e78be to a69bee4 Compare March 26, 2020 23:11
@lkysow lkysow merged commit 30c521c into wan-federation Mar 26, 2020
@lkysow lkysow deleted the mesh-gateway-use-loadbalancer-address branch August 31, 2020 21:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/multi-dc Related to running with multiple datacenters enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants