-
Notifications
You must be signed in to change notification settings - Fork 220
NE-518 GCP: Implement GCP Internal LB Global Access option #550
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ package ingress | |
| import ( | ||
| "context" | ||
| "fmt" | ||
| "strconv" | ||
|
|
||
| operatorv1 "github.com/openshift/api/operator/v1" | ||
| "github.com/openshift/cluster-ingress-operator/pkg/manifests" | ||
|
|
@@ -85,6 +86,10 @@ const ( | |
| // load balancer. | ||
| gcpLBTypeAnnotation = "cloud.google.com/load-balancer-type" | ||
|
|
||
| // GCPGlobalAccessAnnotation is the annotation used on an internal load balancer service | ||
| // to enable the GCP Global Access feature. | ||
| GCPGlobalAccessAnnotation = "networking.gke.io/internal-load-balancer-allow-global-access" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest moving this to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typically we don't put implementation specific constants in the ingress controller API. I think it makes the most sense to define the annotation constant here alongside all of the other provider-specific load balancer service annotations. |
||
|
|
||
| // openstackInternalLBAnnotation is the annotation used on a service to specify an | ||
| // OpenStack load balancer as being internal. | ||
| openstackInternalLBAnnotation = "service.beta.kubernetes.io/openstack-internal-load-balancer" | ||
|
|
@@ -226,6 +231,16 @@ func desiredLoadBalancerService(ci *operatorv1.IngressController, deploymentRef | |
| for name, value := range annotation { | ||
| service.Annotations[name] = value | ||
| } | ||
|
|
||
| // Set the GCP Global Access annotation for internal load balancers on GCP only | ||
| if platform.Type == configv1.GCPPlatformType { | ||
| if ci.Status.EndpointPublishingStrategy.LoadBalancer.ProviderParameters != nil && | ||
| ci.Status.EndpointPublishingStrategy.LoadBalancer.ProviderParameters.Type == operatorv1.GCPLoadBalancerProvider && | ||
| ci.Status.EndpointPublishingStrategy.LoadBalancer.ProviderParameters.GCP != nil { | ||
| globalAccessEnabled := ci.Status.EndpointPublishingStrategy.LoadBalancer.ProviderParameters.GCP.ClientAccess == operatorv1.GCPGlobalAccess | ||
| service.Annotations[GCPGlobalAccessAnnotation] = strconv.FormatBool(globalAccessEnabled) | ||
| } | ||
| } | ||
| } | ||
| switch platform.Type { | ||
| case configv1.AWSPlatformType: | ||
|
|
@@ -353,20 +368,30 @@ func (r *reconciler) updateLoadBalancerService(current, desired *corev1.Service, | |
| // matches the expected and if not returns an updated one. | ||
| func loadBalancerServiceChanged(current, expected *corev1.Service) (bool, *corev1.Service) { | ||
| updated := current.DeepCopy() | ||
| changed := false | ||
|
|
||
| // Preserve everything but the AWS LB health check interval annotation | ||
| // Preserve everything but the AWS LB health check interval annotation & | ||
| // GCP Global Access internal Load Balancer annotation. | ||
| // (see <https://bugzilla.redhat.com/show_bug.cgi?id=1908758>). | ||
| // Updating annotations and spec fields cannot be done unless the | ||
| // previous release blocks upgrades when the user has modified those | ||
| // fields (see <https://bugzilla.redhat.com/show_bug.cgi?id=1905490>). | ||
| if updated.Annotations == nil { | ||
| updated.Annotations = map[string]string{} | ||
| } | ||
| if current.Annotations[awsLBHealthCheckIntervalAnnotation] == expected.Annotations[awsLBHealthCheckIntervalAnnotation] { | ||
| return false, nil | ||
| if current.Annotations[awsLBHealthCheckIntervalAnnotation] != expected.Annotations[awsLBHealthCheckIntervalAnnotation] { | ||
| updated.Annotations[awsLBHealthCheckIntervalAnnotation] = expected.Annotations[awsLBHealthCheckIntervalAnnotation] | ||
| changed = true | ||
| } | ||
|
|
||
| updated.Annotations[awsLBHealthCheckIntervalAnnotation] = expected.Annotations[awsLBHealthCheckIntervalAnnotation] | ||
| if current.Annotations[GCPGlobalAccessAnnotation] != expected.Annotations[GCPGlobalAccessAnnotation] { | ||
| updated.Annotations[GCPGlobalAccessAnnotation] = expected.Annotations[GCPGlobalAccessAnnotation] | ||
| changed = true | ||
| } | ||
|
|
||
| if !changed { | ||
| return false, nil | ||
| } | ||
|
|
||
| return true, updated | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a good time to remove the return value, since it isn't used by the caller. If we anticipate it to be used in the future, you might want to return true here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future we might use the return value from
setDefaultPublishingStrategyto detect if any changes were made toic.Status, so for now I'll add a return value here (surprisingly this was also overlooked in the reverted mutable-scope PR #472, so nice catch!).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.