]> git.proxmox.com Git - ceph.git/blob - ceph/examples/lua/storage_class.md
buildsys: change download over to reef release
[ceph.git] / ceph / examples / lua / storage_class.md
1 # Introduction
2
3 This directory contains an example `storage_class.lua` on how to
4 use [Lua Scripting](https://docs.ceph.com/en/latest/radosgw/lua-scripting/)
5 to read and write the Storage Class field of a put request.
6
7 ## Usage - following examples based on vstart environment built in ceph/build and commands invoked from ceph/build
8
9 * Create Zonegroup placement info for a Storage Class (QLC_CLASS in this example) and point class to a data pool (qlc_pool in this example)
10 NOTE: RGW will need restarted due to the Zonegroup placement info change.
11 See: https://docs.ceph.com/en/latest/radosgw/placement/#zonegroup-zone-configuration for more information.
12
13 ```bash
14 # Create Storage Class
15 ./bin/radosgw-admin zonegroup placement add --rgw-zonegroup default --placement-id default-placement --storage-class QLC_CLASS
16 # Steer objects in QLC_CLASS to the qlc_pool data pool
17 ./bin/radosgw-admin zone placement add --rgw-zone default --placement-id default-placement --storage-class QLC_CLASS --data-pool qlc_pool
18 ```
19 * Restart radosgw for Zone/ZoneGroup placement changes to take effect.
20
21 * Upload the script:
22
23 ```bash
24 ./bin/radosgw-admin script put --infile=storage_class.lua --context=preRequest
25 ```
26
27 * Create a bucket and put and object with a Storage Class header (no modification will occur):
28 ```bash
29 aws --profile=ceph --endpoint=http://localhost:8000 s3api create-bucket --bucket test-bucket
30 aws --profile=ceph --endpoint=http://localhost:8000 s3api put-object --bucket test-bucket --key truv-0 --body ./64KiB_object.bin --storage-class STANDARD
31 ```
32
33 * Send a request without a Storage Class header (Storage Class will be changed to QLC_CLASS by Lua script):
34 ```bash
35 aws --profile=ceph --endpoint=http://localhost:8000 s3api put-object --bucket test-bucket --key truv-0 --body ./64KiB_object.bin
36 ```
37 NOTE: If you use s3cmd instead of aws command-line, s3cmd adds "STANDARD" StorageClass to any put request so the example Lua script will not modify it.
38
39 * Verify S3 object had its StorageClass header added
40 ```bash
41 grep Lua ceph/build/out/radosgw.8000.log
42
43 2021-11-01T17:10:14.048-0400 7f9c7f697640 20 Lua INFO: Put_Obj with StorageClass:
44 2021-11-01T17:10:14.048-0400 7f9c7f697640 20 Lua INFO: No StorageClass for Object and size >= threshold: truv-0 adding QLC StorageClass
45 ```
46
47 ## Requirements
48 * Lua 5.3
49