3

I need to get all resources based on label, I used the following code which works, However, it takes too much time ( ~20sec) to get the response, even which I restrict it to only one namespace (vrf), any idea what im doing wrong here?

resource.NewBuilder(flags).
   Unstructured().
   ResourceTypes(res...).
   NamespaceParam("vrf").AllNamespaces(false).
   LabelSelectorParam("a=b").SelectAllParam(selector == "").
   Flatten().
   Latest().Do().Object()

https://pkg.go.dev/k8s.io/[email protected]/pkg/resource#Builder

As I already using label and ns, not sure what should else I do in this case.

Ive checked the cluster connection and it seems that everything is ok, running regular kubectl are getting very fast response, just this query took much time.

2
  • maybe your connection to the cluster is really bad? I've had 3-5 second calls to a cluster in Japan once. 20 seems a bit too much though Commented Feb 6, 2023 at 4:10
  • No the connection is just fine as others request to the cluster is working blazing fast... Commented Feb 15, 2023 at 16:36

1 Answer 1

1

The search may be heavy due to the sheer size of the resources the query has to search into. Have you looked into this possibility and further reduce the size using one more label or filter on top of current.

Also check the performance of you Kubernetes api server when the operation is being performed and optimize it.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, how can I reduce the size ? I already use ns and label? can you please provide a code example of what you mean?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.