Skip to content

Commit 5234fdb

Browse files
committed
add public vpc-v6 ips as external IPs over slaac ips
1 parent 69cab7f commit 5234fdb

File tree

4 files changed

+420
-350
lines changed

4 files changed

+420
-350
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,5 @@ require (
162162
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
163163
sigs.k8s.io/yaml v1.6.0 // indirect
164164
)
165+
166+
replace github.com/linode/linodego => github.com/tchinmai7/linodego v1.34.1-0.20251210202607-51bdf5ee1ca4

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
187187
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
188188
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
189189
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
190-
github.com/linode/linodego v1.61.0 h1:9g20NWl+/SbhDFj6X5EOZXtM2hBm1Mx8I9h8+F3l1LM=
191-
github.com/linode/linodego v1.61.0/go.mod h1:64o30geLNwR0NeYh5HM/WrVCBXcSqkKnRK3x9xoRuJI=
192190
github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4=
193191
github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU=
194192
github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo=
@@ -272,6 +270,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
272270
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
273271
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
274272
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
273+
github.com/tchinmai7/linodego v1.34.1-0.20251210202607-51bdf5ee1ca4 h1:4nhrDtRLSeiJvLEg8LcAA3SIOWkVvqssJa0GcnhAWQY=
274+
github.com/tchinmai7/linodego v1.34.1-0.20251210202607-51bdf5ee1ca4/go.mod h1:64o30geLNwR0NeYh5HM/WrVCBXcSqkKnRK3x9xoRuJI=
275275
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
276276
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
277277
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=

internal/controller/linodemachine_controller_helpers.go

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,18 +260,6 @@ func buildInstanceAddrs(ctx context.Context, machineScope *scope.MachineScope, i
260260
Type: clusterv1.MachineExternalIP,
261261
})
262262

263-
// check if a node has public ipv6 ip and store it
264-
if addresses.IPv6 == nil {
265-
return nil, errNoPublicIPv6Addrs
266-
}
267-
if addresses.IPv6.SLAAC == nil {
268-
return nil, errNoPublicIPv6SLAACAddrs
269-
}
270-
ips = append(ips, clusterv1.MachineAddress{
271-
Address: addresses.IPv6.SLAAC.Address,
272-
Type: clusterv1.MachineExternalIP,
273-
})
274-
275263
// check if a node has vpc specific ip and store it
276264
for _, vpcIP := range addresses.IPv4.VPC {
277265
if vpcIP.Address != nil && *vpcIP.Address != "" {
@@ -281,6 +269,39 @@ func buildInstanceAddrs(ctx context.Context, machineScope *scope.MachineScope, i
281269
})
282270
}
283271
}
272+
// get the interfaces?
273+
274+
vpcPublicIPv6 := false
275+
// if the cluster has a public vpc ipv6 exclude the slaac
276+
for _, vpcIP := range addresses.IPv6.VPC {
277+
var ipType clusterv1.MachineAddressType
278+
if vpcIP.IPv6IsPublic != nil && *vpcIP.IPv6IsPublic {
279+
vpcPublicIPv6 = true
280+
ipType = clusterv1.MachineExternalIP
281+
} else {
282+
ipType = clusterv1.MachineInternalIP
283+
}
284+
for _, ipv6IP := range vpcIP.IPv6Addresses {
285+
ips = append(ips, clusterv1.MachineAddress{
286+
Address: ipv6IP.SLAACAddress,
287+
Type: ipType,
288+
})
289+
}
290+
}
291+
292+
if !vpcPublicIPv6 {
293+
// check if a node has public ipv6 ip and store it
294+
if addresses.IPv6 == nil {
295+
return nil, errNoPublicIPv6Addrs
296+
}
297+
if addresses.IPv6.SLAAC == nil {
298+
return nil, errNoPublicIPv6SLAACAddrs
299+
}
300+
ips = append(ips, clusterv1.MachineAddress{
301+
Address: addresses.IPv6.SLAAC.Address,
302+
Type: clusterv1.MachineExternalIP,
303+
})
304+
}
284305

285306
if machineScope.LinodeCluster.Spec.Network.UseVlan {
286307
vlanIps, err := handleVlanIps(ctx, machineScope, instanceID)

0 commit comments

Comments
 (0)