-
Notifications
You must be signed in to change notification settings - Fork 159
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
Set Load Balancer internal/external per process instead of per application #1082
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.
Modifying a running application by setting this environment variable and deploying ...
⚠️ Breaks CloudFormation as a Target Group can only be assigned to one Load Balancer, so we'd need to create a separate Target Group?
Probably what we should do is add a prefix to the resource name for the target group that includes the LB scheme. So instead of the resource name being webTargetGroup
, it would be webInternalTargetGroup
or webExternalTargetGroup
.
scheduler/cloudformation/template.go
Outdated
@@ -54,6 +69,20 @@ func loadBalancerType(app *twelvefactor.Manifest, process *twelvefactor.Process) | |||
return classicLoadBalancer | |||
} | |||
|
|||
func schemeExposure(app *twelvefactor.Manifest, process *twelvefactor.Process) string { | |||
env := twelvefactor.Env(app, process) | |||
if v, ok := env["EMPIRE_X_EXPOSURE"]; ok { |
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.
I think we should move this check into https://github.com/remind101/empire/blob/master/releases.go#L456, where it can just set the appropriate Exposure
on the twelvefactor.Process
.
I've been intending on moving all of the EMPIRE_X_*
checks from this file and into releases.go so this would be a good start.
8a595e4
to
0b5bee5
Compare
@ejholmes I've just rebased and pushed additional changes. The TargetGroup prefix was really easy to put it, so that wasn't the problem. Please let me know if you have comments either via Github or if you have time in the next few hours I'll be online via Slack |
4789bca
to
bb15edd
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.
Awesome! I'll try to play around with this later today/tomorrow to check how renaming the target group behaves.
procfile/README.md
Outdated
Name | Default value | Available options | Description | ||
-----|---------------|-------------------|------------ | ||
`EMPIRE_X_LOAD_BALANCER_TYPE` | `elb` | `alb`, `elb`| Determines whether you will use an ALB or ELB | ||
`EMPIRE_X_EXPOSURE` | `private` | `private`, `public` | Sets whether your ALB or ELB will be public (internet-facing) or private (internal), the default is private, however if you have used the deprecated `domain-add` command then the load balancer will become public. **If you change this setting, the load balancer will be recreated as soon as you 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.
One thing that we've tried to do with the extended Procfile is maintain some level of "parity" with docker-compose.yml
, so that concepts just kinda translate over (e.g. ports).
In docker-compose.yaml, you can attach a container to a "network" (like external
or internal
), which I think maps pretty nicely to how we use internal/external ELB's. I wonder if we should just use a networks
key to determine whether the process should be exposed external/internal.
For example:
web:
command: ./bin/web
networks:
- external # Expose this process with an "external" ELB.
admin:
command: ./bin/web
networks:
- internal # Expose this process with an "internal" ELB
Just a thought, totally fine with starting with some EMPIRE_X
env vars.
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.
I like that idea too
mergedEnv := twelvefactor.Merge(appEnv, env) | ||
|
||
isExternal := release.App.Exposure == exposePublic | ||
if v, ok := mergedEnv["EMPIRE_X_EXPOSURE"]; ok { |
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 should add some tests similar to https://github.com/remind101/empire/blob/master/tests/empire/empire_test.go#L77-L180 that exercises this?
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.
yep definitely makes sense. Let me have a stab at it
procfile/README.md
Outdated
@@ -78,3 +78,13 @@ This allows you to set process specific environment variables. If these are set | |||
environment: | |||
EMPIRE_X_LOAD_BALANCER_TYPE: "alb" | |||
``` | |||
|
|||
Supported environment variables that can either be set via `emp set` for the whole application or |
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.
Thanks for documenting these!
…ation Introduces EMPIRE_X_EXPOSURE which needs to be either `internal` or `internet-facing` (kept AWS terminology here). If that environment variable is not set, we fallback to the default selection via application (where you use `domain-add`). Fixes remind101#1076
bb15edd
to
2ddd969
Compare
Introduces EMPIRE_X_EXPOSURE which needs to be
public
.If that environment variable is not set, we fallback to the default selection via application (where you use
domain-add
).Added this explanation in the Procfile doc.
Fixes #1076
Things working and tested:
env set EMPIRE_X_EXPOSURE=public
creates a public ALB/ELBThe biggest thing is that this setting shouldn't be considered as harmless. If you change it ... your load balancer WILL get recreated.
@ejholmes Thoughts?