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.
: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.
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:latestThe 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:
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.
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.