注意

本文档适用于 Ceph 的开发版本。

与 OpenStack Keystone 集成

Ceph 对象网关可以与 OpenStack 身份服务 Keystone 集成。这会设置网关以接受 Keystone 作为用户权限机构。Keystone 授权访问网关的用户也将自动在 Ceph 对象网关上创建(如果事先不存在)。Keystone 验证的令牌将被网关视为有效。

Keystone 集成有以下配置选项

[client.radosgw.gateway]
rgw keystone api version = {keystone api version}
rgw keystone url = {keystone server url:keystone server admin port}
rgw keystone admin token = {keystone admin token}
rgw keystone admin token path = {path to keystone admin token} #preferred
rgw keystone accepted roles = {accepted user roles}
rgw keystone token cache size = {number of tokens to cache}
rgw keystone implicit tenants = {true for private tenant for each new user}

也可以为 Keystone 配置一个 Keystone 服务租户、用户和密码(对于 OpenStack Identity API 的 v2.0 版本),类似于 OpenStack 服务的配置方式,这避免了在配置文件中设置共享密钥 rgw keystone admin token 的需要,建议在生产环境中禁用该选项。服务租户凭据应具有管理员权限,有关详细信息,请参阅 OpenStack Keystone 文档,其中详细解释了该过程。必要的配置选项是

rgw keystone admin user = {keystone service tenant user name}
rgw keystone admin password = {keystone service tenant user password}
rgw keystone admin password = {keystone service tenant user password path} # preferred
rgw keystone admin tenant = {keystone service tenant name}

Ceph 对象网关用户映射到一个 Keystone tenant。Keystone 用户在可能不止一个租户上分配有不同的角色。当 Ceph 对象网关获取票证时,它会查看租户以及分配给该票证的用户角色,并根据可配置的 rgw keystone accepted roles 接受/拒绝请求。

对于 OpenStack Identity API 的 v3 版本,您应该用以下选项替换 rgw keystone admin tenant

rgw keystone admin domain = {keystone admin domain name}
rgw keystone admin project = {keystone admin project name}

为了与以前版本的 ceph 兼容,也可以将 rgw keystone implicit tenants 设置为 s3swift。这会分割身份空间,使得指定的协议只使用隐式租户,而另一个协议永远不会使用隐式租户。一些较旧版本的 ceph 只支持 swift 的隐式租户。

Ocata(及更高版本)

Keystone 本身需要配置为将 Ceph 对象网关指向为对象存储端点

openstack service create --name=swift \
                           --description="Swift Service" \
                           object-store
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Swift Service                    |
| enabled     | True                             |
| id          | 37c4c0e79571404cb4644201a4a6e5ee |
| name        | swift                            |
| type        | object-store                     |
+-------------+----------------------------------+
openstack endpoint create --region RegionOne \
                            --publicurl   "http://radosgw.example.com:8080/swift/v1" \
                            --adminurl    "http://radosgw.example.com:8080/swift/v1" \
                            --internalurl "http://radosgw.example.com:8080/swift/v1" \
                            swift
+--------------+------------------------------------------+
| Field        | Value                                    |
+--------------+------------------------------------------+
| adminurl     | http://radosgw.example.com:8080/swift/v1 |
| id           | e4249d2b60e44743a67b5e5b38c18dd3         |
| internalurl  | http://radosgw.example.com:8080/swift/v1 |
| publicurl    | http://radosgw.example.com:8080/swift/v1 |
| region       | RegionOne                                |
| service_id   | 37c4c0e79571404cb4644201a4a6e5ee         |
| service_name | swift                                    |
| service_type | object-store                             |
+--------------+------------------------------------------+
openstack endpoint show object-store
+--------------+------------------------------------------+
| Field        | Value                                    |
+--------------+------------------------------------------+
| adminurl     | http://radosgw.example.com:8080/swift/v1 |
| enabled      | True                                     |
| id           | e4249d2b60e44743a67b5e5b38c18dd3         |
| internalurl  | http://radosgw.example.com:8080/swift/v1 |
| publicurl    | http://radosgw.example.com:8080/swift/v1 |
| region       | RegionOne                                |
| service_id   | 37c4c0e79571404cb4644201a4a6e5ee         |
| service_name | swift                                    |
| service_type | object-store                             |
+--------------+------------------------------------------+

注意

如果您的 radosgw ceph.conf 设置了配置选项 rgw swift account in url = true,则您的 object-store 端点 URL 必须设置为包含后缀 /v1/AUTH_%(tenant_id)s(而不是仅仅 /v1)。

Keystone URL 是 Keystone 管理 RESTful API URL。管理员令牌是 Keystone 内部为管理请求配置的令牌。

OpenStack Keystone 可能会使用自签名 SSL 证书终止,为了让 radosgw 在这种情况下与 Keystone 交互,您可以将 Keystone 的 SSL 证书安装在运行 radosgw 的节点上。或者,可以通过将可配置的 rgw keystone verify ssl 值设置为 false,使 radosgw 完全不验证 SSL 证书(类似于 OpenStack 客户端带有 --insecure 开关)。

跨项目(租户)访问

为了让一个项目(以前称为“租户”)访问属于不同项目的存储桶,需要启用以下配置选项

rgw swift account in url = true

相应地,Keystone 对象存储端点必须配置为包含 AUTH_%(project_id)s 后缀

openstack endpoint create --region RegionOne \
                            --publicurl   "http://radosgw.example.com:8080/swift/v1/AUTH_$(project_id)s" \
                            --adminurl    "http://radosgw.example.com:8080/swift/v1/AUTH_$(project_id)s" \
                            --internalurl "http://radosgw.example.com:8080/swift/v1/AUTH_$(project_id)s" \
                            swift
+--------------+--------------------------------------------------------------+
| Field        | Value                                                        |
+--------------+--------------------------------------------------------------+
| adminurl     | http://radosgw.example.com:8080/swift/v1/AUTH_$(project_id)s |
| id           | e4249d2b60e44743a67b5e5b38c18dd3                             |
| internalurl  | http://radosgw.example.com:8080/swift/v1/AUTH_$(project_id)s |
| publicurl    | http://radosgw.example.com:8080/swift/v1/AUTH_$(project_id)s |
| region       | RegionOne                                                    |
| service_id   | 37c4c0e79571404cb4644201a4a6e5ee                             |
| service_name | swift                                                        |
| service_type | object-store                                                 |
+--------------+--------------------------------------------------------------+

Keystone 与 S3 API 集成

如果设置了 rgw s3 auth use keystone 选项,即使使用 S3 API(带有类似 AWS 的访问和密钥),也可以使用 Keystone 进行身份验证。有关详细信息,请参阅 身份验证和 ACL

服务令牌支持

可以启用服务令牌支持 RadosGW Keystone 集成,以允许在请求中与有效服务令牌结合使用时允许过期令牌。

使用 rgw keystone service token enabled 启用支持,并使用 rgw keystone service token accepted roles 选项来指定哪些角色被视为服务角色。

rgw keystone expired token cache expiration 选项可用于调整允许使用服务令牌的过期令牌的缓存过期时间,请注意,这必须低于 Keystone 配置中的 [token]/allow_expired_window 选项。

启用此功能将导致 X-Auth-Token 标头中给定的过期令牌被允许,如果与包含具有被接受角色的有效令牌的 X-Service-Token 标头结合使用。这可以允许使用 X-Auth-Token 中的用户令牌的长时间运行进程在令牌过期后继续运行。

由 Ceph 基金会为您呈现

Ceph 文档是由非营利性 Ceph 基金会 资助和托管的社区资源。如果您希望支持这项工作和我们的其他努力,请考虑 立即加入