Add handling of environment variables from ConfigMaps and Secrets #3373
+2,201
−427
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Added detection and reading of environment variables defined in PODs resources like ConfigMaps and Secrets. Supports both
envFrom
andvalueFrom
forms.Link to tracking Issue(s):
Testing:
Added
kubebuilder
tests for new code, tested by deploying the generated image to OpenShift cluster.Documentation:
This is an enhancement, which can be read also as a bug fix (missing feature), so I have not added any documentation.
Implementation notes/questions:
ConfigMap
support is in first commit, theSecret
support is in the second commit. They work the same, they both support “if exists” checks and are able to extend the existing value (append) into a newly created (or updated) environment variable.Container
class naming (or have some common methods prefix?), so please suggest how the main class/file should be named - I can change it easily. The class handles everything regarding environment variables on the container currently.sdkInjector.inject
method gets one in arguments, but Apache and Nginx auto-instrumentations are ignoring it and taking namespace name from POD definition or from PODs resource map, which looks wrong (at minimum this is suspicious). I took the namespace name from the POD and if not found, I fall back to the one supplied as a parameter toinject
method.