Skip to content

Commit 8188bba

Browse files
authored
feat: allow for specifying subnet type for az (#4464)
* feat: allow for specifying subnet type for az Signed-off-by: David van der Spek <[email protected]> * fix: conversion from v1beta1 to v1beta2 Signed-off-by: David van der Spek <[email protected]> * add option for all subnets in az Signed-off-by: David van der Spek <[email protected]> --------- Signed-off-by: David van der Spek <[email protected]>
1 parent 76e369a commit 8188bba

14 files changed

+842
-18
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,14 @@ spec:
533533
description: AdditionalTags is an optional set of tags to add to an
534534
instance, in addition to the ones added by default by the AWS provider.
535535
type: object
536+
availabilityZoneSubnetType:
537+
description: AvailabilityZoneSubnetType specifies which type of subnets
538+
to use when an availability zone is specified.
539+
enum:
540+
- public
541+
- private
542+
- all
543+
type: string
536544
availabilityZones:
537545
description: AvailabilityZones is an array of availability zones instances
538546
can run in

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,14 @@ spec:
519519
version will be used
520520
minLength: 2
521521
type: string
522+
availabilityZoneSubnetType:
523+
description: AvailabilityZoneSubnetType specifies which type of subnets
524+
to use when an availability zone is specified.
525+
enum:
526+
- public
527+
- private
528+
- all
529+
type: string
522530
availabilityZones:
523531
description: AvailabilityZones is an array of availability zones instances
524532
can run in

exp/api/v1beta1/conversion.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ func (src *AWSMachinePool) ConvertTo(dstRaw conversion.Hub) error {
4747
if restored.Spec.AWSLaunchTemplate.InstanceMetadataOptions != nil {
4848
dst.Spec.AWSLaunchTemplate.InstanceMetadataOptions = restored.Spec.AWSLaunchTemplate.InstanceMetadataOptions
4949
}
50+
if restored.Spec.AvailabilityZoneSubnetType != nil {
51+
dst.Spec.AvailabilityZoneSubnetType = restored.Spec.AvailabilityZoneSubnetType
52+
}
5053

5154
return nil
5255
}
@@ -93,6 +96,9 @@ func (src *AWSManagedMachinePool) ConvertTo(dstRaw conversion.Hub) error {
9396
}
9497
dst.Spec.AWSLaunchTemplate.InstanceMetadataOptions = restored.Spec.AWSLaunchTemplate.InstanceMetadataOptions
9598
}
99+
if restored.Spec.AvailabilityZoneSubnetType != nil {
100+
dst.Spec.AvailabilityZoneSubnetType = restored.Spec.AvailabilityZoneSubnetType
101+
}
96102

97103
return nil
98104
}

exp/api/v1beta1/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

exp/api/v1beta2/awsmachinepool_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ type AWSMachinePoolSpec struct {
5252
// AvailabilityZones is an array of availability zones instances can run in
5353
AvailabilityZones []string `json:"availabilityZones,omitempty"`
5454

55+
// AvailabilityZoneSubnetType specifies which type of subnets to use when an availability zone is specified.
56+
// +kubebuilder:validation:Enum:=public;private;all
57+
// +optional
58+
AvailabilityZoneSubnetType *AZSubnetType `json:"availabilityZoneSubnetType,omitempty"`
59+
5560
// Subnets is an array of subnet configurations
5661
// +optional
5762
Subnets []infrav1.AWSResourceReference `json:"subnets,omitempty"`

exp/api/v1beta2/awsmanagedmachinepool_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ type AWSManagedMachinePoolSpec struct {
6868
// AvailabilityZones is an array of availability zones instances can run in
6969
AvailabilityZones []string `json:"availabilityZones,omitempty"`
7070

71+
// AvailabilityZoneSubnetType specifies which type of subnets to use when an availability zone is specified.
72+
// +kubebuilder:validation:Enum:=public;private;all
73+
// +optional
74+
AvailabilityZoneSubnetType *AZSubnetType `json:"availabilityZoneSubnetType,omitempty"`
75+
7176
// SubnetIDs specifies which subnets are used for the
7277
// auto scaling group of this nodegroup
7378
// +optional

exp/api/v1beta2/awsmanagedmachinepool_webhook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ func (r *AWSManagedMachinePool) validateImmutable(old *AWSManagedMachinePool) fi
243243
appendErrorIfMutated(old.Spec.AMIType, r.Spec.AMIType, "amiType")
244244
appendErrorIfMutated(old.Spec.RemoteAccess, r.Spec.RemoteAccess, "remoteAccess")
245245
appendErrorIfSetAndMutated(old.Spec.CapacityType, r.Spec.CapacityType, "capacityType")
246+
appendErrorIfMutated(old.Spec.AvailabilityZones, r.Spec.AvailabilityZones, "availabilityZones")
247+
appendErrorIfMutated(old.Spec.AvailabilityZoneSubnetType, r.Spec.AvailabilityZoneSubnetType, "availabilityZoneSubnetType")
246248
if (old.Spec.AWSLaunchTemplate != nil && r.Spec.AWSLaunchTemplate == nil) ||
247249
(old.Spec.AWSLaunchTemplate == nil && r.Spec.AWSLaunchTemplate != nil) {
248250
allErrs = append(

0 commit comments

Comments
 (0)