简体   繁体   中英

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

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)

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM