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
Limit Pod.List calls by namespace #20
Limit Pod.List calls by namespace #20
Conversation
On larger clusters with thousands of pods listing all pods is too expensive. Signed-off-by: Blake <blake.barnett@postmates.com>
39f5d9a
to
7612a46
Compare
This should probably move to client initialization time, but works fine otherwise. |
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.
Good stuff, thanks @blakebarnett !
Can I just be a pain and ask to fix the indentation before we merge this in ? Thanks !
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
sorry about that, I was on vacation :) I'm not sure how the indentation made it past my vim config (runs go fmt automatically) 🤷♂️ |
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func GetAllPods() map[string]string { | ||
func getNamespace() string { | ||
b, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace") |
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.
@blakebarnett @seeker89 sorry for jumping on a merged PR like this ;) but we've hit this on one of our clusters and wanted to share.
Although this is a rare case, a cluster may have Service Account admission controller disabled (I know... I know...) in this case this file doesn't exist.
Could we consider a fallback option to read this from an Env variable? we could pass it on using metadata.namespace
downward api, similar to how we pass down the hostname.
On larger clusters with thousands of pods listing all pods is too expensive.
Fixes #19