Skip to content
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

feat: Add service k8s metadata to events #257

Merged
merged 3 commits into from
Oct 3, 2023
Merged

Conversation

MikeGoldsmith
Copy link
Contributor

@MikeGoldsmith MikeGoldsmith commented Sep 29, 2023

Which problem is this PR solving?

Kubernetes services are commonly used as load balancers between pod deployments so the pods can be managed separately from routing traffic to live pods. However, the agent only appends Kubernetes metadata when the source and destination IPs of generated events are pods.

This PR updates the process that applies Kubernetes metadata to also lookup services using the source and destination IPs.

Short description of the changes

  • Update the k8sCachedClient to index services in the serviceInformer by it's registered cluster IP
    • ClusterIP will be assigned when using services with a type of ClusterIP, NodePort and LoadBalancer
  • Update k8sutils to attempt to lookup a service if pod lookup failed and if a match is found, apply common service attributes
  • Extend both pod and service metadata to include a new "k8s.resource.type" attribute (will be set to either "pod" or "service")
  • Move custom k8s attribute keys to consts
  • Update existing libhoney handler test to verify the new resource type attribute is set
  • Add new test where the destination IP of an httpEvent targets a service and verify the expected attributes are set

How to verify that this has the expected result

Events generated by the agent now include a resource type attribute and apply service metadata when the service is routed through a service resource and not just pods.

@MikeGoldsmith MikeGoldsmith self-assigned this Sep 29, 2023
@MikeGoldsmith MikeGoldsmith added the type: enhancement New feature or request label Sep 29, 2023
@MikeGoldsmith MikeGoldsmith marked this pull request as ready for review October 3, 2023 12:45
@MikeGoldsmith MikeGoldsmith requested a review from a team October 3, 2023 12:45
Copy link
Contributor

@JamieDanielson JamieDanielson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

service with a smile

@JamieDanielson JamieDanielson merged commit 0dfe201 into main Oct 3, 2023
3 checks passed
@JamieDanielson JamieDanielson deleted the mike/service-metadata branch October 3, 2023 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Capture metadata for k8s service resources
2 participants