ceph對象存儲設置policy
一、前言
本環境使用的ceph L版的對象存儲
二、軟件包准備
s3cmd-2.0.2-1.el7.noarch.rpm
三、操作步驟
1、編寫policy.json文件
[root@node1 ~]# vim policy.xml
{
"Version": "2012-10-17",
"Statement":[
{"Sid":"0",
"Effect":"Allow",
"Principal":"*",
"Action":"s3:*",
"Resource":"arn:aws:s3:::test/*",
"Condition":{
"StringLike":
{"aws:Referer":["http://10.168.106.22*"]}
}
}
]
}
2、 使用s3cmd 命令設置存儲桶的policy。
[root@compute0 ~]# s3cmd setpolicy policy.xml s3://test/
3、使用s3cmd 命令設置存儲桶的policy
[root@compute0 ~]# s3cmd info s3://test/
s3://test-yl/ (bucket):
Location: cn
Payer: BucketOwner
Expiration Rule: none
Policy: {
"Version": "2012-10-17",
"Statement":[
{"Sid":"2",
"Effect":"Allow",
"Principal":"*",
"Action":"s3:*",
"Resource":"arn:aws:s3:::test/*",
"Condition":{
"StringLike":
{"aws:Referer":["http://10.168.106.22*"]}
}
}
]
}
CORS: none
ACL: admin: FULL_CONTROL
四、注意事項
1、 存儲桶的acl規則,應該是private,默認bucket規則是私有的,如果不是需要手動設置,設置方式:
s3cmd setacl s3://test/ --acl-private
五、參數解釋
1、Version
有兩個值可選:默認是 2008-10-17
;對於本環境使用的ceph對象存儲,只能使用另外的一個值 2012-10-17
。
2、 Statement
是policy 的主體,該參數為必需參數。里面放的是列表。
"Statement": [{...},{...},{...}]
3、Sid
是一個可選的標識,當由多條statement 的時候,我們需要為每個statement 分配 一個Sid作為標識
4、Effect
是必需元素,它來指定這條statement 的作用是允許還是拒絕,它只有兩個值( Allow
和 Deny
)
5、Principal
使用Principal
策略中的元素來指定允許或拒絕訪問資源的用戶。
6、Action
用來描述指定動作(例如:s3:GetObject)
對於ceph使用的是S3協議,所以該值的寫法如下:
"Action": "s3:*"
"Action": "s3:GetObject"
7、Resource
指定特定的資源集合
寫法格式:
arn:partition:service:region:account-id:resource-id
arn:partition:service:region:account-id:resource-type/resource-id
arn:partition:service:region:account-id:resource-type:resource-id
partition :對於標准的aws 這個值為aws
service :這個值標識是aws什么產品可以是S3, IAM,RDS
region :資源所在的區域。某些資源的ARN不需要區域,因此可以省略
account-id :擁有資源的AWS賬戶的ID,不帶連字符。例如123456789012。某些資源的ARN不需要帳號,因此可以省略此組件。
resource:資源標識符,可以這樣定義( 子資源類型/父資源/子資源 )
resource-type:資源路徑 resource-id:資源名稱
s3 對象存儲寫法示意圖:
arn:aws:s3:::my_corporate_bucket/*
六、參考文檔
ceph 官方文檔: https://docs.ceph.com/docs/master/radosgw/bucketpolicy/
aws S3官方文檔 : https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_action.html https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html