fix(helm): allow overriding CODER_PPROF_ADDRESS and CODER_PROMETHEUS_ADDRESS#21714
Conversation
…ADDRESS
Previously, these environment variables were hardcoded in the Helm chart
template and could not be overridden via coder.env values. This was a
security concern because binding to 0.0.0.0 exposes these endpoints to
any pod in the cluster.
This change:
- Checks if the user has set CODER_PPROF_ADDRESS or CODER_PROMETHEUS_ADDRESS
in coder.env before applying the default values
- Updates values.yaml documentation to reflect that these can now be
overridden (and recommends 127.0.0.1 for security)
- Adds test cases for both override scenarios
Users can now restrict pprof and prometheus to localhost only:
```yaml
coder:
env:
- name: CODER_PPROF_ADDRESS
value: "127.0.0.1:6060"
- name: CODER_PROMETHEUS_ADDRESS
value: "127.0.0.1:2112"
```
Fixes #21713
Documentation CheckUpdates Needed
RecommendationsConsider adding a security note to Automated review via Coder Tasks |
|
@deansheather Although the PR was created by Blink, I have reviewed it's work. Would appreciate a review from you if you can. Please let me know. |
|
If people rebind to localhost, can they even scrape the data into prometheus or whatever? To me it sounds like it wouldn't work, and at that point why even leave them enabled? I think we support disabling these, right? |
|
You're right that binding to
But you raise a valid point - for Prometheus scraping via a ServiceMonitor or external scraper,
The original issue was specifically about pprof where the customer wanted to prevent other pods from grabbing profiles (security concern), but still wanted the ability to use Should I update the PR description and values.yaml docs to be clearer about these tradeoffs? Or do you think this flexibility isn't worth the added complexity and we should just keep them non-overridable? |
|
I think this is more about allowing customers to declare their own desired configuration when it comes to security matters like these. Per Blink there are definitely still use cases for binding to localhost that would be helpful for customers. |
Documentation CheckPrevious FeedbackNot yet addressed - The documentation update identified in the previous review is still needed. Updates Needed
RecommendationsConsider adding a brief security note explaining the tradeoffs of binding to
Automated review via Coder Tasks |
Summary
Previously,
CODER_PPROF_ADDRESSandCODER_PROMETHEUS_ADDRESSwere hardcoded in the Helm chart template to0.0.0.0:6060and0.0.0.0:2112respectively. These values could not be overridden viacoder.envvalues because the hardcoded values were set first in the template, and Kubernetes uses the first occurrence of duplicate env vars.This was a security concern because binding to
0.0.0.0exposes these endpoints to any pod in the cluster:Changes
helm/coder/templates/_coder.tpl: Added logic to check if the user has setCODER_PPROF_ADDRESSorCODER_PROMETHEUS_ADDRESSincoder.envbefore applying the default values. If the user provides a value, the hardcoded default is skipped.helm/coder/values.yaml: Updated documentation to:Tests: Added test cases for both override scenarios with corresponding golden files.
Usage
Users can now restrict pprof and prometheus to localhost only:
Local Testing
To verify the fix locally:
Fixes #21713