kubernetes - gcsfuse 在 GKE 和/或 python3 boto 中安装存储桶以进行流式写入?
问题描述
我正在寻找一种将一些 .mp4 视频文件(因为它们是由某些 python 应用程序生成的)“写入流”到谷歌云存储桶的方法。python 应用程序已容器化并部署在 GKE 中,目前可以作为 Web 服务正常执行。但问题是所有视频文件都是在本地生成并存储在tmp/processed
pod 内的路径 ( ) 中。
但是,我希望将视频文件写入谷歌存储桶中名为my_bucket
.
我已阅读gcsfuse指南 ( https://github.com/maciekrb/gcs-fuse-sample ) 关于如何在 Kubernetes pod 中安装存储桶并阅读有关boto ( https://cloud.google.com/storage/docs /boto-plugin#streaming-transfers)用于将流传输到存储桶。
为了挂载my_bucket
,tmp/processed
我在我的应用程序的部署文件 (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,我想也许只是安装就足够了!但是,我的应用程序在尝试生成视频文件时给了我输入/输出错误。
现在我的问题是我是否需要同时使用gcsfuse和boto,或者只需将存储桶安装在我的 GKE pod 中就足够了?我安装对了吗?
更新:我验证我使用以下命令正确安装:
kubectl exec -it [POD_NAME] bash
解决方案
问题解决了!我只需要将我的桶安装在吊舱内,就是这样。安装脚本(如上面我的问题中所写)已正确完成。但是,导致的问题input/output error
是由于我的 GKE 集群没有足够的权限。基本上,集群没有读取/写入存储的权限,并且项目需要其他一些权限。因此,我使用以下命令创建了一个新集群:
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"
为了能够读取/写入存储桶,集群必须具有https://www.googleapis.com/auth/devstorage.read_write
权限。
此外,无需使用boto并通过gcsfuse 挂载就足以让我能够将流视频文件写入my_bucket
.
推荐阅读
- reactjs - 显示个人资料图片
- python - 当我按下一个按钮时,两个按钮被按下,pygame
- c# - .NET Core 2.2 将 cshtml 呈现为字符串
- java - Java x*0.01 和 x/100.0 不一样,为什么?
- javascript - 使用键盘存储以前的剑道下拉列表选项
- elasticsearch - 在 _reindex api 中的字段上使用 geo_point 数据类型
- ruby - 为什么 Ruby base64 编码的字符串与所有其他 base64 编码的字符串不同?
- mongodb-atlas - mongodb atlas alert 的调试流程
- python - 如何在两个值之间随机选择?
- spring-security - 如何绕过 Spring Boot 管理客户端中的 Spring Boot 安全性?