Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Kubernetes client-go methods are safe for concurrent calls?

Tags:

go

kubernetes

The Kubernetes client-go package includes a nice example of creating a single deployment using the client-go api.

I want to create and destroy many kubernetes resources without waiting for each http request to complete.

Is it possible to use the client-go api asynchronously?

Are methods like the ones below safe for concurrent calls from multiple goroutines?

resultPod, err := clientset.CoreV1().Pods("default").Create(desiredPod)
like image 881
Charles Holbrow Avatar asked Jan 25 '18 17:01

Charles Holbrow


1 Answers

The k8s client uses http.Client internally which is safe to call concurrently. But it is probably wise to limit the number of concurrent API calls to a reasonable upper limit (I'd start with 4; anything above that is probably not going to improve performance much).

like image 51
simonmenke Avatar answered Oct 04 '22 21:10

simonmenke