Bookmark this page

Guided Exercise: Providing Object Storage Using the Amazon S3 API

In this exercise, you will configure the RADOS Gateway and access the gateway using the Amazon S3 API.

Outcomes

You should be able to configure the Ceph Object Gateway to allow access to Ceph object storage via the Amazon S3 API.

[student@workstation ~]$ lab start api-s3

Procedure 9.1. Instructions

  1. Log in to clienta as the admin user.

    [student@workstation ~]$ ssh admin@clienta
    [admin@clienta ~]$
  2. Create an Amazon S3 API user called operator. Use 12345 as the S3 access key and 67890 as the secret key.

    [admin@clienta ~]$ sudo cephadm shell -- radosgw-admin user create \
      --uid="operator" --display-name="S3 Operator" --email="operator@example.com" \
      --access_key="12345" --secret="67890"
    {
        "user_id": "operator",
        "display_name": "S3 Operator",
        "email": "operator@example.com",
        "suspended": 0,
        "max_buckets": 1000,
        "subusers": [],
        "keys": [
            {
                "user": "operator",
                "access_key": "12345",
                "secret_key": "67890"
            }
        ],
        "swift_keys": [],
        "caps": [],
        "op_mask": "read, write, delete",
    ...output omitted...
  3. Configure the AWS CLI tool to use operator credentials. Enter 12345 as the access key and 67890 as the secret key.

    [admin@clienta ~]$ aws configure --profile=ceph
    AWS Access Key ID [None]: 12345
    AWS Secret Access Key [None]: 67890
    Default region name [None]: Enter
    Default output format [None]: Enter
  4. Create a bucket called testbucket. List the created bucket.

    [admin@clienta ~]$ aws --profile=ceph \
      --endpoint=http://serverc:80 s3 mb s3://testbucket
    make_bucket: testbucket
    [admin@clienta ~]$ aws --profile=ceph --endpoint=http://serverc:80 s3 ls
    2021-10-05 21:51:37 testbucket
  5. Create a 10 MB file called 10MB.bin. Upload the file to testbucket.

    [admin@clienta ~]$ dd if=/dev/zero of=/tmp/10MB.bin bs=1024K count=10
    10+0 records in
    10+0 records out
    10485760 bytes (10 MB, 10 MiB) copied, 0.00894909 s, 1.2 GB/s
    [admin@clienta ~]$ aws --profile=ceph --endpoint=http://serverc:80 \
      --acl=public-read-write s3 cp /tmp/10MB.bin s3://testbucket/10MB.bin
    upload: ../../tmp/10MB.bin to s3://testbucket/10MB.bin
  6. Verify that the S3 object is accessible using path-style URLs.

    [admin@clienta ~]$ wget -O /dev/null http://serverc:80/testbucket/10MB.bin
    --2021-10-05 22:03:37--  http://serverc/testbucket/10MB.bin
    Resolving serverc (serverc)... 172.25.250.12
    Connecting to serverc (serverc)|172.25.250.12|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 10485760 (10M) [application/octet-stream]
    
    Saving to: ‘/dev/null’
    
    10MB.bin  100%[===================================>]  10.00M  --.-KB/s  in 0.02s
  7. Use the radosgw-admin command to view the metadata of the testbucket bucket.

    [admin@clienta ~]$ sudo cephadm shell -- radosgw-admin bucket list
    [
      "testbucket"
    ]
    
    [admin@clienta ~]$ sudo cephadm shell -- radosgw-admin metadata \
      get bucket:testbucket
    {
        "key": "bucket:testbucket",
        "ver": {
            "tag": "_2d3Y6puJve1TnYs0pwHc0Go",
            "ver": 1
        },
        "mtime": "2021-10-06T01:51:37.514627Z",
        "data": {
            "bucket": {
                "name": "testbucket",
                "marker": "cb16a524-d938-4fa2-837f-d1f2011676e2.54360.1",
                "bucket_id": "cb16a524-d938-4fa2-837f-d1f2011676e2.54360.1",
                "tenant": "",
                "explicit_placement": {
                    "data_pool": "",
                    "data_extra_pool": "",
                    "index_pool": ""
                }
            },
            "owner": "operator",
            "creation_time": "2021-10-06T01:51:37.498002Z",
            "linked": "true",
            "has_bucket_info": "false"
        }
    }
  8. Return to workstation as the student user.

    [admin@clienta ~]$ exit
    [student@workstation ~]$

Finish

On the workstation machine, use the lab command to complete this exercise. This is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish api-s3

This concludes the guided exercise.

Revision: cl260-5.0-29d2128