Skip to content

Always render LINKERD2_PROXY_INBOUND_PORTS env var in install/inject output#7893

Merged
kleimkuhler merged 3 commits intomainfrom
kleimkuhler/no-inbound-ports
Feb 16, 2022
Merged

Always render LINKERD2_PROXY_INBOUND_PORTS env var in install/inject output#7893
kleimkuhler merged 3 commits intomainfrom
kleimkuhler/no-inbound-ports

Conversation

@kleimkuhler
Copy link
Contributor

@kleimkuhler kleimkuhler commented Feb 15, 2022

Closes #7816.

With this change, the LINKERD2_PROXY_INBOUND_PORTS is always rendered in install/inject output. This means that if a workload does not expose any ports, then the env var is rendered as the empty string.

Coupled with linkerd/linkerd2-proxy#1478, no error is printed upon proxy startup.

Signed-off-by: Kevin Leimkuhler [email protected]

Signed-off-by: Kevin Leimkuhler <[email protected]>
@kleimkuhler kleimkuhler changed the title Allow for empty inbound ports env var Always render LINKERD2_PROXY_INBOUND_PORTS env var in install/inject output Feb 15, 2022
@kleimkuhler kleimkuhler marked this pull request as ready for review February 15, 2022 21:42
@kleimkuhler kleimkuhler requested a review from a team as a code owner February 15, 2022 21:42
Copy link
Member

@adleong adleong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Member

@mateiidavid mateiidavid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think the tests will be ok once PRs rebased :D

Do you think an integration test here would be useful to make sure pods that do not expose container pods get injected properly and spin up? Think it would be straightforward if we do it as part of the inject test

valueFrom:
fieldRef:
fieldPath: status.podIPs
{{ if .Values.proxy.podInboundPorts -}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we list the environment variables, LINKERD2_PROXY_INBOUND_PORTS will not have a corresponding value. I wonder if that's going to be a bit confusing down the line. When debugging, for example, it might be weird not to have a value associated at all with the variable, we wouldn't know whether this is expected behaviour or the injector/values were bad.

    - name: LINKERD2_PROXY_INBOUND_PORTS
    - name: LINKERD2_PROXY_DESTINATION_PROFILE_SUFFIXES
      value: svc.cluster.local.
    - name: LINKERD2_PROXY_INBOUND_ACCEPT_KEEPALIVE
      value: 10000ms
    - name: LINKERD2_PROXY_OUTBOUND_CONNECT_KEEPALIVE
      value: 10000ms
    - name: LINKERD2_PROXY_INBOUND_PORTS_DISABLE_PROTOCOL_DETECTION
      value: 25,587,3306,4444,5432,6379,9300,11211

Would it make sense to have an empty string as a value?

- name: LINKERD2_PROXY_INBOUND_PORTS
  value: ""

I'm not sure if we can do this through the templating functions or we'd have to do it in the injector, not sure if k8s itself will strip an empty value but wdyt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we list the environment variables, LINKERD2_PROXY_INBOUND_PORTS will not have a corresponding value.

AFAICT, this change does exactly what you propose by removing the guard around setting the environment variable. So it should be set and empty if there's an empty podInboundPorts. Or are you referring to something else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sorry, I was referring to seeing the value has been explictly set to empty, e.g

- name: LINKERD2_PROXY_INBOUND_PORTS
   value: ""

instead of

- name: LINKERD2_PROXY_INBOUND_PORTS

but I think if the variable is set to an empty value then it'll be stripped in the output? It's not a blocker either way, was just curious if this would make it more clear that it's been intentionally set to empty.

@kleimkuhler kleimkuhler enabled auto-merge (squash) February 16, 2022 17:19
@kleimkuhler kleimkuhler merged commit 9342b0e into main Feb 16, 2022
@kleimkuhler kleimkuhler deleted the kleimkuhler/no-inbound-ports branch February 16, 2022 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Always set LINKERD2_PROXY_INBOUND_PORTS when injecting pods

4 participants