简体   繁体   English

使用Storage API从Kubernetes部署进行Google Cloud Bucket连接

[英]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.

相关问题 kubernetes PersistentVolume over google 云存储桶 - kubernetes PersistentVolume over google cloud storage bucket 无法在谷歌云中使用kubernetes公开部署 - Not able to expose deployment using kubernetes in google cloud 如何将GCP上的Kubernetes引擎连接到外部Google Cloud Storage Bucket? - How do I connect Kubernetes Engine on GCP to an external Google Cloud Storage Bucket? Knative - kubernetes yaml 从谷歌云存储挂载数据 - Knative - kubernetes yaml to mount data from google cloud storage Google Cloud SQL使用错误的SSL证书建立来自kubernetes的套接字连接 - Google cloud sql using wrong ssl cert to to establish socket connection from kubernetes 谷歌云 Kubernetes 部署错误:字段不可变 - Google cloud Kubernetes deployment error: Field is immutable Apache 点燃谷歌云 Kubernetes 部署 - Apache Ignite Google cloud Kubernetes deployment Google Cloud Storage 作为 Kubernetes Stateful Set 的卷 - Google Cloud Storage as volume for Kubernetes Stateful Set 使用谷歌云 sdk 在 GCS 存储桶上上传数据时,Kube.netes cronjob 出现错误 - Getting error in Kubernetes cronjob while using google cloud sdk to upload data on GCS bucket 使用谷歌云 API 获取 kubernetes 配置文件 - Getting kubernetes config file using google-cloud API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM