Cherry-pick #26056 to 7.x: Add k8s cluster identifier#26346
Merged
ChrsMark merged 1 commit intoelastic:7.xfrom Jun 17, 2021
Merged
Cherry-pick #26056 to 7.x: Add k8s cluster identifier#26346ChrsMark merged 1 commit intoelastic:7.xfrom
ChrsMark merged 1 commit intoelastic:7.xfrom
Conversation
(cherry picked from commit 0829211)
Contributor
|
Pinging @elastic/integrations (Team:Integrations) |
Contributor
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
|
has this been forgotten ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Cherry-pick of PR #26056 to 7.x branch. Original message:
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/nameand 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-configconfigMap (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.asciidocorCHANGELOG-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-metricson 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_metadataastrueand also provide the properkube_configso 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.namespaceandkubernetes.node.nameare 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
kubeadmsince values for cluster info are retrieved fromkubeadm-configconfigmap, you can trykubectl -n kube-system get configmap kubeadm-config -o yamlto verify it)B. Verify that events from add_kuberentes_metadata are enriched properly
orchestrator.cluster.name,orchestrator.cluster.name,kubernetes.namespaceandkubernetes.node.nameare being populated properly.C. Verify that events from autodiscover provider are enriched properly
orchestrator.cluster.name,orchestrator.cluster.name,kubernetes.namespaceandkubernetes.node.nameare being populated properly.D. Perform one of the above scenarios with Metricbeat running as Pod on GKE.
Related issues