From 2eed587785ad9f6b183b41d7742fb1ef419ca853 Mon Sep 17 00:00:00 2001 From: Max Fedotov Date: Tue, 28 Nov 2023 01:08:06 +0200 Subject: [PATCH 1/3] support setting dnsNameOptions --- api/v1beta1/zz_generated.conversion.go | 3 + api/v1beta2/awsmachine_types.go | 4 ++ api/v1beta2/awsmachine_webhook.go | 11 ++++ api/v1beta2/awsmachine_webhook_test.go | 6 +- api/v1beta2/network_types.go | 7 ++ api/v1beta2/types.go | 18 +++++ api/v1beta2/zz_generated.deepcopy.go | 45 +++++++++++++ ...ster.x-k8s.io_awsmanagedcontrolplanes.yaml | 66 +++++++++++++++++++ ...tructure.cluster.x-k8s.io_awsclusters.yaml | 33 ++++++++++ ....cluster.x-k8s.io_awsclustertemplates.yaml | 12 ++++ ...ture.cluster.x-k8s.io_awsmachinepools.yaml | 21 ++++++ ...tructure.cluster.x-k8s.io_awsmachines.yaml | 20 ++++++ ....cluster.x-k8s.io_awsmachinetemplates.yaml | 21 ++++++ ...uster.x-k8s.io_awsmanagedmachinepools.yaml | 21 ++++++ .../v1beta2/awsmanagedcontrolplane_webhook.go | 22 +++++-- exp/api/v1beta1/zz_generated.conversion.go | 1 + exp/api/v1beta2/types.go | 4 ++ exp/api/v1beta2/zz_generated.deepcopy.go | 5 ++ pkg/cloud/services/ec2/instances.go | 23 +++++++ pkg/cloud/services/ec2/launchtemplate.go | 21 ++++++ pkg/cloud/services/network/subnets.go | 16 +++++ 21 files changed, 375 insertions(+), 5 deletions(-) diff --git a/api/v1beta1/zz_generated.conversion.go b/api/v1beta1/zz_generated.conversion.go index 347e67fd35..88ab37dd5b 100644 --- a/api/v1beta1/zz_generated.conversion.go +++ b/api/v1beta1/zz_generated.conversion.go @@ -1411,6 +1411,7 @@ func autoConvert_v1beta2_AWSMachineSpec_To_v1beta1_AWSMachineSpec(in *v1beta2.AW out.SpotMarketOptions = (*SpotMarketOptions)(unsafe.Pointer(in.SpotMarketOptions)) // WARNING: in.PlacementGroupName requires manual conversion: does not exist in peer-type out.Tenancy = in.Tenancy + // WARNING: in.PrivateDnsNameOptions requires manual conversion: does not exist in peer-type return nil } @@ -2010,6 +2011,7 @@ func autoConvert_v1beta2_Instance_To_v1beta1_Instance(in *v1beta2.Instance, out out.Tenancy = in.Tenancy out.VolumeIDs = *(*[]string)(unsafe.Pointer(&in.VolumeIDs)) // WARNING: in.InstanceMetadataOptions requires manual conversion: does not exist in peer-type + // WARNING: in.PrivateDnsNameOptions requires manual conversion: does not exist in peer-type return nil } @@ -2284,6 +2286,7 @@ func autoConvert_v1beta2_VPCSpec_To_v1beta1_VPCSpec(in *v1beta2.VPCSpec, out *VP out.Tags = *(*Tags)(unsafe.Pointer(&in.Tags)) out.AvailabilityZoneUsageLimit = (*int)(unsafe.Pointer(in.AvailabilityZoneUsageLimit)) out.AvailabilityZoneSelection = (*AZSelectionScheme)(unsafe.Pointer(in.AvailabilityZoneSelection)) + // WARNING: in.PrivateDnsHostnameTypeOnLaunch requires manual conversion: does not exist in peer-type // WARNING: in.EmptyRoutesDefaultVPCSecurityGroup requires manual conversion: does not exist in peer-type return nil } diff --git a/api/v1beta2/awsmachine_types.go b/api/v1beta2/awsmachine_types.go index 83fed36893..1a8e72626e 100644 --- a/api/v1beta2/awsmachine_types.go +++ b/api/v1beta2/awsmachine_types.go @@ -160,6 +160,10 @@ type AWSMachineSpec struct { // +optional // +kubebuilder:validation:Enum:=default;dedicated;host Tenancy string `json:"tenancy,omitempty"` + + // PrivateDnsNameOptions is the options for the instance hostname. + // +optional + PrivateDnsNameOptions *PrivateDnsNameOptions `json:"privateDnsNameOptions,omitempty"` } // CloudInit defines options related to the bootstrapping systems where diff --git a/api/v1beta2/awsmachine_webhook.go b/api/v1beta2/awsmachine_webhook.go index cbf728fda4..2c749dd475 100644 --- a/api/v1beta2/awsmachine_webhook.go +++ b/api/v1beta2/awsmachine_webhook.go @@ -114,6 +114,17 @@ func (r *AWSMachine) ValidateUpdate(old runtime.Object) (admission.Warnings, err delete(cloudInit, "secureSecretsBackend") } + // allow changes to enableResourceNameDnsAAAARecord and enableResourceNameDnsARecord + if privateDnsNameOptions, ok := oldAWSMachineSpec["privateDnsNameOptions"].(map[string]interface{}); ok { + delete(privateDnsNameOptions, "enableResourceNameDnsAAAARecord") + delete(privateDnsNameOptions, "enableResourceNameDnsARecord") + } + + if privateDnsNameOptions, ok := newAWSMachineSpec["privateDnsNameOptions"].(map[string]interface{}); ok { + delete(privateDnsNameOptions, "enableResourceNameDnsAAAARecord") + delete(privateDnsNameOptions, "enableResourceNameDnsARecord") + } + if !cmp.Equal(oldAWSMachineSpec, newAWSMachineSpec) { allErrs = append(allErrs, field.Forbidden(field.NewPath("spec"), "cannot be modified")) } diff --git a/api/v1beta2/awsmachine_webhook_test.go b/api/v1beta2/awsmachine_webhook_test.go index 7536a1b767..280f7bdda2 100644 --- a/api/v1beta2/awsmachine_webhook_test.go +++ b/api/v1beta2/awsmachine_webhook_test.go @@ -273,7 +273,7 @@ func TestAWSMachineUpdate(t *testing.T) { wantErr bool }{ { - name: "change in providerid, cloudinit, tags and securitygroups", + name: "change in providerid, cloudinit, tags, securitygroups and privateDnsNameOptions", oldMachine: &AWSMachine{ Spec: AWSMachineSpec{ ProviderID: nil, @@ -298,6 +298,10 @@ func TestAWSMachineUpdate(t *testing.T) { SecretPrefix: "test", SecretCount: 5, }, + PrivateDnsNameOptions: &PrivateDnsNameOptions{ + EnableResourceNameDnsAAAARecord: aws.Bool(true), + EnableResourceNameDnsARecord: aws.Bool(true), + }, }, }, wantErr: false, diff --git a/api/v1beta2/network_types.go b/api/v1beta2/network_types.go index 8b4ba3ac4e..a606986dad 100644 --- a/api/v1beta2/network_types.go +++ b/api/v1beta2/network_types.go @@ -335,6 +335,13 @@ type VPCSpec struct { // // +optional EmptyRoutesDefaultVPCSecurityGroup bool `json:"emptyRoutesDefaultVPCSecurityGroup,omitempty"` + + // PrivateDnsHostnameTypeOnLaunch is the type of hostname to assign to instances in the subnet at launch. + // For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an instance DNS name can be based on the instance IPv4 address (ip-name) + // or the instance ID (resource-name). For IPv6 only subnets, an instance DNS name must be based on the instance ID (resource-name). + // +optional + // +kubebuilder:validation:Enum:=ip-name;resource-name + PrivateDnsHostnameTypeOnLaunch *string `json:"privateDnsHostnameTypeOnLaunch,omitempty"` } // String returns a string representation of the VPC. diff --git a/api/v1beta2/types.go b/api/v1beta2/types.go index 9e77923bbd..785f44a293 100644 --- a/api/v1beta2/types.go +++ b/api/v1beta2/types.go @@ -232,6 +232,10 @@ type Instance struct { // InstanceMetadataOptions is the metadata options for the EC2 instance. // +optional InstanceMetadataOptions *InstanceMetadataOptions `json:"instanceMetadataOptions,omitempty"` + + // PrivateDnsNameOptions is the options for the instance hostname. + // +optional + PrivateDnsNameOptions *PrivateDnsNameOptions `json:"privateDnsNameOptions,omitempty"` } // InstanceMetadataState describes the state of InstanceMetadataOptions.HttpEndpoint and InstanceMetadataOptions.InstanceMetadataTags @@ -407,3 +411,17 @@ const ( // AmazonLinuxGPU is the AmazonLinux GPU AMI type. AmazonLinuxGPU EKSAMILookupType = "AmazonLinuxGPU" ) + +// PrivateDnsNameOptions is the options for the instance hostname. +type PrivateDnsNameOptions struct { + // EnableResourceNameDnsAAAARecord indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. + // +optional + EnableResourceNameDnsAAAARecord *bool `json:"enableResourceNameDnsAAAARecord,omitempty"` + // EnableResourceNameDnsARecord indicates whether to respond to DNS queries for instance hostnames with DNS A records. + // +optional + EnableResourceNameDnsARecord *bool `json:"enableResourceNameDnsARecord,omitempty"` + // The type of hostname to assign to an instance. + // +optional + // +kubebuilder:validation:Enum:=ip-name;resource-name + HostnameType *string `json:"hostnameType,omitempty"` +} diff --git a/api/v1beta2/zz_generated.deepcopy.go b/api/v1beta2/zz_generated.deepcopy.go index 40e92eb73a..f50ab4edda 100644 --- a/api/v1beta2/zz_generated.deepcopy.go +++ b/api/v1beta2/zz_generated.deepcopy.go @@ -739,6 +739,11 @@ func (in *AWSMachineSpec) DeepCopyInto(out *AWSMachineSpec) { *out = new(SpotMarketOptions) (*in).DeepCopyInto(*out) } + if in.PrivateDnsNameOptions != nil { + in, out := &in.PrivateDnsNameOptions, &out.PrivateDnsNameOptions + *out = new(PrivateDnsNameOptions) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSMachineSpec. @@ -1466,6 +1471,11 @@ func (in *Instance) DeepCopyInto(out *Instance) { *out = new(InstanceMetadataOptions) **out = **in } + if in.PrivateDnsNameOptions != nil { + in, out := &in.PrivateDnsNameOptions, &out.PrivateDnsNameOptions + *out = new(PrivateDnsNameOptions) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Instance. @@ -1649,6 +1659,36 @@ func (in *NetworkStatus) DeepCopy() *NetworkStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PrivateDnsNameOptions) DeepCopyInto(out *PrivateDnsNameOptions) { + *out = *in + if in.EnableResourceNameDnsAAAARecord != nil { + in, out := &in.EnableResourceNameDnsAAAARecord, &out.EnableResourceNameDnsAAAARecord + *out = new(bool) + **out = **in + } + if in.EnableResourceNameDnsARecord != nil { + in, out := &in.EnableResourceNameDnsARecord, &out.EnableResourceNameDnsARecord + *out = new(bool) + **out = **in + } + if in.HostnameType != nil { + in, out := &in.HostnameType, &out.HostnameType + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PrivateDnsNameOptions. +func (in *PrivateDnsNameOptions) DeepCopy() *PrivateDnsNameOptions { + if in == nil { + return nil + } + out := new(PrivateDnsNameOptions) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RouteTable) DeepCopyInto(out *RouteTable) { *out = *in @@ -1912,6 +1952,11 @@ func (in *VPCSpec) DeepCopyInto(out *VPCSpec) { *out = new(AZSelectionScheme) **out = **in } + if in.PrivateDnsHostnameTypeOnLaunch != nil { + in, out := &in.PrivateDnsHostnameTypeOnLaunch, &out.PrivateDnsHostnameTypeOnLaunch + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VPCSpec. diff --git a/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml b/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml index 6fde25fdea..c8ef0511b2 100644 --- a/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml +++ b/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml @@ -647,6 +647,18 @@ spec: is set. Mutually exclusive with IPAMPool. type: string type: object + privateDnsHostnameTypeOnLaunch: + description: PrivateDnsHostnameTypeOnLaunch is the type of + hostname to assign to instances in the subnet at launch. + For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an + instance DNS name can be based on the instance IPv4 address + (ip-name) or the instance ID (resource-name). For IPv6 only + subnets, an instance DNS name must be based on the instance + ID (resource-name). + enum: + - ip-name + - resource-name + type: string tags: additionalProperties: type: string @@ -1096,6 +1108,27 @@ spec: description: PlacementGroupName specifies the name of the placement group in which to launch the instance. type: string + privateDnsNameOptions: + description: PrivateDnsNameOptions is the options for the instance + hostname. + properties: + enableResourceNameDnsAAAARecord: + description: EnableResourceNameDnsAAAARecord indicates whether + to respond to DNS queries for instance hostnames with DNS + AAAA records. + type: boolean + enableResourceNameDnsARecord: + description: EnableResourceNameDnsARecord indicates whether + to respond to DNS queries for instance hostnames with DNS + A records. + type: boolean + hostnameType: + description: The type of hostname to assign to an instance. + enum: + - ip-name + - resource-name + type: string + type: object privateIp: description: The private IPv4 address assigned to the instance. type: string @@ -2244,6 +2277,18 @@ spec: is set. Mutually exclusive with IPAMPool. type: string type: object + privateDnsHostnameTypeOnLaunch: + description: PrivateDnsHostnameTypeOnLaunch is the type of + hostname to assign to instances in the subnet at launch. + For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an + instance DNS name can be based on the instance IPv4 address + (ip-name) or the instance ID (resource-name). For IPv6 only + subnets, an instance DNS name must be based on the instance + ID (resource-name). + enum: + - ip-name + - resource-name + type: string tags: additionalProperties: type: string @@ -2706,6 +2751,27 @@ spec: description: PlacementGroupName specifies the name of the placement group in which to launch the instance. type: string + privateDnsNameOptions: + description: PrivateDnsNameOptions is the options for the instance + hostname. + properties: + enableResourceNameDnsAAAARecord: + description: EnableResourceNameDnsAAAARecord indicates whether + to respond to DNS queries for instance hostnames with DNS + AAAA records. + type: boolean + enableResourceNameDnsARecord: + description: EnableResourceNameDnsARecord indicates whether + to respond to DNS queries for instance hostnames with DNS + A records. + type: boolean + hostnameType: + description: The type of hostname to assign to an instance. + enum: + - ip-name + - resource-name + type: string + type: object privateIp: description: The private IPv4 address assigned to the instance. type: string diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml index e8ff7c2191..69cfd73388 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml @@ -1479,6 +1479,18 @@ spec: is set. Mutually exclusive with IPAMPool. type: string type: object + privateDnsHostnameTypeOnLaunch: + description: PrivateDnsHostnameTypeOnLaunch is the type of + hostname to assign to instances in the subnet at launch. + For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an + instance DNS name can be based on the instance IPv4 address + (ip-name) or the instance ID (resource-name). For IPv6 only + subnets, an instance DNS name must be based on the instance + ID (resource-name). + enum: + - ip-name + - resource-name + type: string tags: additionalProperties: type: string @@ -1687,6 +1699,27 @@ spec: description: PlacementGroupName specifies the name of the placement group in which to launch the instance. type: string + privateDnsNameOptions: + description: PrivateDnsNameOptions is the options for the instance + hostname. + properties: + enableResourceNameDnsAAAARecord: + description: EnableResourceNameDnsAAAARecord indicates whether + to respond to DNS queries for instance hostnames with DNS + AAAA records. + type: boolean + enableResourceNameDnsARecord: + description: EnableResourceNameDnsARecord indicates whether + to respond to DNS queries for instance hostnames with DNS + A records. + type: boolean + hostnameType: + description: The type of hostname to assign to an instance. + enum: + - ip-name + - resource-name + type: string + type: object privateIp: description: The private IPv4 address assigned to the instance. type: string diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclustertemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclustertemplates.yaml index 36d6677db4..2b07463f88 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclustertemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclustertemplates.yaml @@ -1098,6 +1098,18 @@ spec: with IPAMPool. type: string type: object + privateDnsHostnameTypeOnLaunch: + description: PrivateDnsHostnameTypeOnLaunch is the + type of hostname to assign to instances in the subnet + at launch. For IPv4-only and dual-stack (IPv4 and + IPv6) subnets, an instance DNS name can be based + on the instance IPv4 address (ip-name) or the instance + ID (resource-name). For IPv6 only subnets, an instance + DNS name must be based on the instance ID (resource-name). + enum: + - ip-name + - resource-name + type: string tags: additionalProperties: type: string diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml index aea799d05d..f1461835ff 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml @@ -690,6 +690,27 @@ spec: name: description: The name of the launch template. type: string + privateDnsNameOptions: + description: PrivateDnsNameOptions is the options for the instance + hostname. + properties: + enableResourceNameDnsAAAARecord: + description: EnableResourceNameDnsAAAARecord indicates whether + to respond to DNS queries for instance hostnames with DNS + AAAA records. + type: boolean + enableResourceNameDnsARecord: + description: EnableResourceNameDnsARecord indicates whether + to respond to DNS queries for instance hostnames with DNS + A records. + type: boolean + hostnameType: + description: The type of hostname to assign to an instance. + enum: + - ip-name + - resource-name + type: string + type: object rootVolume: description: RootVolume encapsulates the configuration options for the root volume diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml index a59168e3cb..db25f22155 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml @@ -780,6 +780,26 @@ spec: description: PlacementGroupName specifies the name of the placement group in which to launch the instance. type: string + privateDnsNameOptions: + description: PrivateDnsNameOptions is the options for the instance + hostname. + properties: + enableResourceNameDnsAAAARecord: + description: EnableResourceNameDnsAAAARecord indicates whether + to respond to DNS queries for instance hostnames with DNS AAAA + records. + type: boolean + enableResourceNameDnsARecord: + description: EnableResourceNameDnsARecord indicates whether to + respond to DNS queries for instance hostnames with DNS A records. + type: boolean + hostnameType: + description: The type of hostname to assign to an instance. + enum: + - ip-name + - resource-name + type: string + type: object providerID: description: ProviderID is the unique identifier as specified by the cloud provider. diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml index ee9cbb12ea..0f3891dfb5 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml @@ -734,6 +734,27 @@ spec: description: PlacementGroupName specifies the name of the placement group in which to launch the instance. type: string + privateDnsNameOptions: + description: PrivateDnsNameOptions is the options for the + instance hostname. + properties: + enableResourceNameDnsAAAARecord: + description: EnableResourceNameDnsAAAARecord indicates + whether to respond to DNS queries for instance hostnames + with DNS AAAA records. + type: boolean + enableResourceNameDnsARecord: + description: EnableResourceNameDnsARecord indicates whether + to respond to DNS queries for instance hostnames with + DNS A records. + type: boolean + hostnameType: + description: The type of hostname to assign to an instance. + enum: + - ip-name + - resource-name + type: string + type: object providerID: description: ProviderID is the unique identifier as specified by the cloud provider. diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmanagedmachinepools.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmanagedmachinepools.yaml index 71ddb58d26..bc63c85a81 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmanagedmachinepools.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmanagedmachinepools.yaml @@ -678,6 +678,27 @@ spec: name: description: The name of the launch template. type: string + privateDnsNameOptions: + description: PrivateDnsNameOptions is the options for the instance + hostname. + properties: + enableResourceNameDnsAAAARecord: + description: EnableResourceNameDnsAAAARecord indicates whether + to respond to DNS queries for instance hostnames with DNS + AAAA records. + type: boolean + enableResourceNameDnsARecord: + description: EnableResourceNameDnsARecord indicates whether + to respond to DNS queries for instance hostnames with DNS + A records. + type: boolean + hostnameType: + description: The type of hostname to assign to an instance. + enum: + - ip-name + - resource-name + type: string + type: object rootVolume: description: RootVolume encapsulates the configuration options for the root volume diff --git a/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_webhook.go b/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_webhook.go index 97baa68716..76ad02d5bf 100644 --- a/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_webhook.go +++ b/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_webhook.go @@ -36,10 +36,11 @@ import ( ) const ( - minAddonVersion = "v1.18.0" - minKubeVersionForIPv6 = "v1.21.0" - minVpcCniVersionForIPv6 = "1.10.2" - maxClusterNameLength = 100 + minAddonVersion = "v1.18.0" + minKubeVersionForIPv6 = "v1.21.0" + minVpcCniVersionForIPv6 = "1.10.2" + maxClusterNameLength = 100 + hostnameTypeResourceName = "resource-name" ) // log is for logging in this package. @@ -93,6 +94,7 @@ func (r *AWSManagedControlPlane) ValidateCreate() (admission.Warnings, error) { allErrs = append(allErrs, r.validateKubeProxy()...) allErrs = append(allErrs, r.Spec.AdditionalTags.Validate()...) allErrs = append(allErrs, r.validateNetwork()...) + allErrs = append(allErrs, r.validatePrivateDnsHostnameTypeOnLaunch()...) if len(allErrs) == 0 { return nil, nil @@ -126,6 +128,7 @@ func (r *AWSManagedControlPlane) ValidateUpdate(old runtime.Object) (admission.W allErrs = append(allErrs, r.validateDisableVPCCNI()...) allErrs = append(allErrs, r.validateKubeProxy()...) allErrs = append(allErrs, r.Spec.AdditionalTags.Validate()...) + allErrs = append(allErrs, r.validatePrivateDnsHostnameTypeOnLaunch()...) if r.Spec.Region != oldAWSManagedControlplane.Spec.Region { allErrs = append(allErrs, @@ -389,6 +392,17 @@ func (r *AWSManagedControlPlane) validateDisableVPCCNI() field.ErrorList { return allErrs } +func (r *AWSManagedControlPlane) validatePrivateDnsHostnameTypeOnLaunch() field.ErrorList { + var allErrs field.ErrorList + + if r.Spec.NetworkSpec.VPC.IsIPv6Enabled() && r.Spec.NetworkSpec.VPC.PrivateDnsHostnameTypeOnLaunch != nil && *r.Spec.NetworkSpec.VPC.PrivateDnsHostnameTypeOnLaunch != hostnameTypeResourceName { + privateDnsHostnameTypeOnLaunch := field.NewPath("spec", "networkSpec", "vpc", "privateDnsHostnameTypeOnLaunch") + allErrs = append(allErrs, field.Invalid(privateDnsHostnameTypeOnLaunch, r.Spec.NetworkSpec.VPC.PrivateDnsHostnameTypeOnLaunch, fmt.Sprintf("only %s HostnameType can be used in IPv6 mode", hostnameTypeResourceName))) + } + + return allErrs +} + func (r *AWSManagedControlPlane) validateNetwork() field.ErrorList { var allErrs field.ErrorList diff --git a/exp/api/v1beta1/zz_generated.conversion.go b/exp/api/v1beta1/zz_generated.conversion.go index fe8b85def4..32377ce0ac 100644 --- a/exp/api/v1beta1/zz_generated.conversion.go +++ b/exp/api/v1beta1/zz_generated.conversion.go @@ -407,6 +407,7 @@ func autoConvert_v1beta2_AWSLaunchTemplate_To_v1beta1_AWSLaunchTemplate(in *v1be out.AdditionalSecurityGroups = *(*[]apiv1beta2.AWSResourceReference)(unsafe.Pointer(&in.AdditionalSecurityGroups)) out.SpotMarketOptions = (*apiv1beta2.SpotMarketOptions)(unsafe.Pointer(in.SpotMarketOptions)) // WARNING: in.InstanceMetadataOptions requires manual conversion: does not exist in peer-type + // WARNING: in.PrivateDnsNameOptions requires manual conversion: does not exist in peer-type return nil } diff --git a/exp/api/v1beta2/types.go b/exp/api/v1beta2/types.go index 04c824a419..51df3a8912 100644 --- a/exp/api/v1beta2/types.go +++ b/exp/api/v1beta2/types.go @@ -120,6 +120,10 @@ type AWSLaunchTemplate struct { // InstanceMetadataOptions defines the behavior for applying metadata to instances. // +optional InstanceMetadataOptions *infrav1.InstanceMetadataOptions `json:"instanceMetadataOptions,omitempty"` + + // PrivateDnsNameOptions is the options for the instance hostname. + // +optional + PrivateDnsNameOptions *infrav1.PrivateDnsNameOptions `json:"privateDnsNameOptions,omitempty"` } // Overrides are used to override the instance type specified by the launch template with multiple diff --git a/exp/api/v1beta2/zz_generated.deepcopy.go b/exp/api/v1beta2/zz_generated.deepcopy.go index 73a3ab00ce..5f84be55f0 100644 --- a/exp/api/v1beta2/zz_generated.deepcopy.go +++ b/exp/api/v1beta2/zz_generated.deepcopy.go @@ -123,6 +123,11 @@ func (in *AWSLaunchTemplate) DeepCopyInto(out *AWSLaunchTemplate) { *out = new(apiv1beta2.InstanceMetadataOptions) **out = **in } + if in.PrivateDnsNameOptions != nil { + in, out := &in.PrivateDnsNameOptions, &out.PrivateDnsNameOptions + *out = new(apiv1beta2.PrivateDnsNameOptions) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AWSLaunchTemplate. diff --git a/pkg/cloud/services/ec2/instances.go b/pkg/cloud/services/ec2/instances.go index d5b510f438..db99da9af2 100644 --- a/pkg/cloud/services/ec2/instances.go +++ b/pkg/cloud/services/ec2/instances.go @@ -238,6 +238,8 @@ func (s *Service) CreateInstance(scope *scope.MachineScope, userData []byte, use input.PlacementGroupName = scope.AWSMachine.Spec.PlacementGroupName + input.PrivateDnsNameOptions = scope.AWSMachine.Spec.PrivateDnsNameOptions + s.scope.Debug("Running instance", "machine-role", scope.Role()) s.scope.Debug("Running instance with instance metadata options", "metadata options", input.InstanceMetadataOptions) out, err := s.runInstance(scope.Role(), input) @@ -595,6 +597,7 @@ func (s *Service) runInstance(role string, i *infrav1.Instance) (*infrav1.Instan input.InstanceMarketOptions = getInstanceMarketOptionsRequest(i.SpotMarketOptions) input.MetadataOptions = getInstanceMetadataOptionsRequest(i.InstanceMetadataOptions) + input.PrivateDnsNameOptions = getPrivateDnsNameOptionsRequest(i.PrivateDnsNameOptions) if i.Tenancy != "" { input.Placement = &ec2.Placement{ @@ -865,6 +868,14 @@ func (s *Service) SDKToInstance(v *ec2.Instance) (*infrav1.Instance, error) { i.InstanceMetadataOptions = metadataOptions } + if v.PrivateDnsNameOptions != nil { + i.PrivateDnsNameOptions = &infrav1.PrivateDnsNameOptions{ + EnableResourceNameDnsAAAARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsAAAARecord, + EnableResourceNameDnsARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsARecord, + HostnameType: v.PrivateDnsNameOptions.HostnameType, + } + } + return i, nil } @@ -1053,3 +1064,15 @@ func getInstanceMetadataOptionsRequest(metadataOptions *infrav1.InstanceMetadata return request } + +func getPrivateDnsNameOptionsRequest(privateDnsNameOptions *infrav1.PrivateDnsNameOptions) *ec2.PrivateDnsNameOptionsRequest { + if privateDnsNameOptions == nil { + return nil + } + + return &ec2.PrivateDnsNameOptionsRequest{ + EnableResourceNameDnsAAAARecord: privateDnsNameOptions.EnableResourceNameDnsAAAARecord, + EnableResourceNameDnsARecord: privateDnsNameOptions.EnableResourceNameDnsARecord, + HostnameType: privateDnsNameOptions.HostnameType, + } +} diff --git a/pkg/cloud/services/ec2/launchtemplate.go b/pkg/cloud/services/ec2/launchtemplate.go index 8724b4bc86..f17c2b7b87 100644 --- a/pkg/cloud/services/ec2/launchtemplate.go +++ b/pkg/cloud/services/ec2/launchtemplate.go @@ -498,6 +498,7 @@ func (s *Service) createLaunchTemplateData(scope scope.LaunchTemplateScope, imag data.ImageId = imageID data.InstanceMarketOptions = getLaunchTemplateInstanceMarketOptionsRequest(scope.GetLaunchTemplate().SpotMarketOptions) + data.PrivateDnsNameOptions = getLaunchTemplatePrivateDnsNameOptionsRequest(scope.GetLaunchTemplate().PrivateDnsNameOptions) // Set up root volume if lt.RootVolume != nil { @@ -669,6 +670,14 @@ func (s *Service) SDKToLaunchTemplate(d *ec2.LaunchTemplateVersion) (*expinfrav1 } } + if v.PrivateDnsNameOptions != nil { + i.PrivateDnsNameOptions = &infrav1.PrivateDnsNameOptions{ + EnableResourceNameDnsAAAARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsAAAARecord, + EnableResourceNameDnsARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsARecord, + HostnameType: v.PrivateDnsNameOptions.HostnameType, + } + } + if v.IamInstanceProfile != nil { i.IamInstanceProfile = aws.StringValue(v.IamInstanceProfile.Name) } @@ -914,3 +923,15 @@ func getLaunchTemplateInstanceMarketOptionsRequest(spotMarketOptions *infrav1.Sp return launchTemplateInstanceMarketOptionsRequest } + +func getLaunchTemplatePrivateDnsNameOptionsRequest(privateDnsNameOptions *infrav1.PrivateDnsNameOptions) *ec2.LaunchTemplatePrivateDnsNameOptionsRequest { + if privateDnsNameOptions == nil { + return nil + } + + return &ec2.LaunchTemplatePrivateDnsNameOptionsRequest{ + EnableResourceNameDnsAAAARecord: privateDnsNameOptions.EnableResourceNameDnsAAAARecord, + EnableResourceNameDnsARecord: privateDnsNameOptions.EnableResourceNameDnsARecord, + HostnameType: privateDnsNameOptions.HostnameType, + } +} diff --git a/pkg/cloud/services/network/subnets.go b/pkg/cloud/services/network/subnets.go index 84766c4289..a28f34941d 100644 --- a/pkg/cloud/services/network/subnets.go +++ b/pkg/cloud/services/network/subnets.go @@ -490,6 +490,22 @@ func (s *Service) createSubnet(sn *infrav1.SubnetSpec) (*infrav1.SubnetSpec, err record.Eventf(s.scope.InfraCluster(), "SuccessfulModifySubnetAttributes", "Modified managed Subnet %q attributes", *out.Subnet.SubnetId) } + if s.scope.VPC().PrivateDnsHostnameTypeOnLaunch != nil { + if err := wait.WaitForWithRetryable(wait.NewBackoff(), func() (bool, error) { + if _, err := s.EC2Client.ModifySubnetAttributeWithContext(context.TODO(), &ec2.ModifySubnetAttributeInput{ + SubnetId: out.Subnet.SubnetId, + PrivateDnsHostnameTypeOnLaunch: s.scope.VPC().PrivateDnsHostnameTypeOnLaunch, + }); err != nil { + return false, err + } + return true, nil + }, awserrors.SubnetNotFound); err != nil { + record.Warnf(s.scope.InfraCluster(), "FailedModifySubnetAttributes", "Failed modifying managed Subnet %q attributes: %v", *out.Subnet.SubnetId, err) + return nil, errors.Wrapf(err, "failed to set subnet %q attribute private DNS Hostname type on launch", *out.Subnet.SubnetId) + } + record.Eventf(s.scope.InfraCluster(), "SuccessfulModifySubnetAttributes", "Modified managed Subnet %q attributes", *out.Subnet.SubnetId) + } + subnet := &infrav1.SubnetSpec{ // Preserve the original identifier. The AWS identifier `subnet-` is stored in the ResourceID field. ID: sn.ID, From af2a59e0089feb21a7911019fad2183cc2cd8d4e Mon Sep 17 00:00:00 2001 From: Max Fedotov Date: Fri, 22 Dec 2023 14:10:24 +0200 Subject: [PATCH 2/3] capitalize DNS abbreviation --- api/v1beta1/awscluster_conversion.go | 2 ++ api/v1beta1/awsmachine_conversion.go | 2 ++ api/v1beta1/zz_generated.conversion.go | 6 ++-- api/v1beta2/awsmachine_types.go | 4 +-- api/v1beta2/awsmachine_webhook.go | 14 ++++---- api/v1beta2/awsmachine_webhook_test.go | 10 +++--- api/v1beta2/network_types.go | 4 +-- api/v1beta2/types.go | 16 +++++----- api/v1beta2/zz_generated.deepcopy.go | 32 +++++++++---------- ...ster.x-k8s.io_awsmanagedcontrolplanes.yaml | 16 +++++----- ...tructure.cluster.x-k8s.io_awsclusters.yaml | 8 ++--- ....cluster.x-k8s.io_awsclustertemplates.yaml | 2 +- ...ture.cluster.x-k8s.io_awsmachinepools.yaml | 6 ++-- ...tructure.cluster.x-k8s.io_awsmachines.yaml | 6 ++-- ....cluster.x-k8s.io_awsmachinetemplates.yaml | 6 ++-- ...uster.x-k8s.io_awsmanagedmachinepools.yaml | 6 ++-- .../v1beta2/awsmanagedcontrolplane_webhook.go | 12 +++---- exp/api/v1beta1/conversion.go | 8 +++++ exp/api/v1beta1/zz_generated.conversion.go | 2 +- exp/api/v1beta2/types.go | 4 +-- exp/api/v1beta2/zz_generated.deepcopy.go | 6 ++-- pkg/cloud/services/ec2/instances.go | 20 ++++++------ pkg/cloud/services/ec2/launchtemplate.go | 18 +++++------ pkg/cloud/services/network/subnets.go | 4 +-- 24 files changed, 113 insertions(+), 101 deletions(-) diff --git a/api/v1beta1/awscluster_conversion.go b/api/v1beta1/awscluster_conversion.go index ca199770ec..8e666e189e 100644 --- a/api/v1beta1/awscluster_conversion.go +++ b/api/v1beta1/awscluster_conversion.go @@ -48,6 +48,7 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error { if restored.Status.Bastion != nil { dst.Status.Bastion.InstanceMetadataOptions = restored.Status.Bastion.InstanceMetadataOptions dst.Status.Bastion.PlacementGroupName = restored.Status.Bastion.PlacementGroupName + dst.Status.Bastion.PrivateDNSNameOptions = restored.Status.Bastion.PrivateDNSNameOptions } dst.Spec.Partition = restored.Spec.Partition @@ -91,6 +92,7 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error { } dst.Spec.NetworkSpec.VPC.EmptyRoutesDefaultVPCSecurityGroup = restored.Spec.NetworkSpec.VPC.EmptyRoutesDefaultVPCSecurityGroup + dst.Spec.NetworkSpec.VPC.PrivateDNSHostnameTypeOnLaunch = restored.Spec.NetworkSpec.VPC.PrivateDNSHostnameTypeOnLaunch // Restore SubnetSpec.ResourceID field, if any. for _, subnet := range restored.Spec.NetworkSpec.Subnets { diff --git a/api/v1beta1/awsmachine_conversion.go b/api/v1beta1/awsmachine_conversion.go index 503f6d37a5..275afd372b 100644 --- a/api/v1beta1/awsmachine_conversion.go +++ b/api/v1beta1/awsmachine_conversion.go @@ -38,6 +38,7 @@ func (src *AWSMachine) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Ignition = restored.Spec.Ignition dst.Spec.InstanceMetadataOptions = restored.Spec.InstanceMetadataOptions dst.Spec.PlacementGroupName = restored.Spec.PlacementGroupName + dst.Spec.PrivateDNSNameOptions = restored.Spec.PrivateDNSNameOptions return nil } @@ -85,6 +86,7 @@ func (r *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Template.Spec.Ignition = restored.Spec.Template.Spec.Ignition dst.Spec.Template.Spec.InstanceMetadataOptions = restored.Spec.Template.Spec.InstanceMetadataOptions dst.Spec.Template.Spec.PlacementGroupName = restored.Spec.Template.Spec.PlacementGroupName + dst.Spec.Template.Spec.PrivateDNSNameOptions = restored.Spec.Template.Spec.PrivateDNSNameOptions return nil } diff --git a/api/v1beta1/zz_generated.conversion.go b/api/v1beta1/zz_generated.conversion.go index 88ab37dd5b..57cd1c576b 100644 --- a/api/v1beta1/zz_generated.conversion.go +++ b/api/v1beta1/zz_generated.conversion.go @@ -1411,7 +1411,7 @@ func autoConvert_v1beta2_AWSMachineSpec_To_v1beta1_AWSMachineSpec(in *v1beta2.AW out.SpotMarketOptions = (*SpotMarketOptions)(unsafe.Pointer(in.SpotMarketOptions)) // WARNING: in.PlacementGroupName requires manual conversion: does not exist in peer-type out.Tenancy = in.Tenancy - // WARNING: in.PrivateDnsNameOptions requires manual conversion: does not exist in peer-type + // WARNING: in.PrivateDNSNameOptions requires manual conversion: does not exist in peer-type return nil } @@ -2011,7 +2011,7 @@ func autoConvert_v1beta2_Instance_To_v1beta1_Instance(in *v1beta2.Instance, out out.Tenancy = in.Tenancy out.VolumeIDs = *(*[]string)(unsafe.Pointer(&in.VolumeIDs)) // WARNING: in.InstanceMetadataOptions requires manual conversion: does not exist in peer-type - // WARNING: in.PrivateDnsNameOptions requires manual conversion: does not exist in peer-type + // WARNING: in.PrivateDNSNameOptions requires manual conversion: does not exist in peer-type return nil } @@ -2286,8 +2286,8 @@ func autoConvert_v1beta2_VPCSpec_To_v1beta1_VPCSpec(in *v1beta2.VPCSpec, out *VP out.Tags = *(*Tags)(unsafe.Pointer(&in.Tags)) out.AvailabilityZoneUsageLimit = (*int)(unsafe.Pointer(in.AvailabilityZoneUsageLimit)) out.AvailabilityZoneSelection = (*AZSelectionScheme)(unsafe.Pointer(in.AvailabilityZoneSelection)) - // WARNING: in.PrivateDnsHostnameTypeOnLaunch requires manual conversion: does not exist in peer-type // WARNING: in.EmptyRoutesDefaultVPCSecurityGroup requires manual conversion: does not exist in peer-type + // WARNING: in.PrivateDNSHostnameTypeOnLaunch requires manual conversion: does not exist in peer-type return nil } diff --git a/api/v1beta2/awsmachine_types.go b/api/v1beta2/awsmachine_types.go index 1a8e72626e..802612792b 100644 --- a/api/v1beta2/awsmachine_types.go +++ b/api/v1beta2/awsmachine_types.go @@ -161,9 +161,9 @@ type AWSMachineSpec struct { // +kubebuilder:validation:Enum:=default;dedicated;host Tenancy string `json:"tenancy,omitempty"` - // PrivateDnsNameOptions is the options for the instance hostname. + // PrivateDNSNameOptions is the options for the instance hostname. // +optional - PrivateDnsNameOptions *PrivateDnsNameOptions `json:"privateDnsNameOptions,omitempty"` + PrivateDNSNameOptions *PrivateDNSNameOptions `json:"privateDnsNameOptions,omitempty"` } // CloudInit defines options related to the bootstrapping systems where diff --git a/api/v1beta2/awsmachine_webhook.go b/api/v1beta2/awsmachine_webhook.go index 2c749dd475..965fed1805 100644 --- a/api/v1beta2/awsmachine_webhook.go +++ b/api/v1beta2/awsmachine_webhook.go @@ -114,15 +114,15 @@ func (r *AWSMachine) ValidateUpdate(old runtime.Object) (admission.Warnings, err delete(cloudInit, "secureSecretsBackend") } - // allow changes to enableResourceNameDnsAAAARecord and enableResourceNameDnsARecord - if privateDnsNameOptions, ok := oldAWSMachineSpec["privateDnsNameOptions"].(map[string]interface{}); ok { - delete(privateDnsNameOptions, "enableResourceNameDnsAAAARecord") - delete(privateDnsNameOptions, "enableResourceNameDnsARecord") + // allow changes to enableResourceNameDNSAAAARecord and enableResourceNameDNSARecord + if privateDNSNameOptions, ok := oldAWSMachineSpec["privateDnsNameOptions"].(map[string]interface{}); ok { + delete(privateDNSNameOptions, "enableResourceNameDnsAAAARecord") + delete(privateDNSNameOptions, "enableResourceNameDnsARecord") } - if privateDnsNameOptions, ok := newAWSMachineSpec["privateDnsNameOptions"].(map[string]interface{}); ok { - delete(privateDnsNameOptions, "enableResourceNameDnsAAAARecord") - delete(privateDnsNameOptions, "enableResourceNameDnsARecord") + if privateDNSNameOptions, ok := newAWSMachineSpec["privateDnsNameOptions"].(map[string]interface{}); ok { + delete(privateDNSNameOptions, "enableResourceNameDnsAAAARecord") + delete(privateDNSNameOptions, "enableResourceNameDnsARecord") } if !cmp.Equal(oldAWSMachineSpec, newAWSMachineSpec) { diff --git a/api/v1beta2/awsmachine_webhook_test.go b/api/v1beta2/awsmachine_webhook_test.go index 280f7bdda2..a9a0da34de 100644 --- a/api/v1beta2/awsmachine_webhook_test.go +++ b/api/v1beta2/awsmachine_webhook_test.go @@ -273,7 +273,7 @@ func TestAWSMachineUpdate(t *testing.T) { wantErr bool }{ { - name: "change in providerid, cloudinit, tags, securitygroups and privateDnsNameOptions", + name: "change in providerid, cloudinit, tags, securitygroups", oldMachine: &AWSMachine{ Spec: AWSMachineSpec{ ProviderID: nil, @@ -298,10 +298,6 @@ func TestAWSMachineUpdate(t *testing.T) { SecretPrefix: "test", SecretCount: 5, }, - PrivateDnsNameOptions: &PrivateDnsNameOptions{ - EnableResourceNameDnsAAAARecord: aws.Bool(true), - EnableResourceNameDnsARecord: aws.Bool(true), - }, }, }, wantErr: false, @@ -329,6 +325,10 @@ func TestAWSMachineUpdate(t *testing.T) { ID: pointer.String("ID"), }, }, + PrivateDNSNameOptions: &PrivateDNSNameOptions{ + EnableResourceNameDNSAAAARecord: aws.Bool(true), + EnableResourceNameDNSARecord: aws.Bool(true), + }, }, }, wantErr: true, diff --git a/api/v1beta2/network_types.go b/api/v1beta2/network_types.go index a606986dad..7d70f411ce 100644 --- a/api/v1beta2/network_types.go +++ b/api/v1beta2/network_types.go @@ -336,12 +336,12 @@ type VPCSpec struct { // +optional EmptyRoutesDefaultVPCSecurityGroup bool `json:"emptyRoutesDefaultVPCSecurityGroup,omitempty"` - // PrivateDnsHostnameTypeOnLaunch is the type of hostname to assign to instances in the subnet at launch. + // PrivateDNSHostnameTypeOnLaunch is the type of hostname to assign to instances in the subnet at launch. // For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an instance DNS name can be based on the instance IPv4 address (ip-name) // or the instance ID (resource-name). For IPv6 only subnets, an instance DNS name must be based on the instance ID (resource-name). // +optional // +kubebuilder:validation:Enum:=ip-name;resource-name - PrivateDnsHostnameTypeOnLaunch *string `json:"privateDnsHostnameTypeOnLaunch,omitempty"` + PrivateDNSHostnameTypeOnLaunch *string `json:"privateDnsHostnameTypeOnLaunch,omitempty"` } // String returns a string representation of the VPC. diff --git a/api/v1beta2/types.go b/api/v1beta2/types.go index 785f44a293..e06a01d557 100644 --- a/api/v1beta2/types.go +++ b/api/v1beta2/types.go @@ -233,9 +233,9 @@ type Instance struct { // +optional InstanceMetadataOptions *InstanceMetadataOptions `json:"instanceMetadataOptions,omitempty"` - // PrivateDnsNameOptions is the options for the instance hostname. + // PrivateDNSNameOptions is the options for the instance hostname. // +optional - PrivateDnsNameOptions *PrivateDnsNameOptions `json:"privateDnsNameOptions,omitempty"` + PrivateDNSNameOptions *PrivateDNSNameOptions `json:"privateDnsNameOptions,omitempty"` } // InstanceMetadataState describes the state of InstanceMetadataOptions.HttpEndpoint and InstanceMetadataOptions.InstanceMetadataTags @@ -412,14 +412,14 @@ const ( AmazonLinuxGPU EKSAMILookupType = "AmazonLinuxGPU" ) -// PrivateDnsNameOptions is the options for the instance hostname. -type PrivateDnsNameOptions struct { - // EnableResourceNameDnsAAAARecord indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. +// PrivateDNSNameOptions is the options for the instance hostname. +type PrivateDNSNameOptions struct { + // EnableResourceNameDNSAAAARecord indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. // +optional - EnableResourceNameDnsAAAARecord *bool `json:"enableResourceNameDnsAAAARecord,omitempty"` - // EnableResourceNameDnsARecord indicates whether to respond to DNS queries for instance hostnames with DNS A records. + EnableResourceNameDNSAAAARecord *bool `json:"enableResourceNameDnsAAAARecord,omitempty"` + // EnableResourceNameDNSARecord indicates whether to respond to DNS queries for instance hostnames with DNS A records. // +optional - EnableResourceNameDnsARecord *bool `json:"enableResourceNameDnsARecord,omitempty"` + EnableResourceNameDNSARecord *bool `json:"enableResourceNameDnsARecord,omitempty"` // The type of hostname to assign to an instance. // +optional // +kubebuilder:validation:Enum:=ip-name;resource-name diff --git a/api/v1beta2/zz_generated.deepcopy.go b/api/v1beta2/zz_generated.deepcopy.go index f50ab4edda..3ce76f17c9 100644 --- a/api/v1beta2/zz_generated.deepcopy.go +++ b/api/v1beta2/zz_generated.deepcopy.go @@ -739,9 +739,9 @@ func (in *AWSMachineSpec) DeepCopyInto(out *AWSMachineSpec) { *out = new(SpotMarketOptions) (*in).DeepCopyInto(*out) } - if in.PrivateDnsNameOptions != nil { - in, out := &in.PrivateDnsNameOptions, &out.PrivateDnsNameOptions - *out = new(PrivateDnsNameOptions) + if in.PrivateDNSNameOptions != nil { + in, out := &in.PrivateDNSNameOptions, &out.PrivateDNSNameOptions + *out = new(PrivateDNSNameOptions) (*in).DeepCopyInto(*out) } } @@ -1471,9 +1471,9 @@ func (in *Instance) DeepCopyInto(out *Instance) { *out = new(InstanceMetadataOptions) **out = **in } - if in.PrivateDnsNameOptions != nil { - in, out := &in.PrivateDnsNameOptions, &out.PrivateDnsNameOptions - *out = new(PrivateDnsNameOptions) + if in.PrivateDNSNameOptions != nil { + in, out := &in.PrivateDNSNameOptions, &out.PrivateDNSNameOptions + *out = new(PrivateDNSNameOptions) (*in).DeepCopyInto(*out) } } @@ -1660,15 +1660,15 @@ func (in *NetworkStatus) DeepCopy() *NetworkStatus { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PrivateDnsNameOptions) DeepCopyInto(out *PrivateDnsNameOptions) { +func (in *PrivateDNSNameOptions) DeepCopyInto(out *PrivateDNSNameOptions) { *out = *in - if in.EnableResourceNameDnsAAAARecord != nil { - in, out := &in.EnableResourceNameDnsAAAARecord, &out.EnableResourceNameDnsAAAARecord + if in.EnableResourceNameDNSAAAARecord != nil { + in, out := &in.EnableResourceNameDNSAAAARecord, &out.EnableResourceNameDNSAAAARecord *out = new(bool) **out = **in } - if in.EnableResourceNameDnsARecord != nil { - in, out := &in.EnableResourceNameDnsARecord, &out.EnableResourceNameDnsARecord + if in.EnableResourceNameDNSARecord != nil { + in, out := &in.EnableResourceNameDNSARecord, &out.EnableResourceNameDNSARecord *out = new(bool) **out = **in } @@ -1679,12 +1679,12 @@ func (in *PrivateDnsNameOptions) DeepCopyInto(out *PrivateDnsNameOptions) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PrivateDnsNameOptions. -func (in *PrivateDnsNameOptions) DeepCopy() *PrivateDnsNameOptions { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PrivateDNSNameOptions. +func (in *PrivateDNSNameOptions) DeepCopy() *PrivateDNSNameOptions { if in == nil { return nil } - out := new(PrivateDnsNameOptions) + out := new(PrivateDNSNameOptions) in.DeepCopyInto(out) return out } @@ -1952,8 +1952,8 @@ func (in *VPCSpec) DeepCopyInto(out *VPCSpec) { *out = new(AZSelectionScheme) **out = **in } - if in.PrivateDnsHostnameTypeOnLaunch != nil { - in, out := &in.PrivateDnsHostnameTypeOnLaunch, &out.PrivateDnsHostnameTypeOnLaunch + if in.PrivateDNSHostnameTypeOnLaunch != nil { + in, out := &in.PrivateDNSHostnameTypeOnLaunch, &out.PrivateDNSHostnameTypeOnLaunch *out = new(string) **out = **in } diff --git a/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml b/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml index c8ef0511b2..1aaae14960 100644 --- a/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml +++ b/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml @@ -648,7 +648,7 @@ spec: type: string type: object privateDnsHostnameTypeOnLaunch: - description: PrivateDnsHostnameTypeOnLaunch is the type of + description: PrivateDNSHostnameTypeOnLaunch is the type of hostname to assign to instances in the subnet at launch. For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an instance DNS name can be based on the instance IPv4 address @@ -1109,16 +1109,16 @@ spec: group in which to launch the instance. type: string privateDnsNameOptions: - description: PrivateDnsNameOptions is the options for the instance + description: PrivateDNSNameOptions is the options for the instance hostname. properties: enableResourceNameDnsAAAARecord: - description: EnableResourceNameDnsAAAARecord indicates whether + description: EnableResourceNameDNSAAAARecord indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. type: boolean enableResourceNameDnsARecord: - description: EnableResourceNameDnsARecord indicates whether + description: EnableResourceNameDNSARecord indicates whether to respond to DNS queries for instance hostnames with DNS A records. type: boolean @@ -2278,7 +2278,7 @@ spec: type: string type: object privateDnsHostnameTypeOnLaunch: - description: PrivateDnsHostnameTypeOnLaunch is the type of + description: PrivateDNSHostnameTypeOnLaunch is the type of hostname to assign to instances in the subnet at launch. For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an instance DNS name can be based on the instance IPv4 address @@ -2752,16 +2752,16 @@ spec: group in which to launch the instance. type: string privateDnsNameOptions: - description: PrivateDnsNameOptions is the options for the instance + description: PrivateDNSNameOptions is the options for the instance hostname. properties: enableResourceNameDnsAAAARecord: - description: EnableResourceNameDnsAAAARecord indicates whether + description: EnableResourceNameDNSAAAARecord indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. type: boolean enableResourceNameDnsARecord: - description: EnableResourceNameDnsARecord indicates whether + description: EnableResourceNameDNSARecord indicates whether to respond to DNS queries for instance hostnames with DNS A records. type: boolean diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml index 69cfd73388..8726b507ab 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml @@ -1480,7 +1480,7 @@ spec: type: string type: object privateDnsHostnameTypeOnLaunch: - description: PrivateDnsHostnameTypeOnLaunch is the type of + description: PrivateDNSHostnameTypeOnLaunch is the type of hostname to assign to instances in the subnet at launch. For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an instance DNS name can be based on the instance IPv4 address @@ -1700,16 +1700,16 @@ spec: group in which to launch the instance. type: string privateDnsNameOptions: - description: PrivateDnsNameOptions is the options for the instance + description: PrivateDNSNameOptions is the options for the instance hostname. properties: enableResourceNameDnsAAAARecord: - description: EnableResourceNameDnsAAAARecord indicates whether + description: EnableResourceNameDNSAAAARecord indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. type: boolean enableResourceNameDnsARecord: - description: EnableResourceNameDnsARecord indicates whether + description: EnableResourceNameDNSARecord indicates whether to respond to DNS queries for instance hostnames with DNS A records. type: boolean diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclustertemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclustertemplates.yaml index 2b07463f88..28dde03c70 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclustertemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclustertemplates.yaml @@ -1099,7 +1099,7 @@ spec: type: string type: object privateDnsHostnameTypeOnLaunch: - description: PrivateDnsHostnameTypeOnLaunch is the + description: PrivateDNSHostnameTypeOnLaunch is the type of hostname to assign to instances in the subnet at launch. For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an instance DNS name can be based diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml index f1461835ff..ed45bdc41d 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml @@ -691,16 +691,16 @@ spec: description: The name of the launch template. type: string privateDnsNameOptions: - description: PrivateDnsNameOptions is the options for the instance + description: PrivateDNSNameOptions is the options for the instance hostname. properties: enableResourceNameDnsAAAARecord: - description: EnableResourceNameDnsAAAARecord indicates whether + description: EnableResourceNameDNSAAAARecord indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. type: boolean enableResourceNameDnsARecord: - description: EnableResourceNameDnsARecord indicates whether + description: EnableResourceNameDNSARecord indicates whether to respond to DNS queries for instance hostnames with DNS A records. type: boolean diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml index db25f22155..dbdc1a1f0e 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml @@ -781,16 +781,16 @@ spec: group in which to launch the instance. type: string privateDnsNameOptions: - description: PrivateDnsNameOptions is the options for the instance + description: PrivateDNSNameOptions is the options for the instance hostname. properties: enableResourceNameDnsAAAARecord: - description: EnableResourceNameDnsAAAARecord indicates whether + description: EnableResourceNameDNSAAAARecord indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. type: boolean enableResourceNameDnsARecord: - description: EnableResourceNameDnsARecord indicates whether to + description: EnableResourceNameDNSARecord indicates whether to respond to DNS queries for instance hostnames with DNS A records. type: boolean hostnameType: diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml index 0f3891dfb5..98ae2e1f06 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml @@ -735,16 +735,16 @@ spec: placement group in which to launch the instance. type: string privateDnsNameOptions: - description: PrivateDnsNameOptions is the options for the + description: PrivateDNSNameOptions is the options for the instance hostname. properties: enableResourceNameDnsAAAARecord: - description: EnableResourceNameDnsAAAARecord indicates + description: EnableResourceNameDNSAAAARecord indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. type: boolean enableResourceNameDnsARecord: - description: EnableResourceNameDnsARecord indicates whether + description: EnableResourceNameDNSARecord indicates whether to respond to DNS queries for instance hostnames with DNS A records. type: boolean diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmanagedmachinepools.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmanagedmachinepools.yaml index bc63c85a81..e109b1fd75 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmanagedmachinepools.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmanagedmachinepools.yaml @@ -679,16 +679,16 @@ spec: description: The name of the launch template. type: string privateDnsNameOptions: - description: PrivateDnsNameOptions is the options for the instance + description: PrivateDNSNameOptions is the options for the instance hostname. properties: enableResourceNameDnsAAAARecord: - description: EnableResourceNameDnsAAAARecord indicates whether + description: EnableResourceNameDNSAAAARecord indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. type: boolean enableResourceNameDnsARecord: - description: EnableResourceNameDnsARecord indicates whether + description: EnableResourceNameDNSARecord indicates whether to respond to DNS queries for instance hostnames with DNS A records. type: boolean diff --git a/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_webhook.go b/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_webhook.go index 76ad02d5bf..4b44508b65 100644 --- a/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_webhook.go +++ b/controlplane/eks/api/v1beta2/awsmanagedcontrolplane_webhook.go @@ -94,7 +94,7 @@ func (r *AWSManagedControlPlane) ValidateCreate() (admission.Warnings, error) { allErrs = append(allErrs, r.validateKubeProxy()...) allErrs = append(allErrs, r.Spec.AdditionalTags.Validate()...) allErrs = append(allErrs, r.validateNetwork()...) - allErrs = append(allErrs, r.validatePrivateDnsHostnameTypeOnLaunch()...) + allErrs = append(allErrs, r.validatePrivateDNSHostnameTypeOnLaunch()...) if len(allErrs) == 0 { return nil, nil @@ -128,7 +128,7 @@ func (r *AWSManagedControlPlane) ValidateUpdate(old runtime.Object) (admission.W allErrs = append(allErrs, r.validateDisableVPCCNI()...) allErrs = append(allErrs, r.validateKubeProxy()...) allErrs = append(allErrs, r.Spec.AdditionalTags.Validate()...) - allErrs = append(allErrs, r.validatePrivateDnsHostnameTypeOnLaunch()...) + allErrs = append(allErrs, r.validatePrivateDNSHostnameTypeOnLaunch()...) if r.Spec.Region != oldAWSManagedControlplane.Spec.Region { allErrs = append(allErrs, @@ -392,12 +392,12 @@ func (r *AWSManagedControlPlane) validateDisableVPCCNI() field.ErrorList { return allErrs } -func (r *AWSManagedControlPlane) validatePrivateDnsHostnameTypeOnLaunch() field.ErrorList { +func (r *AWSManagedControlPlane) validatePrivateDNSHostnameTypeOnLaunch() field.ErrorList { var allErrs field.ErrorList - if r.Spec.NetworkSpec.VPC.IsIPv6Enabled() && r.Spec.NetworkSpec.VPC.PrivateDnsHostnameTypeOnLaunch != nil && *r.Spec.NetworkSpec.VPC.PrivateDnsHostnameTypeOnLaunch != hostnameTypeResourceName { - privateDnsHostnameTypeOnLaunch := field.NewPath("spec", "networkSpec", "vpc", "privateDnsHostnameTypeOnLaunch") - allErrs = append(allErrs, field.Invalid(privateDnsHostnameTypeOnLaunch, r.Spec.NetworkSpec.VPC.PrivateDnsHostnameTypeOnLaunch, fmt.Sprintf("only %s HostnameType can be used in IPv6 mode", hostnameTypeResourceName))) + if r.Spec.NetworkSpec.VPC.IsIPv6Enabled() && r.Spec.NetworkSpec.VPC.PrivateDNSHostnameTypeOnLaunch != nil && *r.Spec.NetworkSpec.VPC.PrivateDNSHostnameTypeOnLaunch != hostnameTypeResourceName { + privateDNSHostnameTypeOnLaunch := field.NewPath("spec", "networkSpec", "vpc", "privateDNSHostnameTypeOnLaunch") + allErrs = append(allErrs, field.Invalid(privateDNSHostnameTypeOnLaunch, r.Spec.NetworkSpec.VPC.PrivateDNSHostnameTypeOnLaunch, fmt.Sprintf("only %s HostnameType can be used in IPv6 mode", hostnameTypeResourceName))) } return allErrs diff --git a/exp/api/v1beta1/conversion.go b/exp/api/v1beta1/conversion.go index db54099fd3..4cc33bfe8d 100644 --- a/exp/api/v1beta1/conversion.go +++ b/exp/api/v1beta1/conversion.go @@ -51,6 +51,10 @@ func (src *AWSMachinePool) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.AvailabilityZoneSubnetType = restored.Spec.AvailabilityZoneSubnetType } + if restored.Spec.AWSLaunchTemplate.PrivateDNSNameOptions != nil { + dst.Spec.AWSLaunchTemplate.PrivateDNSNameOptions = restored.Spec.AWSLaunchTemplate.PrivateDNSNameOptions + } + return nil } @@ -95,6 +99,10 @@ func (src *AWSManagedMachinePool) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.AWSLaunchTemplate = restored.Spec.AWSLaunchTemplate } dst.Spec.AWSLaunchTemplate.InstanceMetadataOptions = restored.Spec.AWSLaunchTemplate.InstanceMetadataOptions + + if restored.Spec.AWSLaunchTemplate.PrivateDNSNameOptions != nil { + dst.Spec.AWSLaunchTemplate.PrivateDNSNameOptions = restored.Spec.AWSLaunchTemplate.PrivateDNSNameOptions + } } if restored.Spec.AvailabilityZoneSubnetType != nil { dst.Spec.AvailabilityZoneSubnetType = restored.Spec.AvailabilityZoneSubnetType diff --git a/exp/api/v1beta1/zz_generated.conversion.go b/exp/api/v1beta1/zz_generated.conversion.go index 32377ce0ac..77636c3ae1 100644 --- a/exp/api/v1beta1/zz_generated.conversion.go +++ b/exp/api/v1beta1/zz_generated.conversion.go @@ -407,7 +407,7 @@ func autoConvert_v1beta2_AWSLaunchTemplate_To_v1beta1_AWSLaunchTemplate(in *v1be out.AdditionalSecurityGroups = *(*[]apiv1beta2.AWSResourceReference)(unsafe.Pointer(&in.AdditionalSecurityGroups)) out.SpotMarketOptions = (*apiv1beta2.SpotMarketOptions)(unsafe.Pointer(in.SpotMarketOptions)) // WARNING: in.InstanceMetadataOptions requires manual conversion: does not exist in peer-type - // WARNING: in.PrivateDnsNameOptions requires manual conversion: does not exist in peer-type + // WARNING: in.PrivateDNSNameOptions requires manual conversion: does not exist in peer-type return nil } diff --git a/exp/api/v1beta2/types.go b/exp/api/v1beta2/types.go index 51df3a8912..08f89b69e6 100644 --- a/exp/api/v1beta2/types.go +++ b/exp/api/v1beta2/types.go @@ -121,9 +121,9 @@ type AWSLaunchTemplate struct { // +optional InstanceMetadataOptions *infrav1.InstanceMetadataOptions `json:"instanceMetadataOptions,omitempty"` - // PrivateDnsNameOptions is the options for the instance hostname. + // PrivateDNSNameOptions is the options for the instance hostname. // +optional - PrivateDnsNameOptions *infrav1.PrivateDnsNameOptions `json:"privateDnsNameOptions,omitempty"` + PrivateDNSNameOptions *infrav1.PrivateDNSNameOptions `json:"privateDnsNameOptions,omitempty"` } // Overrides are used to override the instance type specified by the launch template with multiple diff --git a/exp/api/v1beta2/zz_generated.deepcopy.go b/exp/api/v1beta2/zz_generated.deepcopy.go index 5f84be55f0..4b8b59b193 100644 --- a/exp/api/v1beta2/zz_generated.deepcopy.go +++ b/exp/api/v1beta2/zz_generated.deepcopy.go @@ -123,9 +123,9 @@ func (in *AWSLaunchTemplate) DeepCopyInto(out *AWSLaunchTemplate) { *out = new(apiv1beta2.InstanceMetadataOptions) **out = **in } - if in.PrivateDnsNameOptions != nil { - in, out := &in.PrivateDnsNameOptions, &out.PrivateDnsNameOptions - *out = new(apiv1beta2.PrivateDnsNameOptions) + if in.PrivateDNSNameOptions != nil { + in, out := &in.PrivateDNSNameOptions, &out.PrivateDNSNameOptions + *out = new(apiv1beta2.PrivateDNSNameOptions) (*in).DeepCopyInto(*out) } } diff --git a/pkg/cloud/services/ec2/instances.go b/pkg/cloud/services/ec2/instances.go index db99da9af2..b2c060ce6c 100644 --- a/pkg/cloud/services/ec2/instances.go +++ b/pkg/cloud/services/ec2/instances.go @@ -238,7 +238,7 @@ func (s *Service) CreateInstance(scope *scope.MachineScope, userData []byte, use input.PlacementGroupName = scope.AWSMachine.Spec.PlacementGroupName - input.PrivateDnsNameOptions = scope.AWSMachine.Spec.PrivateDnsNameOptions + input.PrivateDNSNameOptions = scope.AWSMachine.Spec.PrivateDNSNameOptions s.scope.Debug("Running instance", "machine-role", scope.Role()) s.scope.Debug("Running instance with instance metadata options", "metadata options", input.InstanceMetadataOptions) @@ -597,7 +597,7 @@ func (s *Service) runInstance(role string, i *infrav1.Instance) (*infrav1.Instan input.InstanceMarketOptions = getInstanceMarketOptionsRequest(i.SpotMarketOptions) input.MetadataOptions = getInstanceMetadataOptionsRequest(i.InstanceMetadataOptions) - input.PrivateDnsNameOptions = getPrivateDnsNameOptionsRequest(i.PrivateDnsNameOptions) + input.PrivateDnsNameOptions = getPrivateDNSNameOptionsRequest(i.PrivateDNSNameOptions) if i.Tenancy != "" { input.Placement = &ec2.Placement{ @@ -869,9 +869,9 @@ func (s *Service) SDKToInstance(v *ec2.Instance) (*infrav1.Instance, error) { } if v.PrivateDnsNameOptions != nil { - i.PrivateDnsNameOptions = &infrav1.PrivateDnsNameOptions{ - EnableResourceNameDnsAAAARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsAAAARecord, - EnableResourceNameDnsARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsARecord, + i.PrivateDNSNameOptions = &infrav1.PrivateDNSNameOptions{ + EnableResourceNameDNSAAAARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsAAAARecord, + EnableResourceNameDNSARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsARecord, HostnameType: v.PrivateDnsNameOptions.HostnameType, } } @@ -1065,14 +1065,14 @@ func getInstanceMetadataOptionsRequest(metadataOptions *infrav1.InstanceMetadata return request } -func getPrivateDnsNameOptionsRequest(privateDnsNameOptions *infrav1.PrivateDnsNameOptions) *ec2.PrivateDnsNameOptionsRequest { - if privateDnsNameOptions == nil { +func getPrivateDNSNameOptionsRequest(privateDNSNameOptions *infrav1.PrivateDNSNameOptions) *ec2.PrivateDnsNameOptionsRequest { + if privateDNSNameOptions == nil { return nil } return &ec2.PrivateDnsNameOptionsRequest{ - EnableResourceNameDnsAAAARecord: privateDnsNameOptions.EnableResourceNameDnsAAAARecord, - EnableResourceNameDnsARecord: privateDnsNameOptions.EnableResourceNameDnsARecord, - HostnameType: privateDnsNameOptions.HostnameType, + EnableResourceNameDnsAAAARecord: privateDNSNameOptions.EnableResourceNameDNSAAAARecord, + EnableResourceNameDnsARecord: privateDNSNameOptions.EnableResourceNameDNSARecord, + HostnameType: privateDNSNameOptions.HostnameType, } } diff --git a/pkg/cloud/services/ec2/launchtemplate.go b/pkg/cloud/services/ec2/launchtemplate.go index f17c2b7b87..5acc6b9864 100644 --- a/pkg/cloud/services/ec2/launchtemplate.go +++ b/pkg/cloud/services/ec2/launchtemplate.go @@ -498,7 +498,7 @@ func (s *Service) createLaunchTemplateData(scope scope.LaunchTemplateScope, imag data.ImageId = imageID data.InstanceMarketOptions = getLaunchTemplateInstanceMarketOptionsRequest(scope.GetLaunchTemplate().SpotMarketOptions) - data.PrivateDnsNameOptions = getLaunchTemplatePrivateDnsNameOptionsRequest(scope.GetLaunchTemplate().PrivateDnsNameOptions) + data.PrivateDnsNameOptions = getLaunchTemplatePrivateDNSNameOptionsRequest(scope.GetLaunchTemplate().PrivateDNSNameOptions) // Set up root volume if lt.RootVolume != nil { @@ -671,9 +671,9 @@ func (s *Service) SDKToLaunchTemplate(d *ec2.LaunchTemplateVersion) (*expinfrav1 } if v.PrivateDnsNameOptions != nil { - i.PrivateDnsNameOptions = &infrav1.PrivateDnsNameOptions{ - EnableResourceNameDnsAAAARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsAAAARecord, - EnableResourceNameDnsARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsARecord, + i.PrivateDNSNameOptions = &infrav1.PrivateDNSNameOptions{ + EnableResourceNameDNSAAAARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsAAAARecord, + EnableResourceNameDNSARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsARecord, HostnameType: v.PrivateDnsNameOptions.HostnameType, } } @@ -924,14 +924,14 @@ func getLaunchTemplateInstanceMarketOptionsRequest(spotMarketOptions *infrav1.Sp return launchTemplateInstanceMarketOptionsRequest } -func getLaunchTemplatePrivateDnsNameOptionsRequest(privateDnsNameOptions *infrav1.PrivateDnsNameOptions) *ec2.LaunchTemplatePrivateDnsNameOptionsRequest { - if privateDnsNameOptions == nil { +func getLaunchTemplatePrivateDNSNameOptionsRequest(privateDNSNameOptions *infrav1.PrivateDNSNameOptions) *ec2.LaunchTemplatePrivateDnsNameOptionsRequest { + if privateDNSNameOptions == nil { return nil } return &ec2.LaunchTemplatePrivateDnsNameOptionsRequest{ - EnableResourceNameDnsAAAARecord: privateDnsNameOptions.EnableResourceNameDnsAAAARecord, - EnableResourceNameDnsARecord: privateDnsNameOptions.EnableResourceNameDnsARecord, - HostnameType: privateDnsNameOptions.HostnameType, + EnableResourceNameDnsAAAARecord: privateDNSNameOptions.EnableResourceNameDNSAAAARecord, + EnableResourceNameDnsARecord: privateDNSNameOptions.EnableResourceNameDNSARecord, + HostnameType: privateDNSNameOptions.HostnameType, } } diff --git a/pkg/cloud/services/network/subnets.go b/pkg/cloud/services/network/subnets.go index a28f34941d..d2b1ee1c63 100644 --- a/pkg/cloud/services/network/subnets.go +++ b/pkg/cloud/services/network/subnets.go @@ -490,11 +490,11 @@ func (s *Service) createSubnet(sn *infrav1.SubnetSpec) (*infrav1.SubnetSpec, err record.Eventf(s.scope.InfraCluster(), "SuccessfulModifySubnetAttributes", "Modified managed Subnet %q attributes", *out.Subnet.SubnetId) } - if s.scope.VPC().PrivateDnsHostnameTypeOnLaunch != nil { + if s.scope.VPC().PrivateDNSHostnameTypeOnLaunch != nil { if err := wait.WaitForWithRetryable(wait.NewBackoff(), func() (bool, error) { if _, err := s.EC2Client.ModifySubnetAttributeWithContext(context.TODO(), &ec2.ModifySubnetAttributeInput{ SubnetId: out.Subnet.SubnetId, - PrivateDnsHostnameTypeOnLaunch: s.scope.VPC().PrivateDnsHostnameTypeOnLaunch, + PrivateDnsHostnameTypeOnLaunch: s.scope.VPC().PrivateDNSHostnameTypeOnLaunch, }); err != nil { return false, err } From d6b1fc2383198c2c789f90c37657c69c3f187a0b Mon Sep 17 00:00:00 2001 From: Max Fedotov Date: Mon, 29 Jan 2024 13:46:57 +0200 Subject: [PATCH 3/3] rename PrivateDNSNameOptions -> PrivateDNSName --- api/v1beta1/awscluster_conversion.go | 2 +- api/v1beta1/awsmachine_conversion.go | 4 ++-- api/v1beta1/zz_generated.conversion.go | 4 ++-- api/v1beta2/awsmachine_types.go | 4 ++-- api/v1beta2/awsmachine_webhook.go | 12 +++++------ api/v1beta2/awsmachine_webhook_test.go | 2 +- api/v1beta2/types.go | 8 ++++---- api/v1beta2/zz_generated.deepcopy.go | 20 +++++++++---------- ...ster.x-k8s.io_awsmanagedcontrolplanes.yaml | 10 ++++------ ...tructure.cluster.x-k8s.io_awsclusters.yaml | 5 ++--- ...ture.cluster.x-k8s.io_awsmachinepools.yaml | 5 ++--- ...tructure.cluster.x-k8s.io_awsmachines.yaml | 5 ++--- ....cluster.x-k8s.io_awsmachinetemplates.yaml | 6 +++--- ...uster.x-k8s.io_awsmanagedmachinepools.yaml | 5 ++--- exp/api/v1beta1/conversion.go | 8 ++++---- exp/api/v1beta1/zz_generated.conversion.go | 2 +- exp/api/v1beta2/types.go | 4 ++-- exp/api/v1beta2/zz_generated.deepcopy.go | 6 +++--- pkg/cloud/services/ec2/instances.go | 16 +++++++-------- pkg/cloud/services/ec2/launchtemplate.go | 14 ++++++------- 20 files changed, 68 insertions(+), 74 deletions(-) diff --git a/api/v1beta1/awscluster_conversion.go b/api/v1beta1/awscluster_conversion.go index 8e666e189e..b6c835fa3e 100644 --- a/api/v1beta1/awscluster_conversion.go +++ b/api/v1beta1/awscluster_conversion.go @@ -48,7 +48,7 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error { if restored.Status.Bastion != nil { dst.Status.Bastion.InstanceMetadataOptions = restored.Status.Bastion.InstanceMetadataOptions dst.Status.Bastion.PlacementGroupName = restored.Status.Bastion.PlacementGroupName - dst.Status.Bastion.PrivateDNSNameOptions = restored.Status.Bastion.PrivateDNSNameOptions + dst.Status.Bastion.PrivateDNSName = restored.Status.Bastion.PrivateDNSName } dst.Spec.Partition = restored.Spec.Partition diff --git a/api/v1beta1/awsmachine_conversion.go b/api/v1beta1/awsmachine_conversion.go index 275afd372b..92a22d5a59 100644 --- a/api/v1beta1/awsmachine_conversion.go +++ b/api/v1beta1/awsmachine_conversion.go @@ -38,7 +38,7 @@ func (src *AWSMachine) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Ignition = restored.Spec.Ignition dst.Spec.InstanceMetadataOptions = restored.Spec.InstanceMetadataOptions dst.Spec.PlacementGroupName = restored.Spec.PlacementGroupName - dst.Spec.PrivateDNSNameOptions = restored.Spec.PrivateDNSNameOptions + dst.Spec.PrivateDNSName = restored.Spec.PrivateDNSName return nil } @@ -86,7 +86,7 @@ func (r *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Template.Spec.Ignition = restored.Spec.Template.Spec.Ignition dst.Spec.Template.Spec.InstanceMetadataOptions = restored.Spec.Template.Spec.InstanceMetadataOptions dst.Spec.Template.Spec.PlacementGroupName = restored.Spec.Template.Spec.PlacementGroupName - dst.Spec.Template.Spec.PrivateDNSNameOptions = restored.Spec.Template.Spec.PrivateDNSNameOptions + dst.Spec.Template.Spec.PrivateDNSName = restored.Spec.Template.Spec.PrivateDNSName return nil } diff --git a/api/v1beta1/zz_generated.conversion.go b/api/v1beta1/zz_generated.conversion.go index 57cd1c576b..030941fb4f 100644 --- a/api/v1beta1/zz_generated.conversion.go +++ b/api/v1beta1/zz_generated.conversion.go @@ -1411,7 +1411,7 @@ func autoConvert_v1beta2_AWSMachineSpec_To_v1beta1_AWSMachineSpec(in *v1beta2.AW out.SpotMarketOptions = (*SpotMarketOptions)(unsafe.Pointer(in.SpotMarketOptions)) // WARNING: in.PlacementGroupName requires manual conversion: does not exist in peer-type out.Tenancy = in.Tenancy - // WARNING: in.PrivateDNSNameOptions requires manual conversion: does not exist in peer-type + // WARNING: in.PrivateDNSName requires manual conversion: does not exist in peer-type return nil } @@ -2011,7 +2011,7 @@ func autoConvert_v1beta2_Instance_To_v1beta1_Instance(in *v1beta2.Instance, out out.Tenancy = in.Tenancy out.VolumeIDs = *(*[]string)(unsafe.Pointer(&in.VolumeIDs)) // WARNING: in.InstanceMetadataOptions requires manual conversion: does not exist in peer-type - // WARNING: in.PrivateDNSNameOptions requires manual conversion: does not exist in peer-type + // WARNING: in.PrivateDNSName requires manual conversion: does not exist in peer-type return nil } diff --git a/api/v1beta2/awsmachine_types.go b/api/v1beta2/awsmachine_types.go index 802612792b..1929c79e4d 100644 --- a/api/v1beta2/awsmachine_types.go +++ b/api/v1beta2/awsmachine_types.go @@ -161,9 +161,9 @@ type AWSMachineSpec struct { // +kubebuilder:validation:Enum:=default;dedicated;host Tenancy string `json:"tenancy,omitempty"` - // PrivateDNSNameOptions is the options for the instance hostname. + // PrivateDNSName is the options for the instance hostname. // +optional - PrivateDNSNameOptions *PrivateDNSNameOptions `json:"privateDnsNameOptions,omitempty"` + PrivateDNSName *PrivateDNSName `json:"privateDnsName,omitempty"` } // CloudInit defines options related to the bootstrapping systems where diff --git a/api/v1beta2/awsmachine_webhook.go b/api/v1beta2/awsmachine_webhook.go index 965fed1805..2fe32083db 100644 --- a/api/v1beta2/awsmachine_webhook.go +++ b/api/v1beta2/awsmachine_webhook.go @@ -115,14 +115,14 @@ func (r *AWSMachine) ValidateUpdate(old runtime.Object) (admission.Warnings, err } // allow changes to enableResourceNameDNSAAAARecord and enableResourceNameDNSARecord - if privateDNSNameOptions, ok := oldAWSMachineSpec["privateDnsNameOptions"].(map[string]interface{}); ok { - delete(privateDNSNameOptions, "enableResourceNameDnsAAAARecord") - delete(privateDNSNameOptions, "enableResourceNameDnsARecord") + if privateDNSName, ok := oldAWSMachineSpec["privateDnsName"].(map[string]interface{}); ok { + delete(privateDNSName, "enableResourceNameDnsAAAARecord") + delete(privateDNSName, "enableResourceNameDnsARecord") } - if privateDNSNameOptions, ok := newAWSMachineSpec["privateDnsNameOptions"].(map[string]interface{}); ok { - delete(privateDNSNameOptions, "enableResourceNameDnsAAAARecord") - delete(privateDNSNameOptions, "enableResourceNameDnsARecord") + if privateDNSName, ok := newAWSMachineSpec["privateDnsName"].(map[string]interface{}); ok { + delete(privateDNSName, "enableResourceNameDnsAAAARecord") + delete(privateDNSName, "enableResourceNameDnsARecord") } if !cmp.Equal(oldAWSMachineSpec, newAWSMachineSpec) { diff --git a/api/v1beta2/awsmachine_webhook_test.go b/api/v1beta2/awsmachine_webhook_test.go index a9a0da34de..2ac1cb927f 100644 --- a/api/v1beta2/awsmachine_webhook_test.go +++ b/api/v1beta2/awsmachine_webhook_test.go @@ -325,7 +325,7 @@ func TestAWSMachineUpdate(t *testing.T) { ID: pointer.String("ID"), }, }, - PrivateDNSNameOptions: &PrivateDNSNameOptions{ + PrivateDNSName: &PrivateDNSName{ EnableResourceNameDNSAAAARecord: aws.Bool(true), EnableResourceNameDNSARecord: aws.Bool(true), }, diff --git a/api/v1beta2/types.go b/api/v1beta2/types.go index e06a01d557..545c4f320c 100644 --- a/api/v1beta2/types.go +++ b/api/v1beta2/types.go @@ -233,9 +233,9 @@ type Instance struct { // +optional InstanceMetadataOptions *InstanceMetadataOptions `json:"instanceMetadataOptions,omitempty"` - // PrivateDNSNameOptions is the options for the instance hostname. + // PrivateDNSName is the options for the instance hostname. // +optional - PrivateDNSNameOptions *PrivateDNSNameOptions `json:"privateDnsNameOptions,omitempty"` + PrivateDNSName *PrivateDNSName `json:"privateDnsName,omitempty"` } // InstanceMetadataState describes the state of InstanceMetadataOptions.HttpEndpoint and InstanceMetadataOptions.InstanceMetadataTags @@ -412,8 +412,8 @@ const ( AmazonLinuxGPU EKSAMILookupType = "AmazonLinuxGPU" ) -// PrivateDNSNameOptions is the options for the instance hostname. -type PrivateDNSNameOptions struct { +// PrivateDNSName is the options for the instance hostname. +type PrivateDNSName struct { // EnableResourceNameDNSAAAARecord indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. // +optional EnableResourceNameDNSAAAARecord *bool `json:"enableResourceNameDnsAAAARecord,omitempty"` diff --git a/api/v1beta2/zz_generated.deepcopy.go b/api/v1beta2/zz_generated.deepcopy.go index 3ce76f17c9..b33336be78 100644 --- a/api/v1beta2/zz_generated.deepcopy.go +++ b/api/v1beta2/zz_generated.deepcopy.go @@ -739,9 +739,9 @@ func (in *AWSMachineSpec) DeepCopyInto(out *AWSMachineSpec) { *out = new(SpotMarketOptions) (*in).DeepCopyInto(*out) } - if in.PrivateDNSNameOptions != nil { - in, out := &in.PrivateDNSNameOptions, &out.PrivateDNSNameOptions - *out = new(PrivateDNSNameOptions) + if in.PrivateDNSName != nil { + in, out := &in.PrivateDNSName, &out.PrivateDNSName + *out = new(PrivateDNSName) (*in).DeepCopyInto(*out) } } @@ -1471,9 +1471,9 @@ func (in *Instance) DeepCopyInto(out *Instance) { *out = new(InstanceMetadataOptions) **out = **in } - if in.PrivateDNSNameOptions != nil { - in, out := &in.PrivateDNSNameOptions, &out.PrivateDNSNameOptions - *out = new(PrivateDNSNameOptions) + if in.PrivateDNSName != nil { + in, out := &in.PrivateDNSName, &out.PrivateDNSName + *out = new(PrivateDNSName) (*in).DeepCopyInto(*out) } } @@ -1660,7 +1660,7 @@ func (in *NetworkStatus) DeepCopy() *NetworkStatus { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PrivateDNSNameOptions) DeepCopyInto(out *PrivateDNSNameOptions) { +func (in *PrivateDNSName) DeepCopyInto(out *PrivateDNSName) { *out = *in if in.EnableResourceNameDNSAAAARecord != nil { in, out := &in.EnableResourceNameDNSAAAARecord, &out.EnableResourceNameDNSAAAARecord @@ -1679,12 +1679,12 @@ func (in *PrivateDNSNameOptions) DeepCopyInto(out *PrivateDNSNameOptions) { } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PrivateDNSNameOptions. -func (in *PrivateDNSNameOptions) DeepCopy() *PrivateDNSNameOptions { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PrivateDNSName. +func (in *PrivateDNSName) DeepCopy() *PrivateDNSName { if in == nil { return nil } - out := new(PrivateDNSNameOptions) + out := new(PrivateDNSName) in.DeepCopyInto(out) return out } diff --git a/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml b/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml index 1aaae14960..2cb7194a4b 100644 --- a/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml +++ b/config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml @@ -1108,9 +1108,8 @@ spec: description: PlacementGroupName specifies the name of the placement group in which to launch the instance. type: string - privateDnsNameOptions: - description: PrivateDNSNameOptions is the options for the instance - hostname. + privateDnsName: + description: PrivateDNSName is the options for the instance hostname. properties: enableResourceNameDnsAAAARecord: description: EnableResourceNameDNSAAAARecord indicates whether @@ -2751,9 +2750,8 @@ spec: description: PlacementGroupName specifies the name of the placement group in which to launch the instance. type: string - privateDnsNameOptions: - description: PrivateDNSNameOptions is the options for the instance - hostname. + privateDnsName: + description: PrivateDNSName is the options for the instance hostname. properties: enableResourceNameDnsAAAARecord: description: EnableResourceNameDNSAAAARecord indicates whether diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml index 8726b507ab..8881fa7c42 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsclusters.yaml @@ -1699,9 +1699,8 @@ spec: description: PlacementGroupName specifies the name of the placement group in which to launch the instance. type: string - privateDnsNameOptions: - description: PrivateDNSNameOptions is the options for the instance - hostname. + privateDnsName: + description: PrivateDNSName is the options for the instance hostname. properties: enableResourceNameDnsAAAARecord: description: EnableResourceNameDNSAAAARecord indicates whether diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml index ed45bdc41d..12951073f8 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinepools.yaml @@ -690,9 +690,8 @@ spec: name: description: The name of the launch template. type: string - privateDnsNameOptions: - description: PrivateDNSNameOptions is the options for the instance - hostname. + privateDnsName: + description: PrivateDNSName is the options for the instance hostname. properties: enableResourceNameDnsAAAARecord: description: EnableResourceNameDNSAAAARecord indicates whether diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml index dbdc1a1f0e..07cf719676 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml @@ -780,9 +780,8 @@ spec: description: PlacementGroupName specifies the name of the placement group in which to launch the instance. type: string - privateDnsNameOptions: - description: PrivateDNSNameOptions is the options for the instance - hostname. + privateDnsName: + description: PrivateDNSName is the options for the instance hostname. properties: enableResourceNameDnsAAAARecord: description: EnableResourceNameDNSAAAARecord indicates whether diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml index 98ae2e1f06..c8b56bdb04 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml @@ -734,9 +734,9 @@ spec: description: PlacementGroupName specifies the name of the placement group in which to launch the instance. type: string - privateDnsNameOptions: - description: PrivateDNSNameOptions is the options for the - instance hostname. + privateDnsName: + description: PrivateDNSName is the options for the instance + hostname. properties: enableResourceNameDnsAAAARecord: description: EnableResourceNameDNSAAAARecord indicates diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmanagedmachinepools.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmanagedmachinepools.yaml index e109b1fd75..3f5dbcf447 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmanagedmachinepools.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmanagedmachinepools.yaml @@ -678,9 +678,8 @@ spec: name: description: The name of the launch template. type: string - privateDnsNameOptions: - description: PrivateDNSNameOptions is the options for the instance - hostname. + privateDnsName: + description: PrivateDNSName is the options for the instance hostname. properties: enableResourceNameDnsAAAARecord: description: EnableResourceNameDNSAAAARecord indicates whether diff --git a/exp/api/v1beta1/conversion.go b/exp/api/v1beta1/conversion.go index 4cc33bfe8d..91c852c1a2 100644 --- a/exp/api/v1beta1/conversion.go +++ b/exp/api/v1beta1/conversion.go @@ -51,8 +51,8 @@ func (src *AWSMachinePool) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.AvailabilityZoneSubnetType = restored.Spec.AvailabilityZoneSubnetType } - if restored.Spec.AWSLaunchTemplate.PrivateDNSNameOptions != nil { - dst.Spec.AWSLaunchTemplate.PrivateDNSNameOptions = restored.Spec.AWSLaunchTemplate.PrivateDNSNameOptions + if restored.Spec.AWSLaunchTemplate.PrivateDNSName != nil { + dst.Spec.AWSLaunchTemplate.PrivateDNSName = restored.Spec.AWSLaunchTemplate.PrivateDNSName } return nil @@ -100,8 +100,8 @@ func (src *AWSManagedMachinePool) ConvertTo(dstRaw conversion.Hub) error { } dst.Spec.AWSLaunchTemplate.InstanceMetadataOptions = restored.Spec.AWSLaunchTemplate.InstanceMetadataOptions - if restored.Spec.AWSLaunchTemplate.PrivateDNSNameOptions != nil { - dst.Spec.AWSLaunchTemplate.PrivateDNSNameOptions = restored.Spec.AWSLaunchTemplate.PrivateDNSNameOptions + if restored.Spec.AWSLaunchTemplate.PrivateDNSName != nil { + dst.Spec.AWSLaunchTemplate.PrivateDNSName = restored.Spec.AWSLaunchTemplate.PrivateDNSName } } if restored.Spec.AvailabilityZoneSubnetType != nil { diff --git a/exp/api/v1beta1/zz_generated.conversion.go b/exp/api/v1beta1/zz_generated.conversion.go index 77636c3ae1..bc26142ba4 100644 --- a/exp/api/v1beta1/zz_generated.conversion.go +++ b/exp/api/v1beta1/zz_generated.conversion.go @@ -407,7 +407,7 @@ func autoConvert_v1beta2_AWSLaunchTemplate_To_v1beta1_AWSLaunchTemplate(in *v1be out.AdditionalSecurityGroups = *(*[]apiv1beta2.AWSResourceReference)(unsafe.Pointer(&in.AdditionalSecurityGroups)) out.SpotMarketOptions = (*apiv1beta2.SpotMarketOptions)(unsafe.Pointer(in.SpotMarketOptions)) // WARNING: in.InstanceMetadataOptions requires manual conversion: does not exist in peer-type - // WARNING: in.PrivateDNSNameOptions requires manual conversion: does not exist in peer-type + // WARNING: in.PrivateDNSName requires manual conversion: does not exist in peer-type return nil } diff --git a/exp/api/v1beta2/types.go b/exp/api/v1beta2/types.go index 08f89b69e6..68e6b24876 100644 --- a/exp/api/v1beta2/types.go +++ b/exp/api/v1beta2/types.go @@ -121,9 +121,9 @@ type AWSLaunchTemplate struct { // +optional InstanceMetadataOptions *infrav1.InstanceMetadataOptions `json:"instanceMetadataOptions,omitempty"` - // PrivateDNSNameOptions is the options for the instance hostname. + // PrivateDNSName is the options for the instance hostname. // +optional - PrivateDNSNameOptions *infrav1.PrivateDNSNameOptions `json:"privateDnsNameOptions,omitempty"` + PrivateDNSName *infrav1.PrivateDNSName `json:"privateDnsName,omitempty"` } // Overrides are used to override the instance type specified by the launch template with multiple diff --git a/exp/api/v1beta2/zz_generated.deepcopy.go b/exp/api/v1beta2/zz_generated.deepcopy.go index 4b8b59b193..f34aac1f6d 100644 --- a/exp/api/v1beta2/zz_generated.deepcopy.go +++ b/exp/api/v1beta2/zz_generated.deepcopy.go @@ -123,9 +123,9 @@ func (in *AWSLaunchTemplate) DeepCopyInto(out *AWSLaunchTemplate) { *out = new(apiv1beta2.InstanceMetadataOptions) **out = **in } - if in.PrivateDNSNameOptions != nil { - in, out := &in.PrivateDNSNameOptions, &out.PrivateDNSNameOptions - *out = new(apiv1beta2.PrivateDNSNameOptions) + if in.PrivateDNSName != nil { + in, out := &in.PrivateDNSName, &out.PrivateDNSName + *out = new(apiv1beta2.PrivateDNSName) (*in).DeepCopyInto(*out) } } diff --git a/pkg/cloud/services/ec2/instances.go b/pkg/cloud/services/ec2/instances.go index b2c060ce6c..1091c9463c 100644 --- a/pkg/cloud/services/ec2/instances.go +++ b/pkg/cloud/services/ec2/instances.go @@ -238,7 +238,7 @@ func (s *Service) CreateInstance(scope *scope.MachineScope, userData []byte, use input.PlacementGroupName = scope.AWSMachine.Spec.PlacementGroupName - input.PrivateDNSNameOptions = scope.AWSMachine.Spec.PrivateDNSNameOptions + input.PrivateDNSName = scope.AWSMachine.Spec.PrivateDNSName s.scope.Debug("Running instance", "machine-role", scope.Role()) s.scope.Debug("Running instance with instance metadata options", "metadata options", input.InstanceMetadataOptions) @@ -597,7 +597,7 @@ func (s *Service) runInstance(role string, i *infrav1.Instance) (*infrav1.Instan input.InstanceMarketOptions = getInstanceMarketOptionsRequest(i.SpotMarketOptions) input.MetadataOptions = getInstanceMetadataOptionsRequest(i.InstanceMetadataOptions) - input.PrivateDnsNameOptions = getPrivateDNSNameOptionsRequest(i.PrivateDNSNameOptions) + input.PrivateDnsNameOptions = getPrivateDNSNameOptionsRequest(i.PrivateDNSName) if i.Tenancy != "" { input.Placement = &ec2.Placement{ @@ -869,7 +869,7 @@ func (s *Service) SDKToInstance(v *ec2.Instance) (*infrav1.Instance, error) { } if v.PrivateDnsNameOptions != nil { - i.PrivateDNSNameOptions = &infrav1.PrivateDNSNameOptions{ + i.PrivateDNSName = &infrav1.PrivateDNSName{ EnableResourceNameDNSAAAARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsAAAARecord, EnableResourceNameDNSARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsARecord, HostnameType: v.PrivateDnsNameOptions.HostnameType, @@ -1065,14 +1065,14 @@ func getInstanceMetadataOptionsRequest(metadataOptions *infrav1.InstanceMetadata return request } -func getPrivateDNSNameOptionsRequest(privateDNSNameOptions *infrav1.PrivateDNSNameOptions) *ec2.PrivateDnsNameOptionsRequest { - if privateDNSNameOptions == nil { +func getPrivateDNSNameOptionsRequest(privateDNSName *infrav1.PrivateDNSName) *ec2.PrivateDnsNameOptionsRequest { + if privateDNSName == nil { return nil } return &ec2.PrivateDnsNameOptionsRequest{ - EnableResourceNameDnsAAAARecord: privateDNSNameOptions.EnableResourceNameDNSAAAARecord, - EnableResourceNameDnsARecord: privateDNSNameOptions.EnableResourceNameDNSARecord, - HostnameType: privateDNSNameOptions.HostnameType, + EnableResourceNameDnsAAAARecord: privateDNSName.EnableResourceNameDNSAAAARecord, + EnableResourceNameDnsARecord: privateDNSName.EnableResourceNameDNSARecord, + HostnameType: privateDNSName.HostnameType, } } diff --git a/pkg/cloud/services/ec2/launchtemplate.go b/pkg/cloud/services/ec2/launchtemplate.go index 5acc6b9864..190f80c724 100644 --- a/pkg/cloud/services/ec2/launchtemplate.go +++ b/pkg/cloud/services/ec2/launchtemplate.go @@ -498,7 +498,7 @@ func (s *Service) createLaunchTemplateData(scope scope.LaunchTemplateScope, imag data.ImageId = imageID data.InstanceMarketOptions = getLaunchTemplateInstanceMarketOptionsRequest(scope.GetLaunchTemplate().SpotMarketOptions) - data.PrivateDnsNameOptions = getLaunchTemplatePrivateDNSNameOptionsRequest(scope.GetLaunchTemplate().PrivateDNSNameOptions) + data.PrivateDnsNameOptions = getLaunchTemplatePrivateDNSNameOptionsRequest(scope.GetLaunchTemplate().PrivateDNSName) // Set up root volume if lt.RootVolume != nil { @@ -671,7 +671,7 @@ func (s *Service) SDKToLaunchTemplate(d *ec2.LaunchTemplateVersion) (*expinfrav1 } if v.PrivateDnsNameOptions != nil { - i.PrivateDNSNameOptions = &infrav1.PrivateDNSNameOptions{ + i.PrivateDNSName = &infrav1.PrivateDNSName{ EnableResourceNameDNSAAAARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsAAAARecord, EnableResourceNameDNSARecord: v.PrivateDnsNameOptions.EnableResourceNameDnsARecord, HostnameType: v.PrivateDnsNameOptions.HostnameType, @@ -924,14 +924,14 @@ func getLaunchTemplateInstanceMarketOptionsRequest(spotMarketOptions *infrav1.Sp return launchTemplateInstanceMarketOptionsRequest } -func getLaunchTemplatePrivateDNSNameOptionsRequest(privateDNSNameOptions *infrav1.PrivateDNSNameOptions) *ec2.LaunchTemplatePrivateDnsNameOptionsRequest { - if privateDNSNameOptions == nil { +func getLaunchTemplatePrivateDNSNameOptionsRequest(privateDNSName *infrav1.PrivateDNSName) *ec2.LaunchTemplatePrivateDnsNameOptionsRequest { + if privateDNSName == nil { return nil } return &ec2.LaunchTemplatePrivateDnsNameOptionsRequest{ - EnableResourceNameDnsAAAARecord: privateDNSNameOptions.EnableResourceNameDNSAAAARecord, - EnableResourceNameDnsARecord: privateDNSNameOptions.EnableResourceNameDNSARecord, - HostnameType: privateDNSNameOptions.HostnameType, + EnableResourceNameDnsAAAARecord: privateDNSName.EnableResourceNameDNSAAAARecord, + EnableResourceNameDnsARecord: privateDNSName.EnableResourceNameDNSARecord, + HostnameType: privateDNSName.HostnameType, } }