[英]Google Cloud Bucket connection from Kubernetes deployment using Storage API
We have a java application running in Kubernetes cluster deployment. 我们有一个Java应用程序在Kubernetes集群部署中运行。 We're using Google Cloud Bucket as storage.
我们正在使用Google Cloud Bucket作为存储。 We were using Java Files.move method to move files from our Persistent Volume Claim (PVC) to the storage bucket:
我们使用Java Files.move方法将文件从持久卷声明(PVC)移到存储桶:
import java.nio.file.Files;
Files.move(source, target, StandardCopyOption.REPLACE_EXISTING)
But we're getting poor write performance. 但是我们的写入性能越来越差。 So we tried exploring Google Cloud Storage API to move files from our PVC to bucket.
因此,我们尝试探索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);
}
But only "before getService" is getting logged. 但是只有“ before getService”被记录。 And nothing happens after that.
在那之后什么也没有发生。 No exception is thrown.
没有异常被抛出。 The process gets stuck in getService()
进程卡在getService()中
The same application works on local deployment with Google Storage Bucket, but is not working on Kubernetes deployment. 相同的应用程序可以在使用Google Storage Bucket的本地部署中使用,但不适用于Kubernetes部署。
For me, updating the version of the Google Storage API fixed the issue. 对我来说,更新Google Storage API的版本可以解决此问题。 In my Gradle build file, I was using 1.36 and after switching to 1.42, it was working fine.
在我的Gradle构建文件中,我使用的是1.36,切换到1.42后,它运行良好。
The problem was due to the api version number in pom.xml (we're using Maven). 问题是由于pom.xml中的api版本号(我们正在使用Maven)所致。 Making the change to version 1.23.0 in pom.xml solved the problem.
在pom.xml中对版本1.23.0进行更改可以解决该问题。
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.23.0</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-jetty</artifactId>
<version>1.23.0</version>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.