Skip to content

Commit

Permalink
feat: allow for specifying subnet type for az (#4464)
Browse files Browse the repository at this point in the history
* feat: allow for specifying subnet type for az

Signed-off-by: David van der Spek <vanderspek.david@gmail.com>

* fix: conversion from v1beta1 to v1beta2

Signed-off-by: David van der Spek <vanderspek.david@gmail.com>

* add option for all subnets in az

Signed-off-by: David van der Spek <vanderspek.david@gmail.com>

---------

Signed-off-by: David van der Spek <vanderspek.david@gmail.com>
  • Loading branch information
davidspek authored Sep 26, 2023
1 parent 76e369a commit 8188bba
Show file tree
Hide file tree
Showing 14 changed files with 842 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,14 @@ spec:
description: AdditionalTags is an optional set of tags to add to an
instance, in addition to the ones added by default by the AWS provider.
type: object
availabilityZoneSubnetType:
description: AvailabilityZoneSubnetType specifies which type of subnets
to use when an availability zone is specified.
enum:
- public
- private
- all
type: string
availabilityZones:
description: AvailabilityZones is an array of availability zones instances
can run in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,14 @@ spec:
version will be used
minLength: 2
type: string
availabilityZoneSubnetType:
description: AvailabilityZoneSubnetType specifies which type of subnets
to use when an availability zone is specified.
enum:
- public
- private
- all
type: string
availabilityZones:
description: AvailabilityZones is an array of availability zones instances
can run in
Expand Down
6 changes: 6 additions & 0 deletions exp/api/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func (src *AWSMachinePool) ConvertTo(dstRaw conversion.Hub) error {
if restored.Spec.AWSLaunchTemplate.InstanceMetadataOptions != nil {
dst.Spec.AWSLaunchTemplate.InstanceMetadataOptions = restored.Spec.AWSLaunchTemplate.InstanceMetadataOptions
}
if restored.Spec.AvailabilityZoneSubnetType != nil {
dst.Spec.AvailabilityZoneSubnetType = restored.Spec.AvailabilityZoneSubnetType
}

return nil
}
Expand Down Expand Up @@ -93,6 +96,9 @@ func (src *AWSManagedMachinePool) ConvertTo(dstRaw conversion.Hub) error {
}
dst.Spec.AWSLaunchTemplate.InstanceMetadataOptions = restored.Spec.AWSLaunchTemplate.InstanceMetadataOptions
}
if restored.Spec.AvailabilityZoneSubnetType != nil {
dst.Spec.AvailabilityZoneSubnetType = restored.Spec.AvailabilityZoneSubnetType
}

return nil
}
Expand Down
2 changes: 2 additions & 0 deletions exp/api/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions exp/api/v1beta2/awsmachinepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ type AWSMachinePoolSpec struct {
// AvailabilityZones is an array of availability zones instances can run in
AvailabilityZones []string `json:"availabilityZones,omitempty"`

// AvailabilityZoneSubnetType specifies which type of subnets to use when an availability zone is specified.
// +kubebuilder:validation:Enum:=public;private;all
// +optional
AvailabilityZoneSubnetType *AZSubnetType `json:"availabilityZoneSubnetType,omitempty"`

// Subnets is an array of subnet configurations
// +optional
Subnets []infrav1.AWSResourceReference `json:"subnets,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions exp/api/v1beta2/awsmanagedmachinepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ type AWSManagedMachinePoolSpec struct {
// AvailabilityZones is an array of availability zones instances can run in
AvailabilityZones []string `json:"availabilityZones,omitempty"`

// AvailabilityZoneSubnetType specifies which type of subnets to use when an availability zone is specified.
// +kubebuilder:validation:Enum:=public;private;all
// +optional
AvailabilityZoneSubnetType *AZSubnetType `json:"availabilityZoneSubnetType,omitempty"`

// SubnetIDs specifies which subnets are used for the
// auto scaling group of this nodegroup
// +optional
Expand Down
2 changes: 2 additions & 0 deletions exp/api/v1beta2/awsmanagedmachinepool_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ func (r *AWSManagedMachinePool) validateImmutable(old *AWSManagedMachinePool) fi
appendErrorIfMutated(old.Spec.AMIType, r.Spec.AMIType, "amiType")
appendErrorIfMutated(old.Spec.RemoteAccess, r.Spec.RemoteAccess, "remoteAccess")
appendErrorIfSetAndMutated(old.Spec.CapacityType, r.Spec.CapacityType, "capacityType")
appendErrorIfMutated(old.Spec.AvailabilityZones, r.Spec.AvailabilityZones, "availabilityZones")
appendErrorIfMutated(old.Spec.AvailabilityZoneSubnetType, r.Spec.AvailabilityZoneSubnetType, "availabilityZoneSubnetType")
if (old.Spec.AWSLaunchTemplate != nil && r.Spec.AWSLaunchTemplate == nil) ||
(old.Spec.AWSLaunchTemplate == nil && r.Spec.AWSLaunchTemplate != nil) {
allErrs = append(
Expand Down
Loading

0 comments on commit 8188bba

Please sign in to comment.