Skip to content

Commit

Permalink
Report internal address if external address is not present
Browse files Browse the repository at this point in the history
Joined with kubernetes-sigs/gateway-api#743,
this allows displaying non-empty results when there is no external IP
for the Gateway (ie its a cluster IP gateway)
  • Loading branch information
howardjohn committed Aug 3, 2021
1 parent 6da7a31 commit 3521a24
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
14 changes: 10 additions & 4 deletions pilot/pkg/config/kube/gateway/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -1033,11 +1033,17 @@ func convertGateways(r *KubernetesResources) ([]config.Config, map[RouteKey][]ga
}
obj.Status.(*kstatus.WrappedStatus).Mutate(func(s config.Status) config.Status {
gs := s.(*k8s.GatewayStatus)
gs.Addresses = make([]k8s.GatewayAddress, 0, len(external))
for _, addr := range external {
ip := k8s.IPAddressType
addressesToReport := external
addrType := k8s.IPAddressType
if len(addressesToReport) == 0 {
addressesToReport = internal
// TODO should be hostname, in v1alpha2
addrType = k8s.NamedAddressType
}
gs.Addresses = make([]k8s.GatewayAddress, 0, len(addressesToReport))
for _, addr := range addressesToReport {
gs.Addresses = append(gs.Addresses, k8s.GatewayAddress{
Type: &ip,
Type: &addrType,
Value: addr,
})
}
Expand Down
13 changes: 6 additions & 7 deletions pilot/pkg/config/kube/gateway/testdata/zero.yaml.golden
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,19 @@ spec:
hosts:
- first.domain.example
http:
- match:
- fault:
abort:
httpStatus: 503
percentage:
value: 100
match:
- uri:
regex: /get((\/).*)?
route:
- destination:
host: httpbin-zero.default.svc.domain.suffix
port:
number: 8080
weight: 0
fault:
abort:
percentage:
value: 100
httpStatus: 503
- match:
- uri:
regex: /weighted-100((\/).*)?
Expand Down

0 comments on commit 3521a24

Please sign in to comment.