Skip to content

Commit

Permalink
Add RecordSet support for route53 controller (#31)
Browse files Browse the repository at this point in the history
**Issue**: 
aws-controllers-k8s/community#1545 

**Description of changes**:
Adds support for RecordSets in Route53 and corresponding E2E tests. This includes support for all record types and routing policies.

Some previous conversations for how to implement this were discussed here:
- https://kubernetes.slack.com/archives/C0402D8JJS1/p1694054604699869
- https://kubernetes.slack.com/archives/C0402D8JJS1/p1695030078194489

Changes made to following files/directories (other changes are all code-gen'ed):
- generator.yaml
- pkg/resource/record_set/hooks.go
- templates/hooks/record_set/
- test/e2e/

Generator results:
```
make build-controller SERVICE=route53
building ack-generate ... ok.
==== building route53-controller ====
Copying common custom resource definitions into route53
Building Kubernetes API objects for route53
Generating deepcopy code for route53
Generating custom resource definitions for route53
Building service controller for route53
Generating RBAC manifests for route53
Running gofmt against generated code for route53
Updating additional GitHub repository maintenance files
==== building route53-controller release artifacts ====
Building release artifacts for route53-v0.0.8
Generating common custom resource definitions
Generating custom resource definitions for route53
Generating RBAC manifests for route53
```

E2E results:
```
[gw1] [ 25%] PASSED tests/test_hosted_zone.py::TestHostedZone::test_create_delete_private
[gw0] [ 50%] PASSED tests/test_hosted_zone.py::TestHostedZone::test_create_delete_public
[gw2] [ 75%] PASSED tests/test_hosted_zone.py::TestHostedZone::test_crud_tags
[gw4] [100%] PASSED tests/test_record_set.py::TestRecordSet::test_crud_simple_record
```

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • Loading branch information
kunhwiko authored Dec 14, 2023
1 parent 92a9e8b commit bfd9a0a
Show file tree
Hide file tree
Showing 36 changed files with 5,224 additions and 89 deletions.
10 changes: 5 additions & 5 deletions apis/v1alpha1/ack-generate-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ack_generate_info:
build_date: "2023-09-14T23:39:01Z"
build_hash: 892f29d00a4c4ad21a2fa32919921de18190979d
build_date: "2023-11-08T12:14:15Z"
build_hash: 5237888d7dc7edb63fc1b36da5c49e3f258cc45d
go_version: go1.21.0
version: v0.27.1
api_directory_checksum: 2f681761d3417cd3c65709b6dc71d9853bdf0481
version: v0.27.1-4-g5237888
api_directory_checksum: 5a419e4b3bdc623d981b9ee5d0ef847bd4dc0bba
api_version: v1alpha1
aws_sdk_go_version: v1.44.93
generator_config_info:
file_checksum: e4f89494b4e355fb756095b55c95050a23efa0b3
file_checksum: 3120a47920b44a81bac54b6e49261a4592315002
original_file_name: generator.yaml
last_modification:
reason: API generation
120 changes: 119 additions & 1 deletion apis/v1alpha1/generator.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ignore:
field_paths:
- ChangeResourceRecordSetsOutput.ChangeInfo.Comment
- CreateHostedZoneInput.CallerReference
operations: null
resource_names:
Expand All @@ -17,12 +18,130 @@ ignore:
shape_names: null
model_name: route53
operations:
ChangeResourceRecordSets:
operation_type:
- Create
- Delete
resource_name:
RecordSet
ListResourceRecordSets:
operation_type:
- List
resource_name:
RecordSet
CreateHostedZone:
output_wrapper_field_path: HostedZone
GetHostedZone:
output_wrapper_field_path: HostedZone
prefix_config: {}
resources:
RecordSet:
exceptions:
terminal_codes:
- InvalidChangeBatch
- InvalidInput
- NoSuchHostedZone
- NoSuchHealthCheck
fields:
AliasTarget:
from:
operation: ChangeResourceRecordSets
path: ChangeBatch.Changes.ResourceRecordSet.AliasTarget
# This field cannot be ignored, but values for this will be overriden and should not be used
ChangeBatch:
is_required: false
CidrRoutingConfig:
from:
operation: ChangeResourceRecordSets
path: ChangeBatch.Changes.ResourceRecordSet.CidrRoutingConfig
Failover:
from:
operation: ChangeResourceRecordSets
path: ChangeBatch.Changes.ResourceRecordSet.Failover
GeoLocation:
from:
operation: ChangeResourceRecordSets
path: ChangeBatch.Changes.ResourceRecordSet.GeoLocation
HealthCheckId:
from:
operation: ChangeResourceRecordSets
path: ChangeBatch.Changes.ResourceRecordSet.HealthCheckId
# Changing this value after a CR has been created could result in orphaned record sets
HostedZoneId:
references:
resource: HostedZone
path: Status.ID
is_required: true
is_immutable: true
ID:
is_primary_key: true
documentation: "ID represents the ChangeID that is returned after a successful
ChangeResourceRecordSet request"
MultiValueAnswer:
from:
operation: ChangeResourceRecordSets
path: ChangeBatch.Changes.ResourceRecordSet.MultiValueAnswer
# Changing this value after a CR has been created could result in orphaned record sets.
# Note that the name refers to the subdomain value of a record set and not the fully
# qualified DNS name
Name:
from:
operation: ChangeResourceRecordSets
path: ChangeBatch.Changes.ResourceRecordSet.Name
is_immutable: true
# Changing this value after a CR has been created could result in orphaned record sets
RecordType:
from:
operation: ChangeResourceRecordSets
path: ChangeBatch.Changes.ResourceRecordSet.Type
is_required: true
is_immutable: true
Region:
from:
operation: ChangeResourceRecordSets
path: ChangeBatch.Changes.ResourceRecordSet.Region
ResourceRecords:
from:
operation: ChangeResourceRecordSets
path: ChangeBatch.Changes.ResourceRecordSet.ResourceRecords
# Changing this value after a CR has been created could result in orphaned record sets
SetIdentifier:
from:
operation: ChangeResourceRecordSets
path: ChangeBatch.Changes.ResourceRecordSet.SetIdentifier
is_immutable: true
Status:
print:
name: STATUS
TTL:
from:
operation: ChangeResourceRecordSets
path: ChangeBatch.Changes.ResourceRecordSet.TTL
Weight:
from:
operation: ChangeResourceRecordSets
path: ChangeBatch.Changes.ResourceRecordSet.Weight
hooks:
sdk_create_post_build_request:
template_path: hooks/record_set/sdk_create_post_build_request.go.tpl
sdk_delete_post_build_request:
template_path: hooks/record_set/sdk_delete_post_build_request.go.tpl
sdk_read_many_post_build_request:
template_path: hooks/record_set/sdk_read_many_post_build_request.go.tpl
sdk_read_many_pre_set_output:
template_path: hooks/record_set/sdk_read_many_pre_set_output.go.tpl
sdk_read_many_post_set_output:
template_path: hooks/record_set/sdk_read_many_post_set_output.go.tpl
list_operation:
match_fields:
- HostedZoneId
- Name
- SetIdentifier
# This resource does not have tags
tags:
ignore: true
update_operation:
custom_method_name: customUpdateRecordSet
HostedZone:
exceptions:
terminal_codes:
Expand Down Expand Up @@ -50,7 +169,6 @@ resources:
template_path: hooks/hosted_zone/sdk_file_end.go.tpl
ensure_tags:
template_path: hooks/hosted_zone/sdk_ensure_tags.go.tpl

tags:
ignore: true
update_operation:
Expand Down
Loading

0 comments on commit bfd9a0a

Please sign in to comment.