- deploy a cephadm cluster with a custom build:
sudo cephadm --image <image> bootstrap --mon-ip <ip> --single-host-defaults
- start OSDs:
sudo cephadm shell ceph orch apply osd --all-available-devices
- enable the rgw service there:
sudo cephadm shell ceph orch apply rgw <service name>
this will create 2 RGWs, one listening on port 80 and one on port 81.
- set logging to files and increase rgw log level to 20:
sudo cephadm shell ceph config set global log_to_file 1
sudo cephadm shell ceph config set global debug_rgw 20
- add a lua package :
sudo cephadm shell radosgw-admin script-package add --package <packge name> --allow-compilation
- restart the rgw service for the change to happen:
sudo cephadm shell ceph orch restart rgw.<service name>
- look at the RGW logs to see that the lua packages were created:
sudo cephadm logs --name rgw.<service name>.<host>.<rgw instance> | grep -i lua
(use sudo cephadm ls
to get the actual name).
- upload lua script that uses a package. for example, if we added
luajson
andluasocket
libraries, and if the following file is/tmp/test.lua
on the host:
local json = require("json")
local socket = require("socket")
local unix = require("socket.unix")
local s = assert(unix())
E = {}
msg = {bucket = (Request.Bucket or (Request.CopyFrom or E).Bucket).Name,
time = Request.Time,
operation = Request.RGWOp,
http_status = Request.Response.HTTPStatusCode,
error_code = Request.Response.HTTPStatus,
object_size = Request.Object.Size,
trans_id = Request.TransactionId}
print(json.encode(msg).."\n")
it should be uploaded via:
sudo cephadm shell radosgw-admin script put --infile /rootfs/tmp/test.lua --context postrequest
- get credentials for the "dashboard" user that was created by cephadm:
sudo cephadm shell radosgw-admin user info --uid dashboard
- and export them:
export AWS_SECRET_ACCESS_KEY=XXX
export AWS_ACCESS_KEY_ID=XXX
- upload a file to a bucket, and verify the lua print in the log:
aws --region=default --endpoint-url http://localhost:80 s3 mb s3://fish
head -c 512 </dev/urandom > myfile
aws --region=default --endpoint-url http://localhost:80 s3 cp myfile s3://fish