Skip to content

Commit dd74578

Browse files
author
Rahul Sharma
committed
group ipv6 stuff in ipv6options
1 parent c938dca commit dd74578

File tree

7 files changed

+161
-57
lines changed

7 files changed

+161
-57
lines changed

api/v1alpha2/linodemachine_types.go

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,23 @@ type LinodeMachineSpec struct {
112112
// +optional
113113
VPCID *int `json:"vpcID,omitempty"`
114114

115+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
116+
// IPv6Options defines the IPv6 options for the instance.
117+
// If not specified, IPv6 ranges won't be allocated to instance.
118+
// +optional
119+
IPv6Options *IPv6CreateOptions `json:"ipv6Options,omitempty"`
120+
121+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
122+
// +optional
123+
// NetworkHelper is an option usually enabled on account level. It helps configure networking automatically for instances.
124+
// You can use this to enable/disable the network helper for a specific instance.
125+
// For more information, see https://techdocs.akamai.com/cloud-computing/docs/automatically-configure-networking
126+
// Defaults to true.
127+
NetworkHelper *bool `json:"networkHelper,omitempty"`
128+
}
129+
130+
// IPv6CreateOptions defines the IPv6 options for the instance.
131+
type IPv6CreateOptions struct {
115132
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
116133
// EnableSLAAC is an option to enable SLAAC (Stateless Address Autoconfiguration) for the instance.
117134
// This is useful for IPv6 addresses, allowing the instance to automatically configure its own IPv6 address.
@@ -120,17 +137,19 @@ type LinodeMachineSpec struct {
120137
EnableSLAAC *bool `json:"enableSLAAC,omitempty"`
121138

122139
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
123-
// IsPublicIPv6 is an option to enable public IPv6 for the instance.
124-
// If set to true, the instance will have a publicly routable IPv6 range.
125-
IsPublicIPv6 *bool `json:"isPublicIPv6,omitempty"`
140+
// EnableRanges is an option to enable IPv6 ranges for the instance.
141+
// If set to true, the instance will have a range of IPv6 addresses.
142+
// This is useful for instances that require multiple IPv6 addresses.
143+
// Defaults to false.
144+
// +optional
145+
EnableRanges *bool `json:"enableRanges,omitempty"`
126146

127147
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
148+
// IsPublicIPv6 is an option to enable public IPv6 for the instance.
149+
// If set to true, the instance will have a publicly routable IPv6 range.
150+
// Defaults to false.
128151
// +optional
129-
// NetworkHelper is an option usually enabled on account level. It helps configure networking automatically for instances.
130-
// You can use this to enable/disable the network helper for a specific instance.
131-
// For more information, see https://techdocs.akamai.com/cloud-computing/docs/automatically-configure-networking
132-
// Defaults to true.
133-
NetworkHelper *bool `json:"networkHelper,omitempty"`
152+
IsPublicIPv6 *bool `json:"isPublicIPv6,omitempty"`
134153
}
135154

136155
// InstanceDisk defines a list of disks to use for an instance

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 34 additions & 9 deletions
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_linodemachines.yaml

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,6 @@ spec:
163163
x-kubernetes-validations:
164164
- message: Value is immutable
165165
rule: self == oldSelf
166-
enableSLAAC:
167-
description: |-
168-
EnableSLAAC is an option to enable SLAAC (Stateless Address Autoconfiguration) for the instance.
169-
This is useful for IPv6 addresses, allowing the instance to automatically configure its own IPv6 address.
170-
Defaults to false.
171-
type: boolean
172-
x-kubernetes-validations:
173-
- message: Value is immutable
174-
rule: self == oldSelf
175166
firewallID:
176167
type: integer
177168
x-kubernetes-validations:
@@ -273,11 +264,40 @@ spec:
273264
x-kubernetes-validations:
274265
- message: Value is immutable
275266
rule: self == oldSelf
276-
isPublicIPv6:
267+
ipv6Options:
277268
description: |-
278-
IsPublicIPv6 is an option to enable public IPv6 for the instance.
279-
If set to true, the instance will have a publicly routable IPv6 range.
280-
type: boolean
269+
IPv6Options defines the IPv6 options for the instance.
270+
If not specified, IPv6 ranges won't be allocated to instance.
271+
properties:
272+
enableRanges:
273+
description: |-
274+
EnableRanges is an option to enable IPv6 ranges for the instance.
275+
If set to true, the instance will have a range of IPv6 addresses.
276+
This is useful for instances that require multiple IPv6 addresses.
277+
Defaults to false.
278+
type: boolean
279+
x-kubernetes-validations:
280+
- message: Value is immutable
281+
rule: self == oldSelf
282+
enableSLAAC:
283+
description: |-
284+
EnableSLAAC is an option to enable SLAAC (Stateless Address Autoconfiguration) for the instance.
285+
This is useful for IPv6 addresses, allowing the instance to automatically configure its own IPv6 address.
286+
Defaults to false.
287+
type: boolean
288+
x-kubernetes-validations:
289+
- message: Value is immutable
290+
rule: self == oldSelf
291+
isPublicIPv6:
292+
description: |-
293+
IsPublicIPv6 is an option to enable public IPv6 for the instance.
294+
If set to true, the instance will have a publicly routable IPv6 range.
295+
Defaults to false.
296+
type: boolean
297+
x-kubernetes-validations:
298+
- message: Value is immutable
299+
rule: self == oldSelf
300+
type: object
281301
x-kubernetes-validations:
282302
- message: Value is immutable
283303
rule: self == oldSelf

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

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,6 @@ spec:
153153
x-kubernetes-validations:
154154
- message: Value is immutable
155155
rule: self == oldSelf
156-
enableSLAAC:
157-
description: |-
158-
EnableSLAAC is an option to enable SLAAC (Stateless Address Autoconfiguration) for the instance.
159-
This is useful for IPv6 addresses, allowing the instance to automatically configure its own IPv6 address.
160-
Defaults to false.
161-
type: boolean
162-
x-kubernetes-validations:
163-
- message: Value is immutable
164-
rule: self == oldSelf
165156
firewallID:
166157
type: integer
167158
x-kubernetes-validations:
@@ -265,11 +256,40 @@ spec:
265256
x-kubernetes-validations:
266257
- message: Value is immutable
267258
rule: self == oldSelf
268-
isPublicIPv6:
259+
ipv6Options:
269260
description: |-
270-
IsPublicIPv6 is an option to enable public IPv6 for the instance.
271-
If set to true, the instance will have a publicly routable IPv6 range.
272-
type: boolean
261+
IPv6Options defines the IPv6 options for the instance.
262+
If not specified, IPv6 ranges won't be allocated to instance.
263+
properties:
264+
enableRanges:
265+
description: |-
266+
EnableRanges is an option to enable IPv6 ranges for the instance.
267+
If set to true, the instance will have a range of IPv6 addresses.
268+
This is useful for instances that require multiple IPv6 addresses.
269+
Defaults to false.
270+
type: boolean
271+
x-kubernetes-validations:
272+
- message: Value is immutable
273+
rule: self == oldSelf
274+
enableSLAAC:
275+
description: |-
276+
EnableSLAAC is an option to enable SLAAC (Stateless Address Autoconfiguration) for the instance.
277+
This is useful for IPv6 addresses, allowing the instance to automatically configure its own IPv6 address.
278+
Defaults to false.
279+
type: boolean
280+
x-kubernetes-validations:
281+
- message: Value is immutable
282+
rule: self == oldSelf
283+
isPublicIPv6:
284+
description: |-
285+
IsPublicIPv6 is an option to enable public IPv6 for the instance.
286+
If set to true, the instance will have a publicly routable IPv6 range.
287+
Defaults to false.
288+
type: boolean
289+
x-kubernetes-validations:
290+
- message: Value is immutable
291+
rule: self == oldSelf
292+
type: object
273293
x-kubernetes-validations:
274294
- message: Value is immutable
275295
rule: self == oldSelf

docs/src/reference/out.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,24 @@ _Appears in:_
239239
| `format` _object (keys:string, values:string)_ | How to format the data stored in the generated Secret.<br />It supports Go template syntax and interpolating the following values: .AccessKey, .SecretKey .BucketName .BucketEndpoint .S3Endpoint<br />If no format is supplied then a generic one is used containing the values specified. | | |
240240

241241

242+
#### IPv6CreateOptions
243+
244+
245+
246+
IPv6CreateOptions defines the IPv6 options for the instance.
247+
248+
249+
250+
_Appears in:_
251+
- [LinodeMachineSpec](#linodemachinespec)
252+
253+
| Field | Description | Default | Validation |
254+
| --- | --- | --- | --- |
255+
| `enableSLAAC` _boolean_ | EnableSLAAC is an option to enable SLAAC (Stateless Address Autoconfiguration) for the instance.<br />This is useful for IPv6 addresses, allowing the instance to automatically configure its own IPv6 address.<br />Defaults to false. | | |
256+
| `enableRanges` _boolean_ | EnableRanges is an option to enable IPv6 ranges for the instance.<br />If set to true, the instance will have a range of IPv6 addresses.<br />This is useful for instances that require multiple IPv6 addresses.<br />Defaults to false. | | |
257+
| `isPublicIPv6` _boolean_ | IsPublicIPv6 is an option to enable public IPv6 for the instance.<br />If set to true, the instance will have a publicly routable IPv6 range.<br />Defaults to false. | | |
258+
259+
242260
#### InstanceConfigInterfaceCreateOptions
243261

244262

@@ -621,8 +639,7 @@ _Appears in:_
621639
| `firewallRef` _[ObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#objectreference-v1-core)_ | FirewallRef is a reference to a firewall object. This makes the linode use the specified firewall. | | |
622640
| `vpcRef` _[ObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#objectreference-v1-core)_ | VPCRef is a reference to a LinodeVPC resource. If specified, this takes precedence over<br />the cluster-level VPC configuration for multi-region support. | | |
623641
| `vpcID` _integer_ | VPCID is the ID of an existing VPC in Linode. This allows using a VPC that is not managed by CAPL. | | |
624-
| `enableSLAAC` _boolean_ | EnableSLAAC is an option to enable SLAAC (Stateless Address Autoconfiguration) for the instance.<br />This is useful for IPv6 addresses, allowing the instance to automatically configure its own IPv6 address.<br />Defaults to false. | | |
625-
| `isPublicIPv6` _boolean_ | IsPublicIPv6 is an option to enable public IPv6 for the instance.<br />If set to true, the instance will have a publicly routable IPv6 range. | | |
642+
| `ipv6Options` _[IPv6CreateOptions](#ipv6createoptions)_ | IPv6Options defines the IPv6 options for the instance.<br />If not specified, IPv6 ranges won't be allocated to instance. | | |
626643
| `networkHelper` _boolean_ | NetworkHelper is an option usually enabled on account level. It helps configure networking automatically for instances.<br />You can use this to enable/disable the network helper for a specific instance.<br />For more information, see https://techdocs.akamai.com/cloud-computing/docs/automatically-configure-networking<br />Defaults to true. | | |
627644

628645

internal/controller/linodemachine_controller_helpers.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -582,29 +582,30 @@ func getVPCInterfaceConfigFromDirectID(ctx context.Context, machineScope *scope.
582582
}
583583

584584
// getMachineIPv6Config returns the IPv6 configuration if subnet has IPv6 ranges.
585-
// For now, we support only a single IPv6 range for machine per subnet.
586-
// If SLAAC is enabled, we create an IPv6 configuration with the SLAAC range.
587-
// If SLAAC is not enabled, we create an IPv6 configuration with the default range.
588-
// If no IPv6 ranges are available in the subnet, it returns nil.
585+
// It checks the LinodeMachine's IPv6Options for SLAAC and Ranges settings.
586+
// If `EnableSLAAC` is set, it will enable SLAAC with the default IPv6 CIDR range.
587+
// If `EnableRanges` is set, it will enable IPv6 ranges with the default IPv6 CIDR range.
589588
// If `IsPublicIPv6` is set, it will be used to determine if the IPv6 range should be publicly routable or not.
590589
func getMachineIPv6Config(machineScope *scope.MachineScope, numIPv6RangesInSubnet int) *linodego.InstanceConfigInterfaceCreateOptionsIPv6 {
591-
if numIPv6RangesInSubnet == 0 {
592-
return nil // No IPv6 ranges available in subnet, return nil
590+
// If there are no IPv6 ranges in the subnet or if IPv6 options are not specified, return nil.
591+
if numIPv6RangesInSubnet == 0 || machineScope.LinodeMachine.Spec.IPv6Options == nil {
592+
return nil
593593
}
594594

595595
intfOpts := &linodego.InstanceConfigInterfaceCreateOptionsIPv6{}
596-
if machineScope.LinodeMachine.Spec.IsPublicIPv6 != nil {
596+
if machineScope.LinodeMachine.Spec.IPv6Options.IsPublicIPv6 != nil {
597597
// Set the public IPv6 flag based on the IsPublicIPv6 specification.
598-
intfOpts.IsPublic = machineScope.LinodeMachine.Spec.IsPublicIPv6
598+
intfOpts.IsPublic = machineScope.LinodeMachine.Spec.IPv6Options.IsPublicIPv6
599599
}
600600

601-
if machineScope.LinodeMachine.Spec.EnableSLAAC != nil && *machineScope.LinodeMachine.Spec.EnableSLAAC {
601+
if machineScope.LinodeMachine.Spec.IPv6Options.EnableSLAAC != nil && *machineScope.LinodeMachine.Spec.IPv6Options.EnableSLAAC {
602602
intfOpts.SLAAC = []linodego.InstanceConfigInterfaceCreateOptionsIPv6SLAAC{
603603
{
604604
Range: defaultNodeIPv6CIDRRange,
605605
},
606606
}
607-
} else {
607+
}
608+
if machineScope.LinodeMachine.Spec.IPv6Options.EnableRanges != nil && *machineScope.LinodeMachine.Spec.IPv6Options.EnableRanges {
608609
intfOpts.Ranges = []linodego.InstanceConfigInterfaceCreateOptionsIPv6Range{
609610
{
610611
Range: ptr.To(defaultNodeIPv6CIDRRange),

internal/controller/linodemachine_controller_helpers_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,8 +1208,10 @@ func TestGetVPCInterfaceConfig(t *testing.T) {
12081208
Namespace: "default",
12091209
},
12101210
Spec: infrav1alpha2.LinodeMachineSpec{
1211-
EnableSLAAC: ptr.To(true),
1212-
IsPublicIPv6: ptr.To(true),
1211+
IPv6Options: &infrav1alpha2.IPv6CreateOptions{
1212+
EnableSLAAC: ptr.To(true),
1213+
IsPublicIPv6: ptr.To(true),
1214+
},
12131215
},
12141216
},
12151217
LinodeCluster: &infrav1alpha2.LinodeCluster{

0 commit comments

Comments
 (0)