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

[Agent] Add K8s event data #6054

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

[Agent] Add K8s event data #6054

wants to merge 1 commit into from

Conversation

TomatoMr
Copy link
Contributor

@TomatoMr TomatoMr commented Apr 9, 2024

This PR is for:

  • Agent
  • Server

Add K8s event data

Send the k8s event to ingester

Checklist

  • Added unit test.

Backport to branches

@@ -727,6 +727,12 @@ vtap_group_id: g-xxxxxx
## FlowAggregator/SessionAggregator.
#flow-sender-queue-count: 1

Copy link
Member

Choose a reason for hiding this comment

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

上面还有一段要改改,体现出来 event(而且要有控制效果)

  ## K8s api resources
  ## Note: Specify kubernetes resources to watch.
  #    The schematics of entries in list is:
  #    {
  #        name: string
  #        group: string
  #        version: string
  #        disabled: bool
  #    }
  #
  #    Agent will watch the following resources by default:
  #    - namespaces
  #    - nodes
  #    - pods
  #    - replicationcontrollers
  #    - services
  #    - daemonsets
  #    - deployments
  #    - replicasets
  #    - statefulsets
  #    - ingresses
  #
  #    To disable a resource, add an entry to the list with `disabled: true`:
  #
  #        kubernetes-resources:
  #        - name: services
  #          disabled: true
  #
  #    To enable a resource, add an entry of this resource to the list. Be advised that
  #    this setting overrides the default of the same resource. For example, to enable
  #    `statefulsets` in both group `apps` (the default) and `apps.kruise.io` will require
  #    two entries:
  #
  #        kubernetes-resources:
  #        - name: statefulsets
  #          group: apps
  #        - name: statefulsets
  #          group: apps.kruise.io
  #          version: v1beta1
  #
  #    The old `ingress-flavour` setting is deprecated. Watching `routes` in openshift will
  #    use these settings:
  #
  #        kubernetes-resources:
  #        - name: ingresses
  #          disabled: true
  #        - name: routes
  #
  #kubernetes-resources: []

Copy link
Member

Choose a reason for hiding this comment

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

目前是否采集 k8s event 受上面的配置项控制吗? @TomatoMr

@@ -885,6 +948,9 @@ where

pub trait Trimmable: 'static + Send {
fn trim(self) -> Self;
fn trim_to_event(&self) -> BoxedKubernetesEvent {
Copy link
Contributor

Choose a reason for hiding this comment

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

这个只有 event 需要,不应该加在这里

@@ -56,6 +56,7 @@ type StaticConfig struct {
ToaLruCacheSize *int `yaml:"toa-lru-cache-size,omitempty"`
FlowSenderQueueSize *int `yaml:"flow-sender-queue-size,omitempty"`
FlowSenderQueueCount *int `yaml:"flow-sender-queue-count,omitempty"`
K8sEventSenderQueueSize *int `yaml:"k8s-event-sender-queue-size,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

之前所有的配置都写的 kubernetes

exception_handler.clone(),
true,
);
api_watcher.set_k8s_events_sender(k8s_events_sender);
Copy link
Contributor

Choose a reason for hiding this comment

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

这部分创建代码考虑放到 api_watcher 创建前,避免 sender 加锁

WatchEvent::Added(object) | WatchEvent::Modified(object) => {
if ctx.kind.name == "events" {
Copy link
Contributor

Choose a reason for hiding this comment

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

用 match guard

Event::default()
}

fn trim_to_event(&self) -> BoxedKubernetesEvent {
Copy link
Contributor

Choose a reason for hiding this comment

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

参数为啥不用self

@@ -456,6 +480,7 @@ pub struct WatcherConfig {
pub struct ResourceWatcher<K> {
api: Api<K>,
entries: Arc<Mutex<HashMap<String, Vec<u8>>>>,
events: Arc<Mutex<Vec<BoxedKubernetesEvent>>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

这个字段不应该出现,因为只有 event 类型需要

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants