Skip to content

Commit e4a1b94

Browse files
committed
publish addresses
Change-Id: I2ab9156410d042a871337306e35f1205d5534f36
1 parent 970ac20 commit e4a1b94

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

pkg/gateway/gateway.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package gateway
33
import (
44
"context"
55
"fmt"
6+
"net"
67
"time"
78

89
clusterv3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
@@ -18,6 +19,7 @@ import (
1819
"k8s.io/apimachinery/pkg/labels"
1920
"k8s.io/client-go/tools/cache"
2021
"k8s.io/klog/v2"
22+
"k8s.io/utils/ptr"
2123

2224
"sigs.k8s.io/cloud-provider-kind/pkg/config"
2325
"sigs.k8s.io/cloud-provider-kind/pkg/container"
@@ -79,9 +81,31 @@ func (c *Controller) syncGateway(key string) error {
7981
return err
8082
}
8183
}
82-
8384
// Update configuration
8485
newGw := gw.DeepCopy()
86+
ipv4, ipv6, err := container.IPs(containerName)
87+
if err != nil {
88+
if strings.Contains(err.Error(), "failed to get container details") {
89+
return err
90+
}
91+
return err
92+
}
93+
newGw.Status.Addresses = []gatewayv1.GatewayStatusAddress{}
94+
if net.ParseIP(ipv4) != nil {
95+
newGw.Status.Addresses = append(newGw.Status.Addresses,
96+
gatewayv1.GatewayStatusAddress{
97+
Type: ptr.To(gatewayv1.IPAddressType),
98+
Value: ipv4,
99+
})
100+
}
101+
if net.ParseIP(ipv6) != nil {
102+
newGw.Status.Addresses = append(newGw.Status.Addresses,
103+
gatewayv1.GatewayStatusAddress{
104+
Type: ptr.To(gatewayv1.IPAddressType),
105+
Value: ipv6,
106+
})
107+
}
108+
85109
resources := map[resourcev3.Type][]envoyproxytypes.Resource{}
86110
newGw.Status.Conditions, _ = UpdateConditionIfChanged(newGw.Status.Conditions, metav1.Condition{
87111
Type: string(gatewayv1.GatewayConditionAccepted),

0 commit comments

Comments
 (0)