Skip to content

Commit d83700f

Browse files
[feat] Add support for new network interfaces (#821)
* add support for new network interfaces on LinodeMachines * add some fixes and validation for linode creation with new network interfaces * We cannot configure network helper at all if using the new linode interfaces * allow skipping of setting interfaces and linodeInterfaces via InterfaceGeneration on LinodeMachines, only update instanceConfig if configuring kernel or network helpers * add webhook test * fix setting of interfaceGeneration * update with latest commit on proj/vpc-dual-stack linodego branch * update firewall listing for new linode interfaces * flip the conditional check just in case InstanceGeneration doesn't get set for existing LinodeMachines * add some comments and handle network helper
1 parent f0d2e1b commit d83700f

17 files changed

+3298
-161
lines changed

api/v1alpha2/linodemachine_types.go

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@ type LinodeMachineSpec struct {
5959
BackupID int `json:"backupID,omitempty"`
6060
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
6161
Image string `json:"image,omitempty"`
62+
// Interfaces is a list of legacy network interfaces to use for the instance.
6263
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
6364
Interfaces []InstanceConfigInterfaceCreateOptions `json:"interfaces,omitempty"`
65+
// LinodeInterfaces is a list of Linode network interfaces to use for the instance. Requires Linode Interfaces beta opt-in to use.
66+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
67+
// +kubebuilder:object:generate=true
68+
LinodeInterfaces []LinodeInterfaceCreateOptions `json:"linodeInterfaces,omitempty"`
6469
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
6570
BackupsEnabled bool `json:"backupsEnabled,omitempty"`
6671
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
@@ -125,6 +130,13 @@ type LinodeMachineSpec struct {
125130
// For more information, see https://techdocs.akamai.com/cloud-computing/docs/automatically-configure-networking
126131
// Defaults to true.
127132
NetworkHelper *bool `json:"networkHelper,omitempty"`
133+
134+
// InterfaceGeneration is the generation of the interface to use for the cluster's
135+
// nodes in interface / linodeInterface are not specified for a LinodeMachine.
136+
// If not set, defaults to "legacy_config".
137+
// +kubebuilder:validation:Enum=legacy_config;linode
138+
// +kubebuilder:default=legacy_config
139+
InterfaceGeneration linodego.InterfaceGeneration `json:"interfaceGeneration,omitempty"`
128140
}
129141

130142
// IPv6CreateOptions defines the IPv6 options for the instance.
@@ -194,6 +206,96 @@ type InstanceConfigInterfaceCreateOptions struct {
194206
IPRanges []string `json:"ipRanges,omitempty"`
195207
}
196208

209+
// LinodeInterfaceCreateOptions defines the linode network interface config
210+
type LinodeInterfaceCreateOptions struct {
211+
FirewallID *int `json:"firewall_id,omitempty"`
212+
DefaultRoute *InterfaceDefaultRoute `json:"default_route,omitempty"`
213+
Public *PublicInterfaceCreateOptions `json:"public,omitempty"`
214+
VPC *VPCInterfaceCreateOptions `json:"vpc,omitempty"`
215+
VLAN *VLANInterface `json:"vlan,omitempty"`
216+
}
217+
218+
// InterfaceDefaultRoute defines the default IPv4 and IPv6 routes for an interface
219+
type InterfaceDefaultRoute struct {
220+
IPv4 *bool `json:"ipv4,omitempty"`
221+
IPv6 *bool `json:"ipv6,omitempty"`
222+
}
223+
224+
// PublicInterfaceCreateOptions defines the IPv4 and IPv6 public interface create options
225+
type PublicInterfaceCreateOptions struct {
226+
IPv4 *PublicInterfaceIPv4CreateOptions `json:"ipv4,omitempty"`
227+
IPv6 *PublicInterfaceIPv6CreateOptions `json:"ipv6,omitempty"`
228+
}
229+
230+
// PublicInterfaceIPv4CreateOptions defines the PublicInterfaceIPv4AddressCreateOptions for addresses
231+
type PublicInterfaceIPv4CreateOptions struct {
232+
Addresses []PublicInterfaceIPv4AddressCreateOptions `json:"addresses,omitempty"`
233+
}
234+
235+
// PublicInterfaceIPv4AddressCreateOptions defines the public IPv4 address and whether it is primary
236+
type PublicInterfaceIPv4AddressCreateOptions struct {
237+
Address string `json:"address"`
238+
Primary *bool `json:"primary,omitempty"`
239+
}
240+
241+
// PublicInterfaceIPv6CreateOptions defines the PublicInterfaceIPv6RangeCreateOptions
242+
type PublicInterfaceIPv6CreateOptions struct {
243+
Ranges []PublicInterfaceIPv6RangeCreateOptions `json:"ranges,omitempty"`
244+
}
245+
246+
// PublicInterfaceIPv6RangeCreateOptions defines the IPv6 range for a public interface
247+
type PublicInterfaceIPv6RangeCreateOptions struct {
248+
Range string `json:"range"`
249+
}
250+
251+
// VPCInterfaceCreateOptions defines the VPC interface configuration for an instance
252+
type VPCInterfaceCreateOptions struct {
253+
SubnetID int `json:"subnet_id"`
254+
IPv4 *VPCInterfaceIPv4CreateOptions `json:"ipv4,omitempty"`
255+
IPv6 *VPCInterfaceIPv6CreateOptions `json:"ipv6,omitempty"`
256+
}
257+
258+
// VPCInterfaceIPv6CreateOptions defines the IPv6 configuration for a VPC interface
259+
type VPCInterfaceIPv6CreateOptions struct {
260+
SLAAC []VPCInterfaceIPv6SLAACCreateOptions `json:"slaac,omitempty"`
261+
Ranges []VPCInterfaceIPv6RangeCreateOptions `json:"ranges,omitempty"`
262+
IsPublic bool `json:"is_public"`
263+
}
264+
265+
// VPCInterfaceIPv6SLAACCreateOptions defines the Range for IPv6 SLAAC
266+
type VPCInterfaceIPv6SLAACCreateOptions struct {
267+
Range string `json:"range"`
268+
}
269+
270+
// VPCInterfaceIPv6RangeCreateOptions defines the IPv6 range for a VPC interface
271+
type VPCInterfaceIPv6RangeCreateOptions struct {
272+
Range string `json:"range"`
273+
}
274+
275+
// VPCInterfaceIPv4CreateOptions defines the IPv4 address and range configuration for a VPC interface
276+
type VPCInterfaceIPv4CreateOptions struct {
277+
Addresses []VPCInterfaceIPv4AddressCreateOptions `json:"addresses,omitempty"`
278+
Ranges []VPCInterfaceIPv4RangeCreateOptions `json:"ranges,omitempty"`
279+
}
280+
281+
// VPCInterfaceIPv4AddressCreateOptions defines the IPv4 configuration for a VPC interface
282+
type VPCInterfaceIPv4AddressCreateOptions struct {
283+
Address string `json:"address"`
284+
Primary *bool `json:"primary,omitempty"`
285+
NAT1To1Address *string `json:"nat_1_1_address,omitempty"`
286+
}
287+
288+
// VPCInterfaceIPv4RangeCreateOptions defines the IPv4 range for a VPC interface
289+
type VPCInterfaceIPv4RangeCreateOptions struct {
290+
Range string `json:"range"`
291+
}
292+
293+
// VLANInterface defines the VLAN interface configuration for an instance
294+
type VLANInterface struct {
295+
VLANLabel string `json:"vlan_label"`
296+
IPAMAddress *string `json:"ipam_address,omitempty"`
297+
}
298+
197299
// VPCIPv4 defines VPC IPV4 settings
198300
type VPCIPv4 struct {
199301
VPC string `json:"vpc,omitempty"`

0 commit comments

Comments
 (0)