-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AWS EC2 instances #777
Add AWS EC2 instances #777
Conversation
This is very much still a WIP. FWIW, I started from the vpc resource which is where you'll see a number references to vpc in the comments. |
Alrighty, I think I got to a point where it would be good to understand what the community's desired outcome is. BackgroundAs @muvaf called out in #85 (comment), the AWS SDK API defines a While manually implementing the API, most of it seems pretty straightforward until you get to The behavior that I'm seeing is that each instance ends up with its own instanceID. It looks like in practice we use the resource ID we get back from AWS to keep track of the resource (and subsequently add it to the resource as the ProblemIt's probably easiest to outline the issue in pictures. apiVersion: ec2.aws.crossplane.io/v1alpha1
kind: Instance
metadata:
name: pr-example
spec:
forProvider:
region: us-east-1
imageId: ami-0dc2d3e4c0f9ebd18
maxCount: 4
minCount: 1
tags:
- key: Name
value: pr-example
providerConfigRef:
name: example We get the following: [add-ec2-instances][~/codez/provider-aws]$ kubectl apply -f examples/ec2/instance.yaml
instance.ec2.aws.crossplane.io/pr-example created
[add-ec2-instances][~/codez/provider-aws]$ kubectl get instance pr-example
NAME READY SYNCED INSTANCES RUNNING AGE
pr-example True True 4 4 3m Note the different instanceIDs and different IPv4 addresses and DNS. If we were just dealing with a handful of instances getting spun up, I think adding a slice of instanceIDs to the SolutionCurrently, I've implemented grouping based on the external labels (tags) that are applied to the instances so I can observe the instances as a group and delete as a group through performing a DescribeInstanceInput that has a filter using those external labels. That all seems to work just fine. Where I'm starting to get into behavior I'm not sure whether or not its desirable is in keeping track of what we observe about the instances. For example, should we be tracking the DNS and addresses for these instances in order to display that to the end user? If so, it seems like we can totally get into the problematic behavior I outlined above when we're talking about 100+ instances. What are your thoughts? cc: @negz @hasheddan @muvaf @jbw976 |
I guess one thought is if it's not possible to remotely ask for that many resources, the above issue is probably moot. |
@tnthornton my intuition here is that this is one of the cases in which we need to 'interpret' the API a little to make it a little more declarative, while still aiming for (mostly) high fidelity. I would not expose the MinCount and MaxCount parameters under I just took a quick look at how our friends over on the Terraform project handle this, and it appears they use a fixed max/min; https://github.com/hashicorp/terraform-provider-aws/blob/e9309698/aws/resource_aws_instance.go#L739 |
Awesome. That makes things easier. |
While we're on the subject of 'interpreting' the API, there's this setting that's available that seems dangerous:
"Dangerous" in the sense that it could result in an unpleasant experience for the end user. Our friends over at Terraform include it https://github.com/hashicorp/terraform-provider-aws/blob/e9309698/aws/resource_aws_instance.go#L728, however arguably we have a slightly different use case and are less "fire and forget". Thoughts? |
The MinCount/MaxCount was meant to act as a gate on the instance launches. From the docs
One of the use-cases would be launching a block of workers to perform a bulk data task and needing to ensure these instances all exist in the same az. Using If we felt like honoring the behavior, we could implement "RunInstances" as an "order for instances," with no promise to manage the instances that are created. We could capture the This pattern works for the AWS API, because a failed call to "RunInstances" leaves no artifacts. In crossplane there would be a number of "failed" "RunInstances" objects that require cleaning up. As @negz already said, the |
@AaronME that's an interesting idea. So in my mind that would be something similar to a replicaSet. |
I think we should stick with a single
If I'm following correctly, I think we can leave this one in. It seems like it's disabled by default, can be updated once set, and when enabled will prevent us from being able to delete the instance? We have a similar option exposed on the |
Sounds good.
Yep, spot on. I couldn't quite find a similar approach (poor searching skills apparently) which was why I raised it. Alrighty with that all cleared up, I'll adjust the current impl to focus on just the single |
ecc3b9a
to
9b3683f
Compare
b61051d
to
e6cf850
Compare
898e33f
to
9e58b42
Compare
Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
add additional instance counts to api output Signed-off-by: Taylor Thornton <taylor@upbound.io>
adds support for user defined tags adjusts how we are grouping instances from the special 'Name' tag to using the external resource labeling Signed-off-by: Taylor Thornton <taylor@upbound.io>
add DisableAPITermination adjust management approach to focus on a single Instance object rather than a group Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
adds late-init flow Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
…al as they aren't guaranteed to come back Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
Signed-off-by: Taylor Thornton <taylor@upbound.io>
368293a
to
51fb4cc
Compare
Signed-off-by: Taylor Thornton <taylor@upbound.io>
1d0e155
to
a6b9ff1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tnthornton update loop is gone. This is good to merge.
Thank you for the contribution!
Thanks @tnthornton and @AaronME for working to get this merged - I think this will be huge for our users. |
Description of your changes
Add ec2/instance
Fixes #85
I have:
make reviewable test
to ensure this PR is ready for review.How has this code been tested
basic create/delete so far