-
Notifications
You must be signed in to change notification settings - Fork 428
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
fix: no extra port mapping in main container when nlb target is a sidecar #3819
Conversation
…tainer is the main contaier (fix aws#3768)
Protocol: tcp | ||
{{- end }} | ||
{{- if .NLB}} {{ $nlbListener := .NLB.Listener }} | ||
{{- if and (eq $nlbListener.TargetContainer .WorkloadName) (ne $nlbListener.TargetPort .NLB.MainContainerPort)}} |
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.
:ack: this looks good, what about this feedback from the issue:
It appears that the cf partial below is not sidecar aware, and assumes that the nlb target is always the main workload container.
To me it sounded like the NLB target group is pointing to the wrong port?
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.
With a manifest like this:
nlb:
port: 80/tcp
target_container: envoy
image:
location: blah
port: 10000
sidecars:
envoy:
# envoy admin port
port: 9901
image: public.ecr.aws/hashicorp/envoy-alpine:latest
The NLB target group's target port will be 9901, not 10000, with the current implementation and as expected!
My understanding for the quoted comment was specifically for the code:
copilot-cli/internal/pkg/template/templates/workloads/partials/cf/workload-container.yml
Line 33 in 2ac6b01
{{if ne .NLB.Listener.TargetPort .NLB.MainContainerPort}} {{/*No need to add additional port if the target port is the same as image port*/}} |
The (bugged) code assume the target container is main container, and add the target port to main container's port mapping if it's not the same as the container port. It fails to take into consideration the possibility that the target container could be a sidecar, in which case, it does not need to add the extra port mapping to the main container.
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 the explanation, totally makes sense!
Fix #3768
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.