Skip to content

Commit 2eed587

Browse files
committed
support setting dnsNameOptions
1 parent 3618d1c commit 2eed587

21 files changed

+375
-5
lines changed

api/v1beta1/zz_generated.conversion.go

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

api/v1beta2/awsmachine_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ type AWSMachineSpec struct {
160160
// +optional
161161
// +kubebuilder:validation:Enum:=default;dedicated;host
162162
Tenancy string `json:"tenancy,omitempty"`
163+
164+
// PrivateDnsNameOptions is the options for the instance hostname.
165+
// +optional
166+
PrivateDnsNameOptions *PrivateDnsNameOptions `json:"privateDnsNameOptions,omitempty"`
163167
}
164168

165169
// CloudInit defines options related to the bootstrapping systems where

api/v1beta2/awsmachine_webhook.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ func (r *AWSMachine) ValidateUpdate(old runtime.Object) (admission.Warnings, err
114114
delete(cloudInit, "secureSecretsBackend")
115115
}
116116

117+
// allow changes to enableResourceNameDnsAAAARecord and enableResourceNameDnsARecord
118+
if privateDnsNameOptions, ok := oldAWSMachineSpec["privateDnsNameOptions"].(map[string]interface{}); ok {
119+
delete(privateDnsNameOptions, "enableResourceNameDnsAAAARecord")
120+
delete(privateDnsNameOptions, "enableResourceNameDnsARecord")
121+
}
122+
123+
if privateDnsNameOptions, ok := newAWSMachineSpec["privateDnsNameOptions"].(map[string]interface{}); ok {
124+
delete(privateDnsNameOptions, "enableResourceNameDnsAAAARecord")
125+
delete(privateDnsNameOptions, "enableResourceNameDnsARecord")
126+
}
127+
117128
if !cmp.Equal(oldAWSMachineSpec, newAWSMachineSpec) {
118129
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec"), "cannot be modified"))
119130
}

api/v1beta2/awsmachine_webhook_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func TestAWSMachineUpdate(t *testing.T) {
273273
wantErr bool
274274
}{
275275
{
276-
name: "change in providerid, cloudinit, tags and securitygroups",
276+
name: "change in providerid, cloudinit, tags, securitygroups and privateDnsNameOptions",
277277
oldMachine: &AWSMachine{
278278
Spec: AWSMachineSpec{
279279
ProviderID: nil,
@@ -298,6 +298,10 @@ func TestAWSMachineUpdate(t *testing.T) {
298298
SecretPrefix: "test",
299299
SecretCount: 5,
300300
},
301+
PrivateDnsNameOptions: &PrivateDnsNameOptions{
302+
EnableResourceNameDnsAAAARecord: aws.Bool(true),
303+
EnableResourceNameDnsARecord: aws.Bool(true),
304+
},
301305
},
302306
},
303307
wantErr: false,

api/v1beta2/network_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,13 @@ type VPCSpec struct {
335335
//
336336
// +optional
337337
EmptyRoutesDefaultVPCSecurityGroup bool `json:"emptyRoutesDefaultVPCSecurityGroup,omitempty"`
338+
339+
// PrivateDnsHostnameTypeOnLaunch is the type of hostname to assign to instances in the subnet at launch.
340+
// For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an instance DNS name can be based on the instance IPv4 address (ip-name)
341+
// or the instance ID (resource-name). For IPv6 only subnets, an instance DNS name must be based on the instance ID (resource-name).
342+
// +optional
343+
// +kubebuilder:validation:Enum:=ip-name;resource-name
344+
PrivateDnsHostnameTypeOnLaunch *string `json:"privateDnsHostnameTypeOnLaunch,omitempty"`
338345
}
339346

340347
// String returns a string representation of the VPC.

api/v1beta2/types.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ type Instance struct {
232232
// InstanceMetadataOptions is the metadata options for the EC2 instance.
233233
// +optional
234234
InstanceMetadataOptions *InstanceMetadataOptions `json:"instanceMetadataOptions,omitempty"`
235+
236+
// PrivateDnsNameOptions is the options for the instance hostname.
237+
// +optional
238+
PrivateDnsNameOptions *PrivateDnsNameOptions `json:"privateDnsNameOptions,omitempty"`
235239
}
236240

237241
// InstanceMetadataState describes the state of InstanceMetadataOptions.HttpEndpoint and InstanceMetadataOptions.InstanceMetadataTags
@@ -407,3 +411,17 @@ const (
407411
// AmazonLinuxGPU is the AmazonLinux GPU AMI type.
408412
AmazonLinuxGPU EKSAMILookupType = "AmazonLinuxGPU"
409413
)
414+
415+
// PrivateDnsNameOptions is the options for the instance hostname.
416+
type PrivateDnsNameOptions struct {
417+
// EnableResourceNameDnsAAAARecord indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records.
418+
// +optional
419+
EnableResourceNameDnsAAAARecord *bool `json:"enableResourceNameDnsAAAARecord,omitempty"`
420+
// EnableResourceNameDnsARecord indicates whether to respond to DNS queries for instance hostnames with DNS A records.
421+
// +optional
422+
EnableResourceNameDnsARecord *bool `json:"enableResourceNameDnsARecord,omitempty"`
423+
// The type of hostname to assign to an instance.
424+
// +optional
425+
// +kubebuilder:validation:Enum:=ip-name;resource-name
426+
HostnameType *string `json:"hostnameType,omitempty"`
427+
}

api/v1beta2/zz_generated.deepcopy.go

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

config/crd/bases/controlplane.cluster.x-k8s.io_awsmanagedcontrolplanes.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,18 @@ spec:
647647
is set. Mutually exclusive with IPAMPool.
648648
type: string
649649
type: object
650+
privateDnsHostnameTypeOnLaunch:
651+
description: PrivateDnsHostnameTypeOnLaunch is the type of
652+
hostname to assign to instances in the subnet at launch.
653+
For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an
654+
instance DNS name can be based on the instance IPv4 address
655+
(ip-name) or the instance ID (resource-name). For IPv6 only
656+
subnets, an instance DNS name must be based on the instance
657+
ID (resource-name).
658+
enum:
659+
- ip-name
660+
- resource-name
661+
type: string
650662
tags:
651663
additionalProperties:
652664
type: string
@@ -1096,6 +1108,27 @@ spec:
10961108
description: PlacementGroupName specifies the name of the placement
10971109
group in which to launch the instance.
10981110
type: string
1111+
privateDnsNameOptions:
1112+
description: PrivateDnsNameOptions is the options for the instance
1113+
hostname.
1114+
properties:
1115+
enableResourceNameDnsAAAARecord:
1116+
description: EnableResourceNameDnsAAAARecord indicates whether
1117+
to respond to DNS queries for instance hostnames with DNS
1118+
AAAA records.
1119+
type: boolean
1120+
enableResourceNameDnsARecord:
1121+
description: EnableResourceNameDnsARecord indicates whether
1122+
to respond to DNS queries for instance hostnames with DNS
1123+
A records.
1124+
type: boolean
1125+
hostnameType:
1126+
description: The type of hostname to assign to an instance.
1127+
enum:
1128+
- ip-name
1129+
- resource-name
1130+
type: string
1131+
type: object
10991132
privateIp:
11001133
description: The private IPv4 address assigned to the instance.
11011134
type: string
@@ -2244,6 +2277,18 @@ spec:
22442277
is set. Mutually exclusive with IPAMPool.
22452278
type: string
22462279
type: object
2280+
privateDnsHostnameTypeOnLaunch:
2281+
description: PrivateDnsHostnameTypeOnLaunch is the type of
2282+
hostname to assign to instances in the subnet at launch.
2283+
For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an
2284+
instance DNS name can be based on the instance IPv4 address
2285+
(ip-name) or the instance ID (resource-name). For IPv6 only
2286+
subnets, an instance DNS name must be based on the instance
2287+
ID (resource-name).
2288+
enum:
2289+
- ip-name
2290+
- resource-name
2291+
type: string
22472292
tags:
22482293
additionalProperties:
22492294
type: string
@@ -2706,6 +2751,27 @@ spec:
27062751
description: PlacementGroupName specifies the name of the placement
27072752
group in which to launch the instance.
27082753
type: string
2754+
privateDnsNameOptions:
2755+
description: PrivateDnsNameOptions is the options for the instance
2756+
hostname.
2757+
properties:
2758+
enableResourceNameDnsAAAARecord:
2759+
description: EnableResourceNameDnsAAAARecord indicates whether
2760+
to respond to DNS queries for instance hostnames with DNS
2761+
AAAA records.
2762+
type: boolean
2763+
enableResourceNameDnsARecord:
2764+
description: EnableResourceNameDnsARecord indicates whether
2765+
to respond to DNS queries for instance hostnames with DNS
2766+
A records.
2767+
type: boolean
2768+
hostnameType:
2769+
description: The type of hostname to assign to an instance.
2770+
enum:
2771+
- ip-name
2772+
- resource-name
2773+
type: string
2774+
type: object
27092775
privateIp:
27102776
description: The private IPv4 address assigned to the instance.
27112777
type: string

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,18 @@ spec:
14791479
is set. Mutually exclusive with IPAMPool.
14801480
type: string
14811481
type: object
1482+
privateDnsHostnameTypeOnLaunch:
1483+
description: PrivateDnsHostnameTypeOnLaunch is the type of
1484+
hostname to assign to instances in the subnet at launch.
1485+
For IPv4-only and dual-stack (IPv4 and IPv6) subnets, an
1486+
instance DNS name can be based on the instance IPv4 address
1487+
(ip-name) or the instance ID (resource-name). For IPv6 only
1488+
subnets, an instance DNS name must be based on the instance
1489+
ID (resource-name).
1490+
enum:
1491+
- ip-name
1492+
- resource-name
1493+
type: string
14821494
tags:
14831495
additionalProperties:
14841496
type: string
@@ -1687,6 +1699,27 @@ spec:
16871699
description: PlacementGroupName specifies the name of the placement
16881700
group in which to launch the instance.
16891701
type: string
1702+
privateDnsNameOptions:
1703+
description: PrivateDnsNameOptions is the options for the instance
1704+
hostname.
1705+
properties:
1706+
enableResourceNameDnsAAAARecord:
1707+
description: EnableResourceNameDnsAAAARecord indicates whether
1708+
to respond to DNS queries for instance hostnames with DNS
1709+
AAAA records.
1710+
type: boolean
1711+
enableResourceNameDnsARecord:
1712+
description: EnableResourceNameDnsARecord indicates whether
1713+
to respond to DNS queries for instance hostnames with DNS
1714+
A records.
1715+
type: boolean
1716+
hostnameType:
1717+
description: The type of hostname to assign to an instance.
1718+
enum:
1719+
- ip-name
1720+
- resource-name
1721+
type: string
1722+
type: object
16901723
privateIp:
16911724
description: The private IPv4 address assigned to the instance.
16921725
type: string

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,18 @@ spec:
10981098
with IPAMPool.
10991099
type: string
11001100
type: object
1101+
privateDnsHostnameTypeOnLaunch:
1102+
description: PrivateDnsHostnameTypeOnLaunch is the
1103+
type of hostname to assign to instances in the subnet
1104+
at launch. For IPv4-only and dual-stack (IPv4 and
1105+
IPv6) subnets, an instance DNS name can be based
1106+
on the instance IPv4 address (ip-name) or the instance
1107+
ID (resource-name). For IPv6 only subnets, an instance
1108+
DNS name must be based on the instance ID (resource-name).
1109+
enum:
1110+
- ip-name
1111+
- resource-name
1112+
type: string
11011113
tags:
11021114
additionalProperties:
11031115
type: string

0 commit comments

Comments
 (0)