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

Add ingress option #774

Merged
merged 6 commits into from
Jan 22, 2021
Merged

Add ingress option #774

merged 6 commits into from
Jan 22, 2021

Conversation

thisisnotashwin
Copy link

@thisisnotashwin thisisnotashwin commented Jan 20, 2021

Changes proposed in this PR:

The ingress resource always performs TLS termination at the point of ingress and can only communicate with the Consul server over the HTTP port. This can be avoided by certain ingress controllers that have the option of allowing ssl pass-through. Added a note to ensure that users have an ingress controller that can passthrough SSL and have it enabled if they want to enable TLS on Consul.

How I've tested this PR:

  • Deployed an ingress controller on the kubernetes cluster (nginx).
  • Performed a helm deploy with ingress enabled for UI. Verified the fields on the ingress resource created for non-TLS and TLS (with HTTP enabled) use cases and was able to access the UI via the created Ingress. (GKE creates a LoadBalancer for ingress)

How I expect reviewers to test this PR:

  • Code review.

Checklist:

@thisisnotashwin thisisnotashwin marked this pull request as ready for review January 21, 2021 19:59
@thisisnotashwin thisisnotashwin requested review from kschoche, a team and lkysow and removed request for a team January 21, 2021 19:59
Copy link
Member

@lkysow lkysow left a comment

Choose a reason for hiding this comment

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

I'm wondering about the version of the object we're using:

W0121 13:39:33.134204   34932 warnings.go:70] extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress

[ "${actual}" = "foo.com" ]
}

@test "ui/Ingress: port 80 when global.tls.enabled=false enables http port" {
Copy link
Member

Choose a reason for hiding this comment

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

I'm finding these test descriptions a bit hard to grok. Maybe "exposes single backed on port 80 when global.tls.enabled=false" and "exposes backends on ports 80 and 443 when ..."?

Copy link
Author

Choose a reason for hiding this comment

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

omg i just read the test names and i admit they are horrible. copy-pasting with proof-reading. this is why we review!

Comment on lines +964 to +968
# tls is a list of hosts and secret name in an Ingress
# which tells the Ingress controller to secure the channel.
Copy link
Member

Choose a reason for hiding this comment

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

Should we tell them what secret to use? Do they need to use passthrough TLS if consul tls is enabled?

Copy link
Author

Choose a reason for hiding this comment

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

So i realized in my tinkering that i hadn't tested the only TLS (https only enabled) options. ie, the 80 port was always open on the service. the ingress resource always performs TLS termination so we cant point traffic to 443 as the request that reached the service will always be HTTP. I guess it doesnt make sense for this PR to support port 443 in that case, and ill make the requisite changes.

@thisisnotashwin
Copy link
Author

@lkysow re version: I can switch over to version v1. This was the version on the initial PR but i think it makes sense to up it given it has been supported since 1.14

@thisisnotashwin thisisnotashwin force-pushed the add-ingress-option branch 4 times, most recently from 09aa9da to 84c20f8 Compare January 22, 2021 17:16
- host: {{ .host | quote }}
http:
paths:
{{- if (or (not $global.tls.enabled) (not $global.tls.httpsOnly)) }}

Choose a reason for hiding this comment

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

The only difference I'm seeing between L27-32 and L35-49 is the servicePort. So why not just make that the conditional instead of the entire block?

Copy link
Author

@thisisnotashwin thisisnotashwin Jan 22, 2021

Choose a reason for hiding this comment

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

I guess the only motivation there would be in a situation when TLS is enabled but both HTTP and HTTPs traffic is allowed, we would need both the blocks. I can look at DRY-ing this up though.

Choose a reason for hiding this comment

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

I see your point from a what's allowed perspective, but not sure why someone would create an Ingress and allow port 80 traffic, if 443 is available for the UI. I would think that the primary reason for having 80 and 443 enabled on consul is because they are migrating from 80 to 443 and havent finished shoring up the clients still using 80.

Choose a reason for hiding this comment

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

And in the case where they are both enabled how does the ingress know which backend to send to if they are defined the exact same way but with different servicePort? This is just a general curiousity question, if the path were different, I could see how it would work. But I'd almost think this would be an invalid configuration for an Ingress.

Copy link
Author

Choose a reason for hiding this comment

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

In case the Ingress controller does not support TLS passthrough, only supporting port 443 will not work. In the case when both ports are exposed, the controller multiplexes the requests across the ports and responds with whichever response is successful.
That is a really good questions though. I tested it with both ports open without the passthrough and it worked like a treat.

Copy link
Author

Choose a reason for hiding this comment

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

This allows for maximum flexibility but ensures the ability to expose just the one port (443) if that is so desired. Did I understand your question correctly?

Copy link
Contributor

@kschoche kschoche left a comment

Choose a reason for hiding this comment

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

🧨

@thisisnotashwin thisisnotashwin merged commit a4894e9 into master Jan 22, 2021
@thisisnotashwin thisisnotashwin deleted the add-ingress-option branch January 22, 2021 19:01
@thisisnotashwin thisisnotashwin mentioned this pull request Jan 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants