Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for HTTPS Redirects #1206

Merged
merged 1 commit into from
Aug 6, 2020

Conversation

spencerhance
Copy link
Contributor

@spencerhance spencerhance commented Aug 5, 2020

Adds support for using HTTPS Redirects with L7 ELB via a Redirects Config in FrontendConfig
Also includes a new status annotation for the additional UrlMap that needs to be synced

e2e tests will be added in a follow up

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 5, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @spencerhance. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 5, 2020
@rramkumar1
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 5, 2020
Copy link
Contributor

@rramkumar1 rramkumar1 left a comment

Choose a reason for hiding this comment

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

LGTM, would like one more pair of eyes on it though.

@geun geun mentioned this pull request Aug 5, 2020
@spencerhance
Copy link
Contributor Author

@freehan can you also take a look?

/assign @freehan

Copy link
Contributor

@freehan freehan left a comment

Choose a reason for hiding this comment

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

How about only supporting GC for the v2 naming scheme.

One more thing, there is one corner case: If someone enabled the HTTP redirect and disable later. Will the RedirectURLMap get trimmed? From the code, I do not think so, right?

Maybe handle this as part of the ensureRedirectUrlMap code?

@@ -88,6 +90,11 @@ func (ln *V1IngressFrontendNamer) UrlMap() string {
return ln.namer.UrlMap(ln.lbName)
}

// UrlMap implements IngressFrontendNamer.
func (ln *V1IngressFrontendNamer) RedirectUrlMap() string {
return ln.namer.RedirectUrlMap(ln.lbName)
Copy link
Contributor

Choose a reason for hiding this comment

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

I strongly recommend NOT to support this feature in V1 Namer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Return an error event. Asking user to recreate ingress and it will come with new naming scheme.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -25,6 +25,8 @@ type IngressFrontendNamer interface {
TargetProxy(protocol NamerProtocol) string
// UrlMap returns the name of the URL Map.
UrlMap() string
// RedirectUrlMap returns the name of the URL Map.
RedirectUrlMap() string
Copy link
Contributor

Choose a reason for hiding this comment

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

// RedirectUrlMap returns the name of the URL Map and if the namer supports naming redirectUrlMap
RedirectUrlMap() (string, bool)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@spencerhance
Copy link
Contributor Author

@freehan

One more thing, there is one corner case: If someone enabled the HTTP redirect and disable later. Will the RedirectURLMap get trimmed? From the code, I do not think so, right?

Good point, I added in code to delete it when disabled

return err
}

currentMap, err := composite.GetUrlMap(l.cloud, key, l.Versions().UrlMap)
Copy link
Contributor

Choose a reason for hiding this comment

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

Might worth avoiding this GET call every time an irrelevant ingress was synced.

One idea is to check if the the ingress status annotation has the redirectUrlMap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return err
}

if expectedMap == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

add a comment here to say "do not expect to have a RedirectUrlMap"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return err
}
}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

probably no need for the else block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Adds support for using HTTPS Redirects via a Redirects Config in FrontendConfig
Also includes a new status annotation for the additional UrlMap that needs to be synced
Copy link
Contributor

@freehan freehan left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 6, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: freehan, spencerhance

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 6, 2020
@k8s-ci-robot k8s-ci-robot merged commit 97f0158 into kubernetes:master Aug 6, 2020
@spencerhance spencerhance deleted the https-redirects-demo branch August 6, 2020 23:26
@coderaven
Copy link

Good to know this has been merged finally! I'm new to this, when is the expected timeline for this to be available in GKE? And is there any documentation that comes along with it?

@peterldowns
Copy link

Yes, would really love to use this, when will it be available in GKE?

@artvichi
Copy link

Is this going to be live at some point in this century ?

@spencerhance
Copy link
Contributor Author

Hi folks, please follow the discussion at #1075

We are doing everything we can to launch this ASAP

tr := translator.NewTranslator(isL7ILB, l.namer)
// Get UrlMap Name, could be the url map or the redirect url map
// TODO(shance): move to translator
var umName string
Copy link

Choose a reason for hiding this comment

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

Why didn't this code written as follow with less branches?

umName := l.um.Name
if flags.F.EnableFrontendConfig {
  // TODO(shance): check for empty name?
    if l.redirectUm != nil && l.runtimeInfo.FrontendConfig.Spec.RedirectToHttps != nil && l.runtimeInfo.FrontendConfig.Spec.RedirectToHttps.Enabled {
      umName = l.redirectUm.Name
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants