consul-k8s icon indicating copy to clipboard operation
consul-k8s copied to clipboard

Add HOST_IP environment variable to consul_dataplane_sidecar.go

Open woz5999 opened this issue 10 months ago • 5 comments

Changes proposed in this PR

  • Add HOST_IP environment variable to consul_dataplane_sidecar.go

This environment variable must be set in order to utilize HOST_IP as part of statsd or dogstatsd sinks. If this variable is unset and the sink is configured to use HOST_IP, the sidecar won't start and pods won't come up healthy.

How I've tested this PR

  • Unit tests
  • Deployed and tested a local build to our cluster and confirmed that injected pods now come up healthy and have the HOST_IP variable set as expected

How I expect reviewers to test this PR

  • The unit tests should do it

    Reference to similar change for mesh-gateway deployments:

    • https://github.com/hashicorp/consul-k8s/blob/8ac97bf0dc70576e01ade4337700c9f78ed54908/CHANGELOG.md?plain=1#L763
    • https://github.com/hashicorp/consul-k8s/pull/1808

Checklist

woz5999 avatar Apr 16 '24 21:04 woz5999

@t-eckert @david-yu You guys reviewed a similar change previously about a year ago: https://github.com/hashicorp/consul-k8s/pull/1808#issuecomment-1407056921

We're just now circling back to try this upgrade and ran into this issue where the code supports the var expansion, but it seems like the env var isn't being set in the injected dataplane pods. This PR fixes that.

Note that I'm not sure why the pr/test and backport checks are failing, but I'm happy to make any changes given proper guidance. We've been waiting a year to get this going, so would love to do anything we can to speed this fix along and finally get onto 1.x. ❤️

woz5999 avatar Apr 16 '24 21:04 woz5999

@woz5999, this is excellent work! Overall, the PR seems right. I would definitely encourage you to run this build in a K8s deployment in order to verify it works correctly with *statsd.

I no longer work at HashiCorp so I don't think it's right for me to approve the change, but from a spot check, this is how adding the env var would be done.

t-eckert avatar Apr 16 '24 22:04 t-eckert

@woz5999 We'll try to get a review, but we also have a few more PRs in the queue from our community that we need to review. Thank you for the PR! And thanks for looking out @t-eckert !

david-yu avatar Apr 16 '24 22:04 david-yu

I just wanted to update that I was able to successfully deploy and confirm this fix in our cluster today.

woz5999 avatar Apr 18 '24 00:04 woz5999

Any update on this?

woz5999 avatar Aug 13 '24 22:08 woz5999

@nathancoleman, I checked this awhile back. I think it's good.

t-eckert avatar Aug 29 '24 17:08 t-eckert

Looks like this needs a rebase and some backport labels. I can handle that by EOD today

nathancoleman avatar Aug 29 '24 19:08 nathancoleman

Thanks @nathancoleman This is updated now

woz5999 avatar Aug 29 '24 21:08 woz5999

@woz5999 I reopened this PR using a branch in hashicorp/consul-k8s since there is some required CI that can't run in forks. I made sure to keep your exact commits in tact so that you're still credited as a contributor by GitHub. Apologies for the back and forth. Will merge once a colleague of mine approves the PR below.

https://github.com/hashicorp/consul-k8s/pull/4277

nathancoleman avatar Aug 30 '24 15:08 nathancoleman