-
Notifications
You must be signed in to change notification settings - Fork 618
feat: set loadbalancerIP from Gateway.spec.addresses #13070
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 9 commits
fd60631
ba7ba13
f80228b
eae9871
3eccc8f
4a81e39
e6ba24b
7fb0cc1
f06b866
6f51567
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,9 @@ | ||||||||
| package deployer | ||||||||
|
|
||||||||
| import ( | ||||||||
| "errors" | ||||||||
| "fmt" | ||||||||
| "net/netip" | ||||||||
| "regexp" | ||||||||
| "sort" | ||||||||
| "strings" | ||||||||
|
|
@@ -18,6 +20,14 @@ import ( | |||||||
| "github.com/kgateway-dev/kgateway/v2/pkg/pluginsdk/ir" | ||||||||
| ) | ||||||||
|
|
||||||||
| var ( | ||||||||
| // ErrMultipleAddresses is returned when multiple addresses are specified in Gateway.spec.addresses | ||||||||
| ErrMultipleAddresses = errors.New("multiple addresses given, only one address is supported") | ||||||||
|
|
||||||||
| // ErrNoValidIPAddress is returned when no valid IP address is found in Gateway.spec.addresses | ||||||||
| ErrNoValidIPAddress = errors.New("no valid IP address found in Gateway.spec.addresses") | ||||||||
| ) | ||||||||
|
|
||||||||
| // This file contains helper functions that generate helm values in the format needed | ||||||||
| // by the deployer. | ||||||||
|
|
||||||||
|
|
@@ -108,16 +118,59 @@ func GetServiceValues(svcConfig *kgateway.Service) *HelmService { | |||||||
| // convert the service type enum to its string representation; | ||||||||
| // if type is not set, it will default to 0 ("ClusterIP") | ||||||||
| var svcType *string | ||||||||
| if svcConfig.GetType() != nil { | ||||||||
| svcType = ptr.To(string(*svcConfig.GetType())) | ||||||||
| var clusterIP *string | ||||||||
| var extraAnnotations map[string]string | ||||||||
| var extraLabels map[string]string | ||||||||
| var externalTrafficPolicy *string | ||||||||
|
|
||||||||
| if svcConfig != nil { | ||||||||
| if svcConfig.GetType() != nil { | ||||||||
| svcType = ptr.To(string(*svcConfig.GetType())) | ||||||||
| } | ||||||||
| clusterIP = svcConfig.GetClusterIP() | ||||||||
| extraAnnotations = svcConfig.GetExtraAnnotations() | ||||||||
| extraLabels = svcConfig.GetExtraLabels() | ||||||||
| externalTrafficPolicy = svcConfig.GetExternalTrafficPolicy() | ||||||||
| } | ||||||||
|
|
||||||||
| return &HelmService{ | ||||||||
| Type: svcType, | ||||||||
| ClusterIP: svcConfig.GetClusterIP(), | ||||||||
| ExtraAnnotations: svcConfig.GetExtraAnnotations(), | ||||||||
| ExtraLabels: svcConfig.GetExtraLabels(), | ||||||||
| ExternalTrafficPolicy: svcConfig.GetExternalTrafficPolicy(), | ||||||||
| ClusterIP: clusterIP, | ||||||||
| ExtraAnnotations: extraAnnotations, | ||||||||
| ExtraLabels: extraLabels, | ||||||||
| ExternalTrafficPolicy: externalTrafficPolicy, | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| // SetLoadBalancerIPFromGateway extracts the IP address from Gateway.spec.addresses | ||||||||
| // and sets it on the HelmService if the service type is LoadBalancer. | ||||||||
| // Only sets the IP if exactly one valid IP address is found in Gateway.spec.addresses. | ||||||||
| // Returns an error if more than one address is specified or no valid IP address is found. | ||||||||
|
||||||||
| // Returns an error if more than one address is specified or no valid IP address is found. | |
| // Returns an error if more than one address is specified, if the single address is not of type IPAddress, | |
| // or if the IP address value is invalid. |
Uh oh!
There was an error while loading. Please reload this page.