-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for using gateway.spec.addresses as gateway service exter…
…nal ip Signed-off-by: Shawnh2 <[email protected]>
- Loading branch information
Showing
6 changed files
with
55 additions
and
44 deletions.
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,40 @@ | ||
// 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) | ||
} | ||
} | ||
} | ||
|
||
gwInfraIR.Proxy.Addresses = sets.List(ipAddr) | ||
} | ||
} |
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
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