![](/img/trans.png)
[英]How to perform Rolling update and Rollback of deployment in Kubernetes using fabric8 java client API?
[英]How do I read a file from deployment's pods using fabric8 kubernetes java client?
如何从部署的 pod 中读取文件? 更具体地说,我希望 fabric8 的 kubernetes java 客户端等效于以下命令:
kubectl exec --stdin --tty deployment/otel-collector -n logcollection -- cat /otel-output/json-out.json
PS:您可以忽略--stdin
和--tty
标志。
这相当简单,从Pod
读取文件可以使用以下语法(另请参阅fabric8 文档):
try (InputStream is = client.pods().inNamespace(currentNamespace).withName(pod1.getMetadata().getName()).file("/msg").read()) {
String result = new BufferedReader(new InputStreamReader(is)).lines().collect(Collectors.joining("\n"));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.