-
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
Add k8s cluster identifier #26056
Add k8s cluster identifier #26056
Conversation
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
@ChrsMark take into account that this value (or the cluster IP itself) doesn't need to be unique in an organization with multiple clusters. An organization will probably use the same CIDRs for the internal networks of their clusters (at least there is no reason to use different ones). Also take into account that the As discussed in #17467 (comment), I think the values for the cluster URL should be unique. Look at this more as the external address that clients use to connect. Kubernetes doesn't have these concepts of "url" or "name" natively, some strategies discussed in the original issue to collect this data were to rely on |
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
👍🏼 Thanks Jaime for the comments. Indeed using endpoints will not be representative. To cut it short here is the logic:
For 2 we use values from
For 3 we use
I think this is a best effort approach to get these non-native k8s metadata using actually external resources. Let me know what you think @jsoriano . Note: Once we verify the approach I will complete the leftover changes and open it for complete review. |
cf905b3
to
ed35415
Compare
Signed-off-by: chrismark <[email protected]>
ed35415
to
5e75367
Compare
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Pinging @elastic/integrations (Team:Integrations) |
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
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.
Ok, from my side this can be merged, but please continue afterwards with the refactor of add_cloud_metadata
, or create an issue so we do it soon.
This pull request is now in conflicts. Could you fix it? 🙏
|
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
Signed-off-by: chrismark <[email protected]>
(cherry picked from commit 0829211)
* master: (25 commits) Fix UBI source URL (elastic#26384) Skip test_rotating_file in osx and windows (elastic#26379) Remove outdated k8s manifests for managed elastic-agent (elastic#26368) Enable agent to send custom headers to kibana/ES (elastic#26275) [Automation] Update elastic stack version to 8.0.0-943ef2c0 for testing (elastic#26354) Make the Syslog input GA (elastic#26293) Move Kerberos FAST config flag to shared kerberos config (elastic#26141) Add k8s cluster identifiers (elastic#26056) Store message from MongoDB json logs in message field (elastic#26338) update threatintel ECS version (elastic#26274) update envoyproxy ECS version (elastic#26277) [Filebeat] [MongoDB] Support MongoDB 4.4 json logs (elastic#24774) Update go-structform to 0.0.9 (elastic#26251) Forward port 7.13.2 changelog to master (elastic#26323) Updated filter expression for filtering 86 artifacts (elastic#26313) Osquerybeat: Align with the rest of the beats, set the ECS version (elastic#26324) [Packetbeat] Add `url.extension` to Packetbeat HTTP events (elastic#25999) Change link to snapshots in README (elastic#26317) Don't include full ES index template in errors (elastic#25743) First refactor of the system module - system/cpu and system/core (elastic#25771) ...
What does this PR do?
This PR add cluster identifier fields (defined in ECS) as part of k8s metadata in:
Note: [MetaGenerators' refactoring ] The identifiers are stored under
orchestrator.cluster.url/name
and because of this the metadata generators are refactored a little bit so as to cover the addition of such fields that are out ofkubernetes.*
namespace. The change is transparent andkubernetes.*
metadata are still reported in the same way. The refactoring is about making it easier to handle in the future ECS fields populated by k8s metadata generators. The logic is covered in interfaces' docs.The transparency of the refactoring is ensured by Event's testing in tests below:
The fields are populated following the flow bellow:
kubeadm-config
configMap (if available). Only for clusters setup withkubeadm
.Why is it important?
To add cluster identifier ECS fields as part of k8s metadata.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
How to test this PR locally
A. Verify that events from state_* metricsets are enriched properly
Enable kubernetes module with the following datasets:
Note: In the example above I run
kube-state-metrics
on local cluster using kind and I expose it to my host machine usingkubectl -n kube-system port-forward svc/kube-state-metrics 8081:8080
. In this case I need to defineadd_metadata
astrue
and also provide the properkube_config
so as to reach the k8s API. You can trykubectl config view -o jsonpath='{"Cluster name\tServer\n"}{range .clusters[*]}{.name}{"\t"}{.cluster.server}{"\n"}{end}'
to verify the values.2. Ensure that
orchestrator.cluster.name
,orchestrator.cluster.name
,kubernetes.namespace
andkubernetes.node.name
are being populated properly.3. Perform same test while running with inCluster mode, running metricbeat as Pod in the cluster (Note that the k8s cluster should be create with
kubeadm
since values for cluster info are retrieved fromkubeadm-config
configmap, you can trykubectl -n kube-system get configmap kubeadm-config -o yaml
to verify it)B. Verify that events from add_kuberentes_metadata are enriched properly
orchestrator.cluster.name
,orchestrator.cluster.name
,kubernetes.namespace
andkubernetes.node.name
are being populated properly.C. Verify that events from autodiscover provider are enriched properly
orchestrator.cluster.name
,orchestrator.cluster.name
,kubernetes.namespace
andkubernetes.node.name
are being populated properly.D. Perform one of the above scenarios with Metricbeat running as Pod on GKE.
Related issues