gcsfuse 在 GKE and/or python3 boto 中安装一个桶来流式写入?
gcsfuse to mount a bucket in GKE and/or python3 boto to stream write?
我正在寻找一种方法 "write stream" 某些 .mp4 视频文件(因为它们是由某些 python 应用程序生成的)到 google 云存储桶。 python 应用程序已容器化并部署在 GKE 中,目前可以作为 Web 服务正常执行。但问题是所有的视频文件都是本地生成的,存储在pod内部的一个路径(tmp/processed
)中。
但是,我希望将视频文件写入名为 my_bucket
的 google 存储桶中的文件。
我已阅读 gcsfuse 准则 (https://github.com/maciekrb/gcs-fuse-sample) on how to mount a bucket in Kubernetes pods and also read about boto (https://cloud.google.com/storage/docs/boto-plugin#streaming-transfers),该准则用于将流传输到存储桶。
为了在 tmp/processed
中安装 my_bucket
,我已将以下行添加到我的应用程序的部署文件 (YAML) 中:
lifecycle:
postStart:
exec:
command:
- gcsfuse
- -o
- nonempty
- my_bucket
- tmp/processed
preStop:
exec:
command:
- fusermount
- -u
- tmp/processed/
securityContext:
capabilities:
add:
- SYS_ADMIN
我还没有使用过 boto,我想也许只是安装就足够了!但是,我的应用程序在尝试生成视频文件时出现 input/output 错误。
现在我的问题是我是否需要同时使用 gcsfuse 和 boto,或者只是将存储桶安装在我的 GKE pod 中足够的?我安装对了吗?
UPDATE:我验证了我使用以下命令正确挂载了:
kubectl exec -it [POD_NAME] bash
问题解决了!
我只需要将我的桶安装在吊舱内,仅此而已。安装脚本(如上面我的问题中所写)已正确完成。但是,导致 input/output error
的问题是由于我的 GKE 集群没有足够的权限。基本上,集群没有 read/write 存储权限,项目需要一些其他权限。因此,我使用以下命令创建了一个新集群:
gcloud container clusters create [MY_CLUSTER_NAME] \
--scopes=https://www.googleapis.com/auth/userinfo.email,cloud-platform,https://www.googleapis.com/auth/devstorage.read_write,storage-rw,trace,https://www.googleapis.com/auth/trace.append,https://www.googleapis.com/auth/servicecontrol,compute-rw,https://www.googleapis.com/auth/compute,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/taskqueue \
--num-nodes 4 --zone "us-central1-c"
要能够 read/write from/to 集群必须具有 https://www.googleapis.com/auth/devstorage.read_write
权限的存储桶。
此外,不需要使用 boto 并且通过 gcsfuse 安装就足以让我能够编写流视频文件到 my_bucket
.
我正在寻找一种方法 "write stream" 某些 .mp4 视频文件(因为它们是由某些 python 应用程序生成的)到 google 云存储桶。 python 应用程序已容器化并部署在 GKE 中,目前可以作为 Web 服务正常执行。但问题是所有的视频文件都是本地生成的,存储在pod内部的一个路径(tmp/processed
)中。
但是,我希望将视频文件写入名为 my_bucket
的 google 存储桶中的文件。
我已阅读 gcsfuse 准则 (https://github.com/maciekrb/gcs-fuse-sample) on how to mount a bucket in Kubernetes pods and also read about boto (https://cloud.google.com/storage/docs/boto-plugin#streaming-transfers),该准则用于将流传输到存储桶。
为了在 tmp/processed
中安装 my_bucket
,我已将以下行添加到我的应用程序的部署文件 (YAML) 中:
lifecycle:
postStart:
exec:
command:
- gcsfuse
- -o
- nonempty
- my_bucket
- tmp/processed
preStop:
exec:
command:
- fusermount
- -u
- tmp/processed/
securityContext:
capabilities:
add:
- SYS_ADMIN
我还没有使用过 boto,我想也许只是安装就足够了!但是,我的应用程序在尝试生成视频文件时出现 input/output 错误。
现在我的问题是我是否需要同时使用 gcsfuse 和 boto,或者只是将存储桶安装在我的 GKE pod 中足够的?我安装对了吗?
UPDATE:我验证了我使用以下命令正确挂载了:
kubectl exec -it [POD_NAME] bash
问题解决了!
我只需要将我的桶安装在吊舱内,仅此而已。安装脚本(如上面我的问题中所写)已正确完成。但是,导致 input/output error
的问题是由于我的 GKE 集群没有足够的权限。基本上,集群没有 read/write 存储权限,项目需要一些其他权限。因此,我使用以下命令创建了一个新集群:
gcloud container clusters create [MY_CLUSTER_NAME] \
--scopes=https://www.googleapis.com/auth/userinfo.email,cloud-platform,https://www.googleapis.com/auth/devstorage.read_write,storage-rw,trace,https://www.googleapis.com/auth/trace.append,https://www.googleapis.com/auth/servicecontrol,compute-rw,https://www.googleapis.com/auth/compute,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/taskqueue \
--num-nodes 4 --zone "us-central1-c"
要能够 read/write from/to 集群必须具有 https://www.googleapis.com/auth/devstorage.read_write
权限的存储桶。
此外,不需要使用 boto 并且通过 gcsfuse 安装就足以让我能够编写流视频文件到 my_bucket
.