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 load filtering to clusterLogConfig and exclude namespaces #643

Merged
merged 6 commits into from
Nov 9, 2023

Conversation

LeiZhang-Hunter
Copy link
Contributor

Proposed Changes:

Which issue(s) this PR fixes:

Fixes #

Additional documentation:

为clusterLogConfig加了很多新特性,可以排除命名空间,可以根据不同的Deployment,CronJob,Statsetfulset,Daemonset 去过滤pod

过滤命名空间

apiVersion: loggie.io/v1beta1
kind:  ClusterLogConfig
metadata:
  name: globalstdout
spec:
  selector:
    type: pod
    namespaceSelector:
      - default1
      - default2
    excludeNameSpaceSelector:
      - default3
  pipeline:
    sources: |
      - type: file
        name: stdout
        paths:
        - stdout
    sinkRef: default

选择负载

apiVersion: loggie.io/v1beta1
kind:  ClusterLogConfig
metadata:
  name: globalstdout
spec:
  selector:
    type: workload
    workload_selector:
      - type: 
          - Deployment
        nameSelector:
          - my-nginx
        nameSpaceSelector:
          - default
       
  pipeline:
    sources: |
      - type: file
        name: stdout
        paths:
        - stdout
    sinkRef: default

return selector, nil
}

// GetPodsByLabelSelector 根据label 筛选出全部的pod
Copy link
Collaborator

Choose a reason for hiding this comment

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

注释都改成英文?

PodSelector `json:",inline"`
NodeSelector `json:",inline"`
NamespaceSelector `json:",inline"`
WorkloadSelector []WorkloadSelector `json:"workload_selector,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

改成驼峰的方式?


func (p *filterCacheChecker) checkOwner(owner metav1.OwnerReference, namespace string) (bool, error) {

// 如果没有选workloadSelector,那么默认是全部符合的
Copy link
Collaborator

Choose a reason for hiding this comment

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

英文

}
}

// Confirm 确认pod 是否满足lgc的规则
Copy link
Collaborator

Choose a reason for hiding this comment

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

英文

return false, nil
}

// 检查label
Copy link
Collaborator

Choose a reason for hiding this comment

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

英文

return ret, nil
}

// Filter 过滤pod
Copy link
Collaborator

Choose a reason for hiding this comment

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

英文

return selector, nil
}

// GetPodsByLabelSelector select pod by label
Copy link
Collaborator

Choose a reason for hiding this comment

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

英文

@ethfoo ethfoo merged commit 7d03ad8 into loggie-io:main Nov 9, 2023
2 checks passed
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.

2 participants