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

Support exposing ClusterIngress to two or more shared Gateways. #2666

Merged
merged 7 commits into from
Dec 7, 2018

Conversation

tcnghia
Copy link
Contributor

@tcnghia tcnghia commented Dec 7, 2018

Proposed Changes

In order for existing users to migrate cleanly off existing knative-ingressgateway we need to have a mechanism to allow them to expose their Services to two or more External LoadBalancer and cleanly update the domain to point to new IP address. This change makes that possible.

Hence even though #1969 is fixed we will leave the knative-ingressgateway around and will have it removed may be when 0.4 rolls out.

Release Note

Reinstate the `knative-ingressgateway` to allow existing users to upgrade cleanly.

@knative-prow-robot knative-prow-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 7, 2018
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@tcnghia: 4 warnings.

In response to this:

Proposed Changes

In order for existing users to migrate cleanly off existing knative-ingressgateway we need to have a mechanism to allow them to expose their Services to two or more External LoadBalancer and cleanly update the domain to point to new IP address. This change makes that possible.

So even though #1969 is fixed we will leave the knative-ingressgateway around and will have it removed may be when 0.4 rolls out.

Release Note

Reinstate the `knative-ingressgateway` to allow existing users to upgrade cleanly.

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.

@knative-prow-robot knative-prow-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 7, 2018
@tcnghia
Copy link
Contributor Author

tcnghia commented Dec 7, 2018

/lint

Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@tcnghia: 1 unresolved warning and 0 new warning.

In response to this:

/lint

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.

@tcnghia
Copy link
Contributor Author

tcnghia commented Dec 7, 2018

/test pull-knative-serving-unit-tests

@tcnghia
Copy link
Contributor Author

tcnghia commented Dec 7, 2018

/test pull-knative-serving-integration-tests

@knative-prow-robot knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 7, 2018
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Dec 7, 2018
@tcnghia tcnghia changed the title [WIP] Support exposing ClusterIngress to two or more shared Gateways. Support exposing ClusterIngress to two or more shared Gateways. Dec 7, 2018
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 7, 2018
@mattmoor mattmoor self-assigned this Dec 7, 2018
# ${gatewayName}:${gatewayService}, where ${gatewayName} is the name of
# the Gateway, and ${gatewayService} is the URL of the service backing
# that gateway.
ingress-gateway: "knative-ingress-gateway:istio-ingressgateway.istio-system.svc.cluster.local;knative-shared-gateway:knative-ingressgateway.istio-system.svc.cluster.local"
Copy link
Member

Choose a reason for hiding this comment

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

let's use a wildcard on keys, like this:

loglevel.controller: "info"
loglevel.autoscaler: "info"
loglevel.queueproxy: "info"
loglevel.webhook: "info"
loglevel.activator: "info"

*-gateway: in config-istio.yaml seems like a safe compromise :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since I don't want the Istio Gateway CRD to be named with -gateway suffix all the time, I opted to use a "gateway." prefix instead.

@tcnghia
Copy link
Contributor Author

tcnghia commented Dec 7, 2018

/test pull-knative-serving-upgrade-tests

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

couple nits / questions

originGateway = "origin.ns.svc.cluster.local"
customGateway = "custom.ns.svc.cluster.local"
originDomainInternal = "origin.ns.svc.cluster.local"
newDomainInternal = "custom.ns.svc.cluster.local"
Copy link
Member

Choose a reason for hiding this comment

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

use these constants above?

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

@@ -31,26 +33,51 @@ const (
// IngressGatewayKey is the name of the configuration entry
// that specifies ingress gateway url.
IngressGatewayKey = "ingress-gateway"
Copy link
Member

Choose a reason for hiding this comment

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

Remove?

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

urls := map[string]string{}
gatewayNames := []string{}
for k, v := range configMap.Data {
if strings.HasPrefix(k, GatewayKeyPrefix) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: if !... { continue } to reduce indent.

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

@@ -32,12 +32,10 @@ func TestStoreLoadWithContext(t *testing.T) {
store.OnConfigChanged(istioConfig)
config := FromContext(store.ToContext(context.Background()))

t.Run("load istio", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Why'd you remove the t.Run?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the test name isn't changing inside a for loop, I didn't see any purpose for the t.Run

if !strings.HasPrefix(k, GatewayKeyPrefix) {
continue
}
gatewayName, serviceURL := strings.TrimPrefix(k, GatewayKeyPrefix), v
Copy link
Contributor

Choose a reason for hiding this comment

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

k[len(GatewayKeyPrefix):] gonna be much faster, since you already know the prefix is there

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

if errs := validation.IsDNS1123Subdomain(gateway); len(errs) > 0 {
return nil, fmt.Errorf("invalid gateway format: %v", errs)
if len(gatewayNames) == 0 {
return nil, fmt.Errorf("at least one gateway is required")
Copy link
Contributor

Choose a reason for hiding this comment

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

No formatting --> Error()

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 nil, fmt.Errorf("at least one gateway is required")
}
sort.Strings(gatewayNames)
gateways := []IngressGateway{}
Copy link
Contributor

Choose a reason for hiding this comment

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

make([]IG, 0, len(gatewayNames)

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

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

LGTM, but I agree with @vagababov nits. Thanks @vagababov :)

@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-serving-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/clusteringress/clusteringress.go 82.7% 83.5% 0.9
pkg/reconciler/v1alpha1/clusteringress/config/istio.go 100.0% 94.1% -5.9

@knative-prow-robot knative-prow-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Dec 7, 2018
Copy link
Member

@mattmoor mattmoor 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
/hold

@vagababov If this LGTY then /hold cancel

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mattmoor, tcnghia

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 7, 2018
@tcnghia
Copy link
Contributor Author

tcnghia commented Dec 7, 2018

/hold cancel
@vagababov already /lgtmed

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 7, 2018
@knative-prow-robot knative-prow-robot merged commit 241f470 into knative:master Dec 7, 2018
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. lgtm Indicates that a PR is ready to be merged. 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.

5 participants