简体   繁体   English

对于并发呼叫,哪种Kubernetes client-go方法是安全的?

[英]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. Kubernetes client-go软件包包含一个使用client-go api创建单个部署的好例子

I want to create and destroy many kubernetes resources without waiting for each http request to complete. 我想创建和销毁许多kubernetes资源,而无需等待每个http请求完成。

Is it possible to use the client-go api asynchronously? 是否可以异步使用client-go api?

Are methods like the ones below safe for concurrent calls from multiple goroutines? 对于来自多个goroutine的并发调用,下面的方法是否安全?

resultPod, err := clientset.CoreV1().Pods("default").Create(desiredPod)

The k8s client uses http.Client internally which is safe to call concurrently. k8s客户端http.Client内部使用http.Client ,可以安全地同时调用。 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). 但是将并发API调用的数量限制在合理的上限可能是明智的(我从4开始;高于此值的任何东西可能都不会提高性能)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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