【发布时间】:2018-08-03 09:52:15
【问题描述】:
我们在 Kubernetes 集群部署中运行了一个 java 应用程序。我们使用 Google Cloud Bucket 作为存储。我们使用 Java Files.move 方法将文件从 Persistent Volume Claim (PVC) 移动到存储桶:
import java.nio.file.Files;
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING)
但是我们的写入性能很差。所以我们尝试探索 Google Cloud Storage API 将文件从我们的 PVC 移动到存储桶。
try {
log.info("before getService");
Storage storage = StorageOptions.newBuilder()
.setCredentials(GoogleCredentials.create(aToken)).build()
.getService();
// aToken is the access token of the service account
log.info("after getService");
} catch (Exception e) {
log.error("Error while creating storage object - ", e);
}
但只有“在 getService 之前”被记录。之后什么也没有发生。不会抛出异常。进程卡在 getService()
同一应用程序适用于使用 Google Storage Bucket 进行本地部署,但不适用于 Kubernetes 部署。
【问题讨论】:
标签: kubernetes google-cloud-storage google-kubernetes-engine