![](/img/trans.png)
[英]Unable to publish messages to GCP Pub/Sub using Python SDK when executed via Cron inside a GKE POD
[英]Why python code is unable to run inside a EKS pod container?
我有 EKS 集群设置,我在 pod 中下载 s3 存储桶对象。 我添加了具有 s3 完全访问权限和 KMS 角色的服务帐户。 但是我无法下载。
botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the GetObject operation: Access Denied
During handling of the above exception, another exception occurred:
我尝试过的事情:
执行到 pod 并运行 python 代码python3 s3_downloads.py
在此 s3 botocore 配置中,添加访问密钥和秘密密钥效果很好。 s3 = boto3.resource('s3', access-key,secret-key)
公开存储桶。
即使我添加了附加到服务帐户的适当角色,我也无法下载。 我想念任何配置吗? 任何帮助将不胜感激。
就我而言,问题是我错过了会话创建。 这是我的原始代码:
client = boto3.client('s3')
固定代码:
session = boto3.Session()
s3 = session.client('s3')
我在 EKS 集群上运行的 Pod 上执行此代码,缺少的行阻止我使用我为此部署定义的 ServiceAccount 角色。
这篇文章中关于 boto3 和会话管理的详细信息https://ben11kehoe.medium.com/boto3-sessions-and-why-you-should-use-them-9b094eb5ca8e
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.