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

Limit Pod.List calls by namespace #20

Merged

Conversation

blakebarnett
Copy link
Contributor

On larger clusters with thousands of pods listing all pods is too expensive.

Fixes #19

On larger clusters with thousands of pods listing all pods is too expensive.

Signed-off-by: Blake <blake.barnett@postmates.com>
@blakebarnett blakebarnett force-pushed the bdb__limit_pod_list_by_namespace branch from 39f5d9a to 7612a46 Compare December 18, 2018 22:45
@blakebarnett
Copy link
Contributor Author

This should probably move to client initialization time, but works fine otherwise.

@blakebarnett blakebarnett changed the title Limit the list of Pod.List calls by namespace Limit Pod.List calls by namespace Dec 18, 2018
Copy link
Contributor

@seeker89 seeker89 left a 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>
@seeker89 seeker89 merged commit 0060f82 into bloomberg:master Dec 20, 2018
@blakebarnett
Copy link
Contributor Author

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")
Copy link
Contributor

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.

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

4 participants