本文为 SPIRE 官方文档 plugin_server_bundlepublisher_gcp_cloudstorage 的中文译本,以英文原文为准。 🔗 穿越源码分析:Server 详解 · BundlePublisher
Server 插件:BundlePublisher "gcp_cloudstorage"
gcp_cloudstorage 插件将 server 当前的信任包(trust bundle)存入指定的 Google Cloud Storage 存储桶(bucket),并保持其持续更新。
该插件接受以下配置选项:
| 配置项 | 说明 | 是否必填 | 默认值 |
|---|---|---|---|
| service_account_file | 用于与 Cloud Storage API 进行认证的服务账号(service account)文件路径。 | 否。 | GOOGLE_APPLICATION_CREDENTIALS 环境变量的值。 |
| bucket_name | 信任包上传到的目标 Google Cloud Storage 存储桶名称。 | 是。 | |
| object_name | 存储桶内的对象名称(object name)。 | 是。 | |
| format | 信任包的存储格式,<spiffe | jwks | pem>。详见支持的信任包格式。 | 是。 | |
| refresh_hint | 使用 spiffe 格式时,设置信任包的刷新提示(refresh hint)。以字符串指定,例如 '10m'、'1h'。详见 time.ParseDuration。 | 否。 |
支持的信任包格式
支持以下信任包格式:
SPIFFE 格式
信任包表示为符合 RFC 7517 的 JWK Set,其具体参数在 SPIFFE Trust Domain and Bundle 规范中定义。其中同时包含 JWT authorities 与 X.509 authorities。
JWKS 格式
信任包编码为符合 RFC 7517 的 JWK Set,但省略了 SPIFFE 专有参数。其中同时包含 JWT authorities 与 X.509 authorities。
PEM 格式
信任包使用 PEM 编码格式。其中仅包含 X.509 authorities。
所需权限
插件要求在所配置的存储桶中,向已认证的服务账号授予以下 IAM 权限:
text
storage.objects.create
storage.objects.deletestorage.objects.delete 权限用于在信任包更新时覆盖原对象。
使用应用默认凭据(Application Default Credentials)的示例配置
以下配置将本地信任包内容上传到 spire-bundle 存储桶中的 example.org 对象。由于未配置 service_account_file,将使用应用默认凭据。
hcl
BundlePublisher "gcp_cloudstorage" {
plugin_data {
bucket = "spire-bundle"
object_name = "example.org"
format = "spiffe"
}
}使用服务账号文件的示例配置
以下配置将本地信任包内容上传到 spire-bundle 存储桶中的 example.org 对象。由于配置了 service_account_file,将使用给定的服务账号文件对 Cloud Storage API 进行认证。
hcl
BundlePublisher "gcp_cloudstorage" {
plugin_data {
service_account_file = "/path/to/service/account/file"
bucket = "spire-bundle"
object_name = "example.org"
format = "spiffe"
}
}