-
Notifications
You must be signed in to change notification settings - Fork 45
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/expose metrics only specific ns #94
Add/expose metrics only specific ns #94
Conversation
…for all ns by default, unless is set to true
…for all ns by default, unless is set to true
Hi @kimiyasharifi, thanks for you pull request. Overall I am for this feature, but we do need to revert of some changes. I will annotate those now. I also enabled the e2e test on this PR incase you can't run the test local. Currently it's failing due to the |
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.
Revert all of charts to chart
Do not bump the version.
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.
Revert this.
select { | ||
case <-ticker.C: |
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.
What is the benefit of doing it this way?
@@ -139,12 +139,28 @@ func (n *Node) Watch() { | |||
// Start the informer to begin watching for Node events | |||
go sharedInformerFactory.Start(stopCh) | |||
|
|||
// Use a ticker for periodic actions | |||
ticker := time.NewTicker(time.Duration(n.sampleInterval) * time.Second) |
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.
Why should we do it this way?
@@ -23,6 +27,35 @@ var ( | |||
Pod pod.Collector | |||
) | |||
|
|||
func getMonitoredNamespaces(clientset *kubernetes.Clientset) ([]string, error) { |
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.
Close. This will get our namespaces on init only. We will want to update our cache of namespaces periodically incase need ones were added.
A good example would be this node watch with a shard informer.
https://github.com/jmcgrath207/k8s-ephemeral-storage-metrics/blob/master/pkg/node/k8s.go#L106
Wouldn't be against following the same pattern and putting that code under pkg/k8s.go
Hey not see any activity. Closing feel free to reopen once changes are completed. |
This pull request introduces changes to enable the exporter to expose metrics only for ns labeled with specific label. Introduced a new env var
EPHEMERAL_STORAGE_LABEL
to specify the label selector for ns to monitor.getMonitoredNamespaces(clientset *kubernetes.Clientset) ([]string, error)
now reads the label selector from theEPHEMERAL_STORAGE_LABEL
env var.setMetrics(clientset *kubernetes.Clientset, nodeName string, monitoredNamespaces map[string]bool)
now receives a map of monitored ns to check if a pod’s ns is in the monitored list.Additionally, this pull request adds the capability to expose metrics for all namespaces by default, unless a specific environment variable,
ENABLE_SPECIFIC_NAMESPACE_MONITORING
, is set totrue
. This logic is implemented in thegetMonitoredNamespaces
function.