Skip to content

Commit 3142153

Browse files
author
Rahul Sharma
committed
allow specifying multiple ipv6 ranges as supported by API. Multiple ranges are not supported for now but maybe in future
1 parent 9448b87 commit 3142153

7 files changed

Lines changed: 281 additions & 60 deletions

File tree

api/v1alpha2/linodevpc_types.go

Lines changed: 34 additions & 11 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,18 +37,30 @@ 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+
// +kubebuilder:default={"range": "auto"}
46+
// IPv6Range is a list of IPv6 ranges to allocate to the VPC.
47+
IPv6Range []VPCCreateOptionsIPv6 `json:"ipv6Range,omitempty"`
48+
// +optional
3949
Subnets []VPCSubnetCreateOptions `json:"subnets,omitempty"`
4050

4151
// CredentialsRef is a reference to a Secret that contains the credentials to use for provisioning this VPC. If not
4252
// supplied then the credentials of the controller will be used.
4353
// +optional
4454
CredentialsRef *corev1.SecretReference `json:"credentialsRef,omitempty"`
45-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
46-
// +optional
47-
// +kubebuilder:validation:MinLength=2
48-
// +kubebuilder:validation:MaxLength=4
49-
// +kubebuilder:default="/52"
50-
IPv6Range string `json:"ipv6Range,omitempty"`
55+
}
56+
57+
// VPCCreateOptionsIPv6 defines the options for creating an IPv6 range in a VPC.
58+
// Its copied from linodego.VPCCreateOptionsIPv6 and should be kept in sync.
59+
// Values supported by the linode API should be used here.
60+
// See https://techdocs.akamai.com/linode-api/reference/post-vpc for more details.
61+
type VPCCreateOptionsIPv6 struct {
62+
Range *string `json:"range,omitempty"`
63+
AllocationClass *string `json:"allocation_class,omitempty"`
5164
}
5265

5366
// VPCSubnetCreateOptions defines subnet options
@@ -58,14 +71,24 @@ type VPCSubnetCreateOptions struct {
5871
Label string `json:"label,omitempty"`
5972
// +optional
6073
IPv4 string `json:"ipv4,omitempty"`
74+
// +optional
75+
IPv6 []linodego.VPCIPv6Range `json:"ipv6,omitempty"`
76+
// +optional
77+
// +kubebuilder:default={"range": "auto"}
78+
// IPv6Range is a list of IPv6 ranges to allocate to the subnet.
79+
// If not specified, the subnet will not have an IPv6 range allocated.
80+
IPv6Range []VPCSubnetCreateOptionsIPv6 `json:"ipv6Range,omitempty"`
6181
// SubnetID is subnet id for the subnet
6282
// +optional
6383
SubnetID int `json:"subnetID,omitempty"`
64-
// +optional
65-
// +kubebuilder:validation:MinLength=2
66-
// +kubebuilder:validation:MaxLength=4
67-
// +kubebuilder:default="/56"
68-
IPv6Range string `json:"ipv6Range,omitempty"`
84+
}
85+
86+
// VPCSubnetCreateOptionsIPv6 defines the options for creating an IPv6 range in a VPC subnet.
87+
// Its copied from linodego.VPCSubnetCreateOptionsIPv6 and should be kept in sync.
88+
// Values supported by the linode API should be used here.
89+
// See https://techdocs.akamai.com/linode-api/reference/post-vpc-subnet for more details.
90+
type VPCSubnetCreateOptionsIPv6 struct {
91+
Range *string `json:"range,omitempty"`
6992
}
7093

7194
// LinodeVPCStatus defines the observed state of LinodeVPC

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: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,39 @@ 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
7085
ipv6Range:
71-
default: /52
72-
maxLength: 4
73-
minLength: 2
74-
type: string
75-
x-kubernetes-validations:
76-
- message: Value is immutable
77-
rule: self == oldSelf
86+
default:
87+
range: auto
88+
description: IPv6Range is a list of IPv6 ranges to allocate to the
89+
VPC.
90+
items:
91+
description: |-
92+
VPCCreateOptionsIPv6 defines the options for creating an IPv6 range in a VPC.
93+
Its 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+
type: string
99+
range:
100+
type: string
101+
type: object
102+
type: array
78103
region:
79104
type: string
80105
x-kubernetes-validations:
@@ -86,11 +111,34 @@ spec:
86111
properties:
87112
ipv4:
88113
type: string
114+
ipv6:
115+
items:
116+
description: VPCIPv6Range represents a single IPv6 range assigned
117+
to a VPC.
118+
properties:
119+
range:
120+
type: string
121+
required:
122+
- range
123+
type: object
124+
type: array
89125
ipv6Range:
90-
default: /56
91-
maxLength: 4
92-
minLength: 2
93-
type: string
126+
default:
127+
range: auto
128+
description: |-
129+
IPv6Range is a list of IPv6 ranges to allocate to the subnet.
130+
If not specified, the subnet will not have an IPv6 range allocated.
131+
items:
132+
description: |-
133+
VPCSubnetCreateOptionsIPv6 defines the options for creating an IPv6 range in a VPC subnet.
134+
Its copied from linodego.VPCSubnetCreateOptionsIPv6 and should be kept in sync.
135+
Values supported by the linode API should be used here.
136+
See https://techdocs.akamai.com/linode-api/reference/post-vpc-subnet for more details.
137+
properties:
138+
range:
139+
type: string
140+
type: object
141+
type: array
94142
label:
95143
maxLength: 63
96144
minLength: 3

docs/src/reference/out.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,9 +1078,10 @@ _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. | \{ range:auto \} | |
10811083
| `subnets` _[VPCSubnetCreateOptions](#vpcsubnetcreateoptions) array_ | | | |
10821084
| `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. | | |
1083-
| `ipv6Range` _string_ | | /52 | MaxLength: 4 <br />MinLength: 2 <br /> |
10841085

10851086

10861087
#### LinodeVPCStatus
@@ -1187,6 +1188,26 @@ _Appears in:_
11871188
| `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. | | |
11881189

11891190

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

11921213

@@ -1237,7 +1258,27 @@ _Appears in:_
12371258
| --- | --- | --- | --- |
12381259
| `label` _string_ | | | MaxLength: 63 <br />MinLength: 3 <br /> |
12391260
| `ipv4` _string_ | | | |
1261+
| `ipv6` _VPCIPv6Range array_ | | | |
1262+
| `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. | \{ range:auto \} | |
12401263
| `subnetID` _integer_ | SubnetID is subnet id for the subnet | | |
1241-
| `ipv6Range` _string_ | | /56 | MaxLength: 4 <br />MinLength: 2 <br /> |
1264+
1265+
1266+
#### VPCSubnetCreateOptionsIPv6
1267+
1268+
1269+
1270+
VPCSubnetCreateOptionsIPv6 defines the options for creating an IPv6 range in a VPC subnet.
1271+
Its copied from linodego.VPCSubnetCreateOptionsIPv6 and should be kept in sync.
1272+
Values supported by the linode API should be used here.
1273+
See https://techdocs.akamai.com/linode-api/reference/post-vpc-subnet for more details.
1274+
1275+
1276+
1277+
_Appears in:_
1278+
- [VPCSubnetCreateOptions](#vpcsubnetcreateoptions)
1279+
1280+
| Field | Description | Default | Validation |
1281+
| --- | --- | --- | --- |
1282+
| `range` _string_ | | | |
12421283

12431284

internal/controller/linodemachine_controller_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,6 +2165,13 @@ var _ = Describe("machine in VPC", Label("machine", "VPC"), Ordered, func() {
21652165
Primary: true,
21662166
SubnetID: ptr.To(1),
21672167
IPv4: &linodego.VPCIPv4{NAT1To1: ptr.To("any")},
2168+
IPv6: &linodego.InstanceConfigInterfaceCreateOptionsIPv6{
2169+
Ranges: []linodego.InstanceConfigInterfaceCreateOptionsIPv6Range{
2170+
{
2171+
Range: ptr.To(ipv6Range),
2172+
},
2173+
},
2174+
},
21682175
},
21692176
{
21702177
Primary: true,
@@ -2311,6 +2318,13 @@ var _ = Describe("machine in VPC", Label("machine", "VPC"), Ordered, func() {
23112318
Primary: true,
23122319
SubnetID: ptr.To(27),
23132320
IPv4: &linodego.VPCIPv4{NAT1To1: ptr.To("any")},
2321+
IPv6: &linodego.InstanceConfigInterfaceCreateOptionsIPv6{
2322+
Ranges: []linodego.InstanceConfigInterfaceCreateOptionsIPv6Range{
2323+
{
2324+
Range: ptr.To(ipv6Range),
2325+
},
2326+
},
2327+
},
23142328
},
23152329
{
23162330
Primary: true,

0 commit comments

Comments
 (0)