Skip to content

Commit

Permalink
Add resource references to cluster names (#17)
Browse files Browse the repository at this point in the history
Description of changes:
Add resource references to each of the custom resources to replace `ClusterName`. I have tested these changes manually and, while they work, are currently sub-optimal.

The generated code currently does not check for the `ResourceSynced` condition to be `true` before resolving the reference. Therefore, since all of these resources reference the cluster spec field, they immediately resolve. As a result, the resources immediately attempt to create - even though the cluster is still in `CREATING` status. Once aws-controllers-k8s/community#1064 is properly implemented, and the code gating the `ResourceSynced` status is enabled, these resources should work flawlessly. 

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.
  • Loading branch information
RedbackThomson authored Jan 12, 2022
1 parent dd817be commit a8e1ec0
Show file tree
Hide file tree
Showing 19 changed files with 394 additions and 22 deletions.
8 changes: 4 additions & 4 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: "2022-01-09T00:30:18Z"
build_hash: 3e184727de8a4dfd4769e3d88f4f52f885858335
build_date: "2022-01-12T20:00:52Z"
build_hash: b24c062600f1ae90d62e760c23e69651ac167a24
go_version: go1.17.1
version: v0.16.0
api_directory_checksum: 18423a5aa90c547e267c460f25ce08e5c0b4aaa6
api_directory_checksum: aca79dadb322fdb182185a7e9b9cb44e14b30d0a
api_version: v1alpha1
aws_sdk_go_version: v1.38.67
generator_config_info:
file_checksum: b66d077bc28c12a65378f3eb515c5ab814a93090
file_checksum: 794a511b629b00b81bfe943eaf41eedf7c780ff7
original_file_name: generator.yaml
last_modification:
reason: API generation
4 changes: 2 additions & 2 deletions apis/v1alpha1/addon.go

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

4 changes: 2 additions & 2 deletions apis/v1alpha1/fargate_profile.go

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

15 changes: 15 additions & 0 deletions apis/v1alpha1/generator.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
resources:
Addon:
fields:
ClusterName:
references:
resource: Cluster
path: Spec.Name
renames:
operations:
CreateAddon:
Expand Down Expand Up @@ -58,6 +63,11 @@ resources:
update_operation:
custom_method_name: customUpdate
FargateProfile:
fields:
ClusterName:
references:
resource: Cluster
path: Spec.Name
renames:
operations:
CreateFargateProfile:
Expand Down Expand Up @@ -87,6 +97,11 @@ resources:
- MissingParameter
- ValidationError
Nodegroup:
fields:
ClusterName:
references:
resource: Cluster
path: Spec.Name
renames:
operations:
CreateNodegroup:
Expand Down
4 changes: 2 additions & 2 deletions apis/v1alpha1/nodegroup.go

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

15 changes: 15 additions & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

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

15 changes: 14 additions & 1 deletion config/crd/bases/eks.services.k8s.aws_addons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ spec:
clusterName:
description: The name of the cluster to create the add-on for.
type: string
clusterNameRef:
description: 'AWSResourceReferenceWrapper provides a wrapper around
*AWSResourceReference type to provide more user friendly syntax
for references using ''from'' field Ex: APIIDRef: from: name:
my-api'
properties:
from:
description: AWSResourceReference provides all the values necessary
to reference another k8s resource for finding the identifier(Id/ARN/Name)
properties:
name:
type: string
type: object
type: object
name:
description: The name of the add-on. The name must match one of the
names returned by ListAddons (https://docs.aws.amazon.com/eks/latest/APIReference/API_ListAddons.html).
Expand Down Expand Up @@ -77,7 +91,6 @@ spec:
both of which you define.
type: object
required:
- clusterName
- name
type: object
status:
Expand Down
15 changes: 14 additions & 1 deletion config/crd/bases/eks.services.k8s.aws_fargateprofiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ spec:
description: The name of the Amazon EKS cluster to apply the Fargate
profile to.
type: string
clusterNameRef:
description: 'AWSResourceReferenceWrapper provides a wrapper around
*AWSResourceReference type to provide more user friendly syntax
for references using ''from'' field Ex: APIIDRef: from: name:
my-api'
properties:
from:
description: AWSResourceReference provides all the values necessary
to reference another k8s resource for finding the identifier(Id/ARN/Name)
properties:
name:
type: string
type: object
type: object
name:
description: The name of the Fargate profile.
type: string
Expand Down Expand Up @@ -91,7 +105,6 @@ spec:
Fargate profile, such as the pods that are scheduled with it.
type: object
required:
- clusterName
- name
- podExecutionRoleARN
type: object
Expand Down
15 changes: 14 additions & 1 deletion config/crd/bases/eks.services.k8s.aws_nodegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ spec:
clusterName:
description: The name of the cluster to create the node group in.
type: string
clusterNameRef:
description: 'AWSResourceReferenceWrapper provides a wrapper around
*AWSResourceReference type to provide more user friendly syntax
for references using ''from'' field Ex: APIIDRef: from: name:
my-api'
properties:
from:
description: AWSResourceReference provides all the values necessary
to reference another k8s resource for finding the identifier(Id/ARN/Name)
properties:
name:
type: string
type: object
type: object
diskSize:
description: The root device disk size (in GiB) for your node group
instances. The default disk size is 20 GiB. If you specify launchTemplate,
Expand Down Expand Up @@ -217,7 +231,6 @@ spec:
in the Amazon EKS User Guide.
type: string
required:
- clusterName
- name
- nodeRole
- subnets
Expand Down
15 changes: 15 additions & 0 deletions generator.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
resources:
Addon:
fields:
ClusterName:
references:
resource: Cluster
path: Spec.Name
renames:
operations:
CreateAddon:
Expand Down Expand Up @@ -58,6 +63,11 @@ resources:
update_operation:
custom_method_name: customUpdate
FargateProfile:
fields:
ClusterName:
references:
resource: Cluster
path: Spec.Name
renames:
operations:
CreateFargateProfile:
Expand Down Expand Up @@ -87,6 +97,11 @@ resources:
- MissingParameter
- ValidationError
Nodegroup:
fields:
ClusterName:
references:
resource: Cluster
path: Spec.Name
renames:
operations:
CreateNodegroup:
Expand Down
15 changes: 14 additions & 1 deletion helm/crds/eks.services.k8s.aws_addons.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ spec:
clusterName:
description: The name of the cluster to create the add-on for.
type: string
clusterNameRef:
description: 'AWSResourceReferenceWrapper provides a wrapper around
*AWSResourceReference type to provide more user friendly syntax
for references using ''from'' field Ex: APIIDRef: from: name:
my-api'
properties:
from:
description: AWSResourceReference provides all the values necessary
to reference another k8s resource for finding the identifier(Id/ARN/Name)
properties:
name:
type: string
type: object
type: object
name:
description: The name of the add-on. The name must match one of the
names returned by ListAddons (https://docs.aws.amazon.com/eks/latest/APIReference/API_ListAddons.html).
Expand Down Expand Up @@ -77,7 +91,6 @@ spec:
both of which you define.
type: object
required:
- clusterName
- name
type: object
status:
Expand Down
15 changes: 14 additions & 1 deletion helm/crds/eks.services.k8s.aws_fargateprofiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ spec:
description: The name of the Amazon EKS cluster to apply the Fargate
profile to.
type: string
clusterNameRef:
description: 'AWSResourceReferenceWrapper provides a wrapper around
*AWSResourceReference type to provide more user friendly syntax
for references using ''from'' field Ex: APIIDRef: from: name:
my-api'
properties:
from:
description: AWSResourceReference provides all the values necessary
to reference another k8s resource for finding the identifier(Id/ARN/Name)
properties:
name:
type: string
type: object
type: object
name:
description: The name of the Fargate profile.
type: string
Expand Down Expand Up @@ -91,7 +105,6 @@ spec:
Fargate profile, such as the pods that are scheduled with it.
type: object
required:
- clusterName
- name
- podExecutionRoleARN
type: object
Expand Down
15 changes: 14 additions & 1 deletion helm/crds/eks.services.k8s.aws_nodegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ spec:
clusterName:
description: The name of the cluster to create the node group in.
type: string
clusterNameRef:
description: 'AWSResourceReferenceWrapper provides a wrapper around
*AWSResourceReference type to provide more user friendly syntax
for references using ''from'' field Ex: APIIDRef: from: name:
my-api'
properties:
from:
description: AWSResourceReference provides all the values necessary
to reference another k8s resource for finding the identifier(Id/ARN/Name)
properties:
name:
type: string
type: object
type: object
diskSize:
description: The root device disk size (in GiB) for your node group
instances. The default disk size is 20 GiB. If you specify launchTemplate,
Expand Down Expand Up @@ -217,7 +231,6 @@ spec:
in the Amazon EKS User Guide.
type: string
required:
- clusterName
- name
- nodeRole
- subnets
Expand Down
3 changes: 3 additions & 0 deletions pkg/resource/addon/delta.go

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

Loading

0 comments on commit a8e1ec0

Please sign in to comment.