-
Notifications
You must be signed in to change notification settings - Fork 391
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
feat: allow multiple environments per VPC via new service discovery namespace #2515
Conversation
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.
Looks good to me! Would you add e2e and maybe update the doc accordingly (and merge conflict again sorry)? Thank you!
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.
Looks good to me! Mostly just a few questions
internal/pkg/describe/env.go
Outdated
// If the service discovery param is set (meaning the stack is not upgraded), use the provided value | ||
if v != "" { |
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.
Wouldn't this mean that the stack is actually upgraded? i.e. we are at least on v1.5.0
internal/pkg/describe/env.go
Outdated
if v != "" { | ||
return v, nil | ||
} | ||
// if the param exists but is empty, use the legacy endpoint. |
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.
When can this happen? (not against the code or anything) but it might be worthwhile writing it.
My understanding is that when upgrading we always set a value for this parameter.
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.
We don't set a value when upgrading. If the stack is created at version 1.5.0 or higher, it's set to env.app.local
. If the stack is upgraded from before that version, it's set to empty, which causes the template to use app.local
.
|
||
Prior to Copilot v1.8.0 and environment version 1.5.0, the service discovery namespace used the format _{app name}.local_, without including the environment. This limitation made it impossible to deploy multiple environments in the same VPC. Any environments created with Copilot v1.8.0 and newer can share a VPC with any other environment. | ||
|
||
When your environments are upgraded, Copilot will honor the service discovery namespace that the environment was created with. That means that the endpoint your services are reachable at will not change. Any new environments created with Copilot v1.8.0 and above will use the _{env name}.{app name}.local_ format for service discovery, and can share VPCs with older environments. |
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.
Can we create an issue and pin that in our repository so that folks are aware of this change.
Ideally if they use only the env variable then we are good. However, if folks have app.local
hardcoded in their code and deploy to a new env then their code will fail mysteriously. (Which I think is ok since we provide the env variable)
@@ -262,6 +263,14 @@ func (o *deploySvcOpts) configureClients() error { | |||
// CF client against env account profile AND target environment region | |||
o.svcCFN = cloudformation.New(envSession) | |||
|
|||
o.endpointGetter, err = describe.NewEnvDescriber(describe.NewEnvDescriberConfig{ |
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.
Do we need to update cli/deploy.go
as well? I couldn't find it in the list of files.
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.
No, since there are no flag changes and deploy
under the hood just invokes svc or job deploy.
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.
The endpointGetter
func is initialized during Execute
for both svc init
and job init
by the configureClients()
method on the initSvcProps
and initJobProps
structs.
Co-authored-by: Efe Karakus <efekarakus@gmail.com>
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.
Woohooo 🚀
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.
Awesome 🚢
…amespace (aws#2515) This PR modifies the default service discovery namespace for new environments to the form {env}.{app}.local. This change allows customers to place multiple environments in the same VPC. The PR also creates an upgrade path for older environments. Those upgraded environments will retain the default app.local namespace to avoid a backward breaking change for services deployed there, but new environments will use env.app.local. <img width="761" alt="Screen Shot 2021-06-24 at 3 56 02 PM" src="https://user-images.githubusercontent.com/25392995/123342814-50146a00-d505-11eb-8749-41e409150999.png"> In the image above, I have deployed the same service to 3 environments. legacy was created at environment version 1.4.0. and upgraded to 1.5.0. new was created at version 1.5.0 shared-with-legacy was created at 1.5.0 and shares a vpc and subnets with legacy. There currently is not an upgrade path for existing environments to switch to new service discovery. This should not be an issue in most cases, however, as the environment variable points to the correct namespace in all cases and new+old environments can coexist in the same VPC. This change does not disrupt any existing environments. If we eventually add an "environment v2.0.0," we can force migration to the new discovery service by removing the UseLegacyServiceDiscoveryIfBlank parameter and updating our workloads to remove the LegacyServiceDiscovery bool from the template package. Updated integ tests to reflect new endpoints. Manually tested the above by running `copilot svc exec -n fe -e $ENV` for each of the three environments, then running `curl fe.$COPILOT_SVC_DISCOVERY_ENDPOINT` from within the container. Each time, I received the expected HTML content. Related aws#2377 By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
This PR modifies the default service discovery namespace for new environments to the form {env}.{app}.local. This change allows customers to place multiple environments in the same VPC.
The PR also creates an upgrade path for older environments. Those upgraded environments will retain the default app.local namespace to avoid a backward breaking change for services deployed there, but new environments will use env.app.local.
In the image above, I have deployed the same service to 3 environments.
legacy was created at environment version 1.4.0. and upgraded to 1.5.0.
new was created at version 1.5.0
shared-with-legacy was created at 1.5.0 and shares a vpc and subnets with legacy.
There currently is not an upgrade path for existing environments to switch to new service discovery. This should not be an issue in most cases, however, as the environment variable points to the correct namespace in all cases and new+old environments can coexist in the same VPC.
This change does not disrupt any existing environments. If we eventually add an "environment v2.0.0," we can force migration to the new discovery service by removing the UseLegacyServiceDiscoveryIfBlank parameter and updating our workloads to remove the LegacyServiceDiscovery bool from the template package.
Updated integ tests to reflect new endpoints. Manually tested the above by running
copilot svc exec -n fe -e $ENV
for each of the three environments, then runningcurl fe.$COPILOT_SVC_DISCOVERY_ENDPOINT
from within the container. Each time, I received the expected HTML content.Related #2377
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.