In this exercise, you will configure the RADOS Gateway and access the gateway using the Swift API.
Outcomes
You should be able to configure the Ceph Object Gateway to allow access to Ceph object storage via the Swift API.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
[student@workstation ~]$ lab start api-swift
This command confirms that the hosts required for this exercise are accessible.
It installs the awscli package on clienta and creates the operator user and the testbucket bucket.
Procedure 9.2. Instructions
Log in to clienta as the admin user.
[student@workstation ~]$ ssh admin@clienta
[admin@clienta ~]$Create a Swift subuser called operator:swift on the Ceph Object Gateway for accessing object storage using the Swift API.
You are creating a new subuser attached to the operator user that was created by the lab start command.
The operator user can currently access Ceph object storage using the S3 API.
With this additional configuration, the operator user can create objects and buckets using the S3 API, and then use the Swift API to manage the same objects.
Use opswift as the Swift secret key.
Assign full permissions to the user.
[admin@clienta ~]$sudo cephadm shell -- radosgw-admin subuser create \ --uid="operator" --subuser="operator:swift" --access="full" --secret="opswift"{ "user_id": "operator", "display_name": "S3 Operator", "email": "operator@example.com", "suspended": 0, "max_buckets": 1000, "subusers": [ {"id": "operator:swift","permissions": "full-control" } ], "keys": [ { "user": "operator", "access_key": "12345", "secret_key": "67890" } ], "swift_keys": [ { "user": "operator:swift", "secret_key": "opswift" } ], "caps": [], "op_mask": "read, write, delete", "default_placement": "", "default_storage_class": "", ...output omitted...
Install the swift client on clienta.
Verify access using the operator:swift subuser credentials.
Use -K to specify the Swift secret key for the user.
Install the swift client on clienta.
[admin@clienta ~]$ sudo pip3 install --upgrade python-swiftclient
...output omitted...Verify the bucket status. Your output might be different in your lab environment.
[admin@clienta ~]$ swift -A http://serverc:80/auth/1.0 \
-U operator:swift -K opswift stat
Account: v1
Containers: 1
Objects: 0
Bytes: 0
Objects in policy "default-placement-bytes": 0
Bytes in policy "default-placement-bytes": 0
Containers in policy "default-placement": 1
Objects in policy "default-placement": 0
Bytes in policy "default-placement": 0
X-Timestamp: 1633518961.75503
X-Account-Bytes-Used-Actual: 0
X-Trans-Id: tx00000000000000000000a-00615d8571-ace6-default
X-Openstack-Request-Id: tx00000000000000000000a-00615d8571-ace6-default
Accept-Ranges: bytes
Content-Type: text/plain; charset=utf-8
Connection: Keep-AliveCreate and list the Swift containers.
List the currently available containers.
[admin@clienta ~]$ swift -A http://serverc:80/auth/1.0 \
-U operator:swift -K opswift list
testbucketCreate a Swift container called testcontainer.
[admin@clienta ~]$swift -A http://serverc:80/auth/1.0 \ -U operator:swift -K opswift post testcontainer[admin@clienta ~]$swift -A http://serverc:80/auth/1.0 \ -U operator:swift -K opswift listtestbucket testcontainer
Create a 10 MB file called swift.dat.
Upload the file to testcontainer.
[admin@clienta ~]$dd if=/dev/zero of=/tmp/swift.dat bs=1024K count=1010+0 records in 10+0 records out 10485760 bytes (10 MB) copied, 0.00926399 s, 1.1 GB/s [admin@clienta ~]$swift -A http://serverc:80/auth/1.0 \ -U operator:swift -K opswift upload testcontainer /tmp/swift.dattmp/swift.dat
View the statistics for testcontainer.
[admin@clienta ~]$ swift -A http://serverc:80/auth/1.0 \
-U operator:swift -K opswift stat testcontainer
Account: v1
Container: testcontainer
Objects: 1
Bytes: 10485760
Read ACL:
Write ACL:
Sync To:
Sync Key:
X-Timestamp: 1615999768.12521
X-Container-Bytes-Used-Actual: 10485760
X-Storage-Policy: default-placement
X-Storage-Class: STANDARD
Last-Modified: Wed, 06 Oct 2021 16:50:13 GMT
X-Trans-Id: tx000000000000000000013-0060523354-853f-default
X-Openstack-Request-Id: tx000000000000000000013-0060523354-853f-default
Accept-Ranges: bytes
Content-Type: text/plain; charset=utf-8
Connection: Keep-AliveView the statistics for the operator:swift subuser.
[admin@clienta ~]$swift -A http://serverc:80/auth/1.0 \ -U operator:swift -K opswift statAccount: v1 Containers:2Objects:1Bytes: 10485760 Containers in policy "default-placement": 2 Objects in policy "default-placement": 1 Bytes in policy "default-placement": 10485760 Objects in policy "default-placement-bytes": 0 Bytes in policy "default-placement-bytes": 0 X-Timestamp: 1615999935.32600 X-Account-Bytes-Used-Actual: 10485760 X-Trans-Id: tx000000000000000000015-00605233bf-853f-default X-Openstack-Request-Id: tx000000000000000000015-00605233bf-853f-default Accept-Ranges: bytes Content-Type: text/plain; charset=utf-8 Connection: Keep-Alive
Return to workstation as the student user.
[admin@clienta ~]$ exit
[student@workstation ~]$This concludes the guided exercise.