kubernetes-sigs / node-ipam-controller

Out of tree implementation of https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/2593-multiple-cluster-cidrs
Apache License 2.0
10 stars 11 forks source link

metrics for ipam-controller #40

Open ugur99 opened 1 month ago

ugur99 commented 1 month ago

Hi! I've checked the source code and it seems that there are some metrics planned to be served; but if I'm not mistaken those are not yet served. Are there any plans to improve metrics setup?

Also I was thinking that maybe it would be nice if we add another metric that shows the total ip range usage for each unique ip pool defined in the ClusterCIDR resources.

mneverov commented 1 month ago

Hi @ugur99 thanks for the suggestion! How do you see the metric? Node name, IP range size, # of consumed IPs?

ugur99 commented 2 days ago

hey @mneverov sorry for my late response!

We could scan all defined ClusterCIDRs to identify unique IP ranges. The controller should recalculate these whenever ClusterCIDRs are created or deleted.

For each unique IP range, we could calculate the total allocated IPs across nodes and generate an usage metric. This would allow us to expose metrics for each unique IP range.

Assuming we have two unique IP ranges, the metrics could look like this:

  node_ipam_cidr_usage_percentage{cidr="10.0.0.0/16"} 0.25
  node_ipam_cidr_usage_percentage{cidr="192.168.0.0/16"} 0.80

Not sure how much complexity this would add to the codebase, but would be great to have such metrics.

aojea commented 1 day ago

we already have those values https://github.com/kubernetes-sigs/node-ipam-controller/blob/437086557076b8714619b5b1f934d1ac28997a96/pkg/controller/ipam/multicidrset/multi_cidr_set.go#L32-L59 so it should be straighforward to add those metrics,

/kind feature