Skip to content

Commit 760e7fd

Browse files
authored
[feat] : allocate ipv6 /64 cidrs to linodes (#773)
* add ipv6 ranges to VPC, subnet and nodes * allow specifying multiple ipv6 ranges as supported by API. Multiple ranges are not supported for now but maybe in future * add unittests * fix cognitive complexity of tests * address review comments * increase code coverage
1 parent b3e7cbb commit 760e7fd

12 files changed

+548
-23
lines changed

api/v1alpha2/linodevpc_types.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha2
1818

1919
import (
20+
"github.com/linode/linodego"
2021
corev1 "k8s.io/api/core/v1"
2122
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2223
)
@@ -36,6 +37,16 @@ type LinodeVPCSpec struct {
3637
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
3738
Region string `json:"region"`
3839
// +optional
40+
// IPv6 is a list of IPv6 ranges allocated to the VPC.
41+
// Once ranges are allocated based on the IPv6Range field, they will be
42+
// added to this field.
43+
IPv6 []linodego.VPCIPv6Range `json:"ipv6,omitempty"`
44+
// +optional
45+
// IPv6Range is a list of IPv6 ranges to allocate to the VPC.
46+
// If not specified, the VPC will not have an IPv6 range allocated.
47+
// Once ranges are allocated, they will be added to the IPv6 field.
48+
IPv6Range []VPCCreateOptionsIPv6 `json:"ipv6Range,omitempty"`
49+
// +optional
3950
Subnets []VPCSubnetCreateOptions `json:"subnets,omitempty"`
4051

4152
// Retain allows you to keep the VPC after the LinodeVPC object is deleted.
@@ -52,6 +63,17 @@ type LinodeVPCSpec struct {
5263
CredentialsRef *corev1.SecretReference `json:"credentialsRef,omitempty"`
5364
}
5465

66+
// VPCCreateOptionsIPv6 defines the options for creating an IPv6 range in a VPC.
67+
// It's copied from linodego.VPCCreateOptionsIPv6 and should be kept in sync.
68+
// Values supported by the linode API should be used here.
69+
// See https://techdocs.akamai.com/linode-api/reference/post-vpc for more details.
70+
type VPCCreateOptionsIPv6 struct {
71+
// Range is the IPv6 prefix for the VPC.
72+
Range *string `json:"range,omitempty"`
73+
// IPv6 inventory from which the VPC prefix should be allocated.
74+
AllocationClass *string `json:"allocation_class,omitempty"`
75+
}
76+
5577
// VPCSubnetCreateOptions defines subnet options
5678
type VPCSubnetCreateOptions struct {
5779
// +kubebuilder:validation:MinLength=3
@@ -60,6 +82,16 @@ type VPCSubnetCreateOptions struct {
6082
Label string `json:"label,omitempty"`
6183
// +optional
6284
IPv4 string `json:"ipv4,omitempty"`
85+
// +optional
86+
// IPv6 is a list of IPv6 ranges allocated to the subnet.
87+
// Once ranges are allocated based on the IPv6Range field, they will be
88+
// added to this field.
89+
IPv6 []linodego.VPCIPv6Range `json:"ipv6,omitempty"`
90+
// +optional
91+
// IPv6Range is a list of IPv6 ranges to allocate to the subnet.
92+
// If not specified, the subnet will not have an IPv6 range allocated.
93+
// Once ranges are allocated, they will be added to the IPv6 field.
94+
IPv6Range []VPCSubnetCreateOptionsIPv6 `json:"ipv6Range,omitempty"`
6395
// SubnetID is subnet id for the subnet
6496
// +optional
6597
SubnetID int `json:"subnetID,omitempty"`
@@ -70,6 +102,14 @@ type VPCSubnetCreateOptions struct {
70102
Retain bool `json:"retain,omitempty"`
71103
}
72104

105+
// VPCSubnetCreateOptionsIPv6 defines the options for creating an IPv6 range in a VPC subnet.
106+
// It's copied from linodego.VPCSubnetCreateOptionsIPv6 and should be kept in sync.
107+
// Values supported by the linode API should be used here.
108+
// See https://techdocs.akamai.com/linode-api/reference/post-vpc-subnet for more details.
109+
type VPCSubnetCreateOptionsIPv6 struct {
110+
Range *string `json:"range,omitempty"`
111+
}
112+
73113
// LinodeVPCStatus defines the observed state of LinodeVPC
74114
type LinodeVPCStatus struct {
75115
// Ready is true when the provider resource is ready.

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 72 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_linodevpcs.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,42 @@ spec:
6767
x-kubernetes-map-type: atomic
6868
description:
6969
type: string
70+
ipv6:
71+
description: |-
72+
IPv6 is a list of IPv6 ranges allocated to the VPC.
73+
Once ranges are allocated based on the IPv6Range field, they will be
74+
added to this field.
75+
items:
76+
description: VPCIPv6Range represents a single IPv6 range assigned
77+
to a VPC.
78+
properties:
79+
range:
80+
type: string
81+
required:
82+
- range
83+
type: object
84+
type: array
85+
ipv6Range:
86+
description: |-
87+
IPv6Range is a list of IPv6 ranges to allocate to the VPC.
88+
If not specified, the VPC will not have an IPv6 range allocated.
89+
Once ranges are allocated, they will be added to the IPv6 field.
90+
items:
91+
description: |-
92+
VPCCreateOptionsIPv6 defines the options for creating an IPv6 range in a VPC.
93+
It's copied from linodego.VPCCreateOptionsIPv6 and should be kept in sync.
94+
Values supported by the linode API should be used here.
95+
See https://techdocs.akamai.com/linode-api/reference/post-vpc for more details.
96+
properties:
97+
allocation_class:
98+
description: IPv6 inventory from which the VPC prefix should
99+
be allocated.
100+
type: string
101+
range:
102+
description: Range is the IPv6 prefix for the VPC.
103+
type: string
104+
type: object
105+
type: array
70106
region:
71107
type: string
72108
x-kubernetes-validations:
@@ -86,6 +122,37 @@ spec:
86122
properties:
87123
ipv4:
88124
type: string
125+
ipv6:
126+
description: |-
127+
IPv6 is a list of IPv6 ranges allocated to the subnet.
128+
Once ranges are allocated based on the IPv6Range field, they will be
129+
added to this field.
130+
items:
131+
description: VPCIPv6Range represents a single IPv6 range assigned
132+
to a VPC.
133+
properties:
134+
range:
135+
type: string
136+
required:
137+
- range
138+
type: object
139+
type: array
140+
ipv6Range:
141+
description: |-
142+
IPv6Range is a list of IPv6 ranges to allocate to the subnet.
143+
If not specified, the subnet will not have an IPv6 range allocated.
144+
Once ranges are allocated, they will be added to the IPv6 field.
145+
items:
146+
description: |-
147+
VPCSubnetCreateOptionsIPv6 defines the options for creating an IPv6 range in a VPC subnet.
148+
It's copied from linodego.VPCSubnetCreateOptionsIPv6 and should be kept in sync.
149+
Values supported by the linode API should be used here.
150+
See https://techdocs.akamai.com/linode-api/reference/post-vpc-subnet for more details.
151+
properties:
152+
range:
153+
type: string
154+
type: object
155+
type: array
89156
label:
90157
maxLength: 63
91158
minLength: 3

docs/src/reference/out.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,8 @@ _Appears in:_
10781078
| `vpcID` _integer_ | | | |
10791079
| `description` _string_ | | | |
10801080
| `region` _string_ | | | |
1081+
| `ipv6` _VPCIPv6Range array_ | IPv6 is a list of IPv6 ranges allocated to the VPC.<br />Once ranges are allocated based on the IPv6Range field, they will be<br />added to this field. | | |
1082+
| `ipv6Range` _[VPCCreateOptionsIPv6](#vpccreateoptionsipv6) array_ | IPv6Range is a list of IPv6 ranges to allocate to the VPC.<br />If not specified, the VPC will not have an IPv6 range allocated.<br />Once ranges are allocated, they will be added to the IPv6 field. | | |
10811083
| `subnets` _[VPCSubnetCreateOptions](#vpcsubnetcreateoptions) array_ | | | |
10821084
| `retain` _boolean_ | Retain allows you to keep the VPC after the LinodeVPC object is deleted.<br />This is useful if you want to use an existing VPC that was not created by this controller.<br />If set to true, the controller will not delete the VPC resource in Linode.<br />Defaults to false. | false | |
10831085
| `credentialsRef` _[SecretReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#secretreference-v1-core)_ | CredentialsRef is a reference to a Secret that contains the credentials to use for provisioning this VPC. If not<br />supplied then the credentials of the controller will be used. | | |
@@ -1187,6 +1189,26 @@ _Appears in:_
11871189
| `credentialsRef` _[SecretReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#secretreference-v1-core)_ | CredentialsRef is a reference to a Secret that contains the credentials to use for accessing the Cluster Object Store. | | |
11881190

11891191

1192+
#### VPCCreateOptionsIPv6
1193+
1194+
1195+
1196+
VPCCreateOptionsIPv6 defines the options for creating an IPv6 range in a VPC.
1197+
It's copied from linodego.VPCCreateOptionsIPv6 and should be kept in sync.
1198+
Values supported by the linode API should be used here.
1199+
See https://techdocs.akamai.com/linode-api/reference/post-vpc for more details.
1200+
1201+
1202+
1203+
_Appears in:_
1204+
- [LinodeVPCSpec](#linodevpcspec)
1205+
1206+
| Field | Description | Default | Validation |
1207+
| --- | --- | --- | --- |
1208+
| `range` _string_ | Range is the IPv6 prefix for the VPC. | | |
1209+
| `allocation_class` _string_ | IPv6 inventory from which the VPC prefix should be allocated. | | |
1210+
1211+
11901212
#### VPCIPv4
11911213

11921214

@@ -1237,7 +1259,28 @@ _Appears in:_
12371259
| --- | --- | --- | --- |
12381260
| `label` _string_ | | | MaxLength: 63 <br />MinLength: 3 <br /> |
12391261
| `ipv4` _string_ | | | |
1262+
| `ipv6` _VPCIPv6Range array_ | IPv6 is a list of IPv6 ranges allocated to the subnet.<br />Once ranges are allocated based on the IPv6Range field, they will be<br />added to this field. | | |
1263+
| `ipv6Range` _[VPCSubnetCreateOptionsIPv6](#vpcsubnetcreateoptionsipv6) array_ | IPv6Range is a list of IPv6 ranges to allocate to the subnet.<br />If not specified, the subnet will not have an IPv6 range allocated.<br />Once ranges are allocated, they will be added to the IPv6 field. | | |
12401264
| `subnetID` _integer_ | SubnetID is subnet id for the subnet | | |
12411265
| `retain` _boolean_ | Retain allows you to keep the Subnet after the LinodeVPC object is deleted.<br />This is only applicable when the parent VPC has retain set to true. | false | |
12421266

12431267

1268+
#### VPCSubnetCreateOptionsIPv6
1269+
1270+
1271+
1272+
VPCSubnetCreateOptionsIPv6 defines the options for creating an IPv6 range in a VPC subnet.
1273+
It's copied from linodego.VPCSubnetCreateOptionsIPv6 and should be kept in sync.
1274+
Values supported by the linode API should be used here.
1275+
See https://techdocs.akamai.com/linode-api/reference/post-vpc-subnet for more details.
1276+
1277+
1278+
1279+
_Appears in:_
1280+
- [VPCSubnetCreateOptions](#vpcsubnetcreateoptions)
1281+
1282+
| Field | Description | Default | Validation |
1283+
| --- | --- | --- | --- |
1284+
| `range` _string_ | | | |
1285+
1286+

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/go-logr/logr v1.4.3
1616
github.com/google/go-cmp v0.7.0
1717
github.com/google/uuid v1.6.0
18-
github.com/linode/linodego v1.53.0
18+
github.com/linode/linodego v1.53.1-0.20250709175023-9b152d30578c
1919
github.com/onsi/ginkgo/v2 v2.23.4
2020
github.com/onsi/gomega v1.37.0
2121
github.com/stretchr/testify v1.10.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
177177
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
178178
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
179179
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
180-
github.com/linode/linodego v1.53.0 h1:UWr7bUUVMtcfsuapC+6blm6+jJLPd7Tf9MZUpdOERnI=
181-
github.com/linode/linodego v1.53.0/go.mod h1:bI949fZaVchjWyKIA08hNyvAcV6BAS+PM2op3p7PAWA=
180+
github.com/linode/linodego v1.53.1-0.20250709175023-9b152d30578c h1:WlZm+YNHBuphycMZG2s2+F04hx2wx1ShuOwPAIInjP8=
181+
github.com/linode/linodego v1.53.1-0.20250709175023-9b152d30578c/go.mod h1:bI949fZaVchjWyKIA08hNyvAcV6BAS+PM2op3p7PAWA=
182182
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
183183
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
184184
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=

0 commit comments

Comments
 (0)