Add autodiscover for kubernetes#6055
Conversation
|
Can one of the admins verify this patch? |
libbeat/common/kubernetes/util.go
Outdated
There was a problem hiding this comment.
exported function DiscoverKubernetesNode should have comment or be unexported
libbeat/common/kubernetes/util.go
Outdated
There was a problem hiding this comment.
exported function GetKubernetesClient should have comment or be unexported
don't use underscores in Go names; func parameter in_cluster should be inCluster
don't use underscores in Go names; func parameter kube_config should be kubeConfig
libbeat/common/kubernetes/types.go
Outdated
There was a problem hiding this comment.
exported method PodContainerStatus.GetContainerID should have comment or be unexported
There was a problem hiding this comment.
exported method Provider.Stop should have comment or be unexported
There was a problem hiding this comment.
exported method Provider.Start should have comment or be unexported
There was a problem hiding this comment.
@vjsamuel lately we have been trying to make hound happy for most of its messages, could you add these comments?
327c662 to
27a1825
Compare
There was a problem hiding this comment.
Will this need an update to our fields.yml or is node already in there?
libbeat/common/kubernetes/util.go
Outdated
There was a problem hiding this comment.
We normally use inClusterfor naming, same for kubeConfig
libbeat/common/kubernetes/util.go
Outdated
There was a problem hiding this comment.
nit: We often use err instead of error
|
jenkins, test it |
There was a problem hiding this comment.
The behavior of this Func is odd when beat is put outside of k8s cluster. As far as I know, host is used as a node selector while making watch requests. So when beat is deployed outside the cluster, host should be ignored or it won't get any watched info from k8s. And if beat is put in cluster, host should be set by k8s downward api I think. So should we remove this host config since it is either wrong in case outside cluster or error-prone while user specify a wrong host in config?
There was a problem hiding this comment.
@walktall, this piece of code when provided with a host just uses the host. it is good especially when you are testing locally without having to deploy the beat onto Kubernetes. when running in cluster, this code, gets the pod name and uses it to get the pod spec and figures out what host the pod is deployed on.
There was a problem hiding this comment.
Yes, it is useful while test beat locally since user can set host to k8s node name. But if it is deployed outside the cluster or as a k8s deployment, we still need to ignore host anyway. Say I put beat in another k8s cluster, the result will be wrong here.
There was a problem hiding this comment.
when running in cluster, this code, gets the pod name and uses it to get the pod spec and figures out what host the pod is deployed on.
I prefer using k8s downward api here to get pod name though.
There was a problem hiding this comment.
In general, watching all nodes from outside the cluster may suffer from other issues, like scalability.
These settings work best when running from inside the cluster, or orchestrating beats as part of the deployment (one per node, with the host value set).
We can discuss this in a new issue if you find the idea worth exploring, as I want to move this PR forward, and it only moved code around to get a cleaner interface.
61a916a to
e487576
Compare
libbeat/common/kubernetes/types.go
Outdated
There was a problem hiding this comment.
exported method PodContainerStatus.GetContainerID should have comment or be unexported
metricbeat/module/uwsgi/uwsgi.go
Outdated
There was a problem hiding this comment.
exported function NewModule should have comment or be unexported
libbeat/common/kubernetes/types.go
Outdated
There was a problem hiding this comment.
exported method PodContainerStatus.GetContainerID should have comment or be unexported
metricbeat/module/uwsgi/uwsgi.go
Outdated
There was a problem hiding this comment.
exported function NewModule should have comment or be unexported
e487576 to
8415b40
Compare
exekias
left a comment
There was a problem hiding this comment.
LGTM, nice helper functions, and the node name addition.
We will need to open a follow-up PR for documentation
|
ok to test |
libbeat/common/kubernetes/types.go
Outdated
There was a problem hiding this comment.
comment on exported method PodContainerStatus.GetContainerID should be of the form "GetContainerID ..."
libbeat/common/kubernetes/types.go
Outdated
There was a problem hiding this comment.
comment on exported method PodContainerStatus.GetContainerID should be of the form "GetContainerID ..."
db2cf2b to
37cfd21
Compare
|
ok to test |
|
Awesome work @vjsamuel, as usual, thank you! 🎉 |
|
I see that docs are added in #6065, so I'm removing the needs_docs label from this PR. Please open an issue against docs if additional changes are required. |
This PR adds auto discovery for kubernetes. Some sample specs for using this feature:
Filebeat: (discover all workloads in default namespace)
Metricbeat: query for pods with label
project: prometheus