-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leverage KUBECONFIG when creating k8s client #13916
Conversation
c8d2334
to
196374a
Compare
I don't know how the elastic config library works, and probably that's something to take into account here. Usually precedence regarding configuration variables would be:
Is this the intended scenario? If not, can you clarify what the target is? it is not 100% clear reading the related issue On implementation, it would be nice to have a |
The implementation focuses on the description that is summarised on #13648 (comment). Currently we have So with this feature we add an extra step to check if The aim is to leverage the |
yep, Iike the idea and the original issue is clear about the intention. I still miss the general broad view of args precedence: https://www.elastic.co/guide/en/beats/libbeat/master/config-file-format-cli.html so, if I'm not wrong, precedence will be:
That sounds good, although I'm hesitant if Can you add to the kubernetes docs how it works as of your changes? |
I'm not sure if a user would like to use command line flags to set Module's specific settings. In our case it will look like However, I think that this is not a concern for this PR, since the behaviour of flags is to overwrite specific configuration settings, and this patch comes after the whole configuration is already loaded.
Regarding
Sure thing I will update the docs! |
me agrees all |
95d2c8f
to
6f687b7
Compare
TBH I'm not sure if these doc's changes are enough but we don't have a unique place to document all k8s related configuration options for |
That's a great idea. Maybe you can open another PR to unify kube provider parameters somehow!. That said, I would not block this PR from getting in |
6f687b7
to
69bd269
Compare
I opened an issue for this documentation topic (#13997). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking this! left a minor comment
@@ -1339,6 +1339,7 @@ the Kubernetes node. | |||
processors: | |||
- add_kubernetes_metadata: | |||
host: <hostname> | |||
# It defaults to `KUBECONFIG` variable if present. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you update these comments to make sure it says environment variable
instead? Just in case, to avoid confusion
@@ -79,6 +79,7 @@ metricbeat.modules: | |||
add_metadata: true | |||
# When used outside the cluster: | |||
#host: node_name | |||
# It defaults to `KUBECONFIG` environment variable if present. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my POV this is not accurate.
A user could think that even if the kube_config
element is informed, KUBECONFIG
will overwrite it, but that's not the case.
Something like if kube_config is not informed, KUBECONFIG env var will be checked and if not present it will fall back to InCluster
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, you are right about the overwriting confusion I ll go along and try to change it.
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
519dab2
to
3ad34a6
Compare
jenkins, test this again please |
Closes #13648.
This PR changes the k8s Client creation so as:
kube_config
is provided return a client using itKUBECONFIG
env var is present and points to a valid file return a client using itin_cluster
mode so useinClusterConfig
(this is implemented inBuildConfigFromFlags
already)cc: @exekias , @odacremolbap