-
Notifications
You must be signed in to change notification settings - Fork 361
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
Add support for using gateway.spec.addresses as service external ips #1322
Merged
Merged
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
359623b
Implements Gateway.Spec.Addresses.
tommie ed8ffd0
Uses Gateway.Addresses in Gateway.Status.Addresses as a fallback.
tommie 4d4b1ca
fixup assignment
tommie 00351d0
add support for using gateway.spec.addresses as gateway service exter…
shawnh2 651b5fa
fix unit test
shawnh2 5c704c7
Merge branch 'main' into udef-gw-addr/external-ips
shawnh2 666f534
regenerate ir and add some other tweaks
shawnh2 2f20161
update address set in resource provider and add some test to it
shawnh2 5a462cb
Merge branch 'main' of github.com:envoyproxy/gateway into udef-gw-add…
shawnh2 6db842a
Merge branch 'main' of github.com:envoyproxy/gateway into udef-gw-add…
shawnh2 80821b0
resolve conflicts
shawnh2 dfb0c7f
add doc
shawnh2 c51aca2
Merge branch 'main' into udef-gw-addr/external-ips
shawnh2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright Envoy Gateway Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// The full text of the Apache license is available in the LICENSE file at | ||
// the root of the repo. | ||
|
||
package gatewayapi | ||
|
||
import ( | ||
"net/netip" | ||
|
||
"k8s.io/apimachinery/pkg/util/sets" | ||
"sigs.k8s.io/gateway-api/apis/v1beta1" | ||
) | ||
|
||
var _ AddressesTranslator = (*Translator)(nil) | ||
|
||
type AddressesTranslator interface { | ||
ProcessAddresses(gateways []*GatewayContext, xdsIR XdsIRMap, infraIR InfraIRMap, resources *Resources) | ||
} | ||
|
||
func (t *Translator) ProcessAddresses(gateways []*GatewayContext, xdsIR XdsIRMap, infraIR InfraIRMap, resources *Resources) { | ||
for _, gateway := range gateways { | ||
// Infra IR already exist | ||
irKey := irStringKey(gateway.Gateway) | ||
gwInfraIR := infraIR[irKey] | ||
|
||
ipAddr := sets.Set[string]{} | ||
|
||
for _, addr := range gateway.Spec.Addresses { | ||
switch *addr.Type { | ||
case v1beta1.IPAddressType: | ||
if _, err := netip.ParseAddr(addr.Value); err == nil { | ||
ipAddr.Insert(addr.Value) | ||
} | ||
} | ||
} | ||
|
||
if ip := sets.List(ipAddr); len(ip) > 0 { | ||
shawnh2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
gwInfraIR.Proxy.Addresses = ip | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can we expose the error in the status condition ?
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.
actually, we cannot expose this error in the status condition.
becasue when we apply an invalid IP address (like
a.b.c.d
) to Gateway, it will fail to create a Gateway Service,gateway/internal/infrastructure/kubernetes/service.go
Lines 20 to 32 in f81c011
thus we cannot get this Service when setting the status condition:
gateway/internal/status/gateway.go
Lines 25 to 28 in f81c011
IMO, we can solve this by validating the
Gateway.Spec.Addresses
before creating the Service, since the GW API does not provide any validation webhook on this field, should we validate it ourselves or raise an issue in upstream?cc @arkodg
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.
thanks for raising an issue upstream !