|
| 1 | +======================================= |
| 2 | +Testing the Ceph S3-Compatible Endpoint |
| 3 | +======================================= |
| 4 | + |
| 5 | +Ceph provides an S3-compatible service. While the service is REST-based, it |
| 6 | +is tedious to test by hand with `curl` or other tools, as the S3 protocol |
| 7 | +requires that requests are *signed* by ordering the headers and creating a |
| 8 | +hash. While easy-to-use tools are available, many assume the provider is Amazon |
| 9 | +and may be difficult to change. |
| 10 | +[Amazon S3 Documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/RESTAuthentication.html#ConstructingTheAuthenticationHeader) |
| 11 | + |
| 12 | +This how-to covers: |
| 13 | +* Required services in microceph |
| 14 | +* Creating authorized users |
| 15 | +* Installing and configuring the `s3cmd` tool |
| 16 | +* Creating a bucket, adding a file and removing the file and bucket |
| 17 | + |
| 18 | +Important Considerations |
| 19 | +------------------------ |
| 20 | + |
| 21 | +There are two ways to reference an S3 bucket: *path-style* and *virtual |
| 22 | +hosted-style*. Amazon has stated a preference to deprecate *path-style*, |
| 23 | +but as of September 2020 has decided to delay the deprecation. |
| 24 | +[Amazon S3 Documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/RESTAPI.html#virtual-hosted-path-style-requests) |
| 25 | +[Amazon S3 Blog](https://aws.amazon.com/blogs/aws/amazon-s3-path-deprecation-plan-the-rest-of-the-story/) |
| 26 | + |
| 27 | +Currently, ***Microceph supports only path-style bucket references.*** |
| 28 | + |
| 29 | +Prerequisites |
| 30 | +------------- |
| 31 | + |
| 32 | +This guide assumes that Microceph has been installed and confiugred as |
| 33 | +specified in this guide. Also, that the [enable service instances](enable-service-instances/) |
| 34 | +guide has been followed to create the RGW service. |
| 35 | + |
| 36 | +Create RADOS user |
| 37 | +----------------- |
| 38 | + |
| 39 | +On the Microceph node, use the :command:`radosgw-admin` tool. |
| 40 | + |
| 41 | +.. code-block:: none |
| 42 | +
|
| 43 | + admin@ceph-lab:~$ sudo radosgw-admin user create --uid=[userid] --display-name="[displayname]" |
| 44 | +
|
| 45 | +Where [userid] and [displayname] are replaced with appropriate values. |
| 46 | + |
| 47 | +This will return a JSON object: |
| 48 | +.. code-block:: JSON |
| 49 | +:emphasize-lines: 11,12 |
| 50 | + |
| 51 | + { |
| 52 | + "user_id": "[userid]", |
| 53 | + "display_name": "[displayname]", |
| 54 | + "email": "", |
| 55 | + "suspended": 0, |
| 56 | + "max_buckets": 1000, |
| 57 | + "subusers": [], |
| 58 | + "keys": [ |
| 59 | + { |
| 60 | + "user": "tanzu", |
| 61 | + "access_key": "[20-char text string]", |
| 62 | + "secret_key": "[40-char text string]" |
| 63 | + } |
| 64 | + ], |
| 65 | + "swift_keys": [], |
| 66 | + "caps": [], |
| 67 | + "op_mask": "read, write, delete", |
| 68 | + "default_placement": "", |
| 69 | + "default_storage_class": "", |
| 70 | + "placement_tags": [], |
| 71 | + "bucket_quota": |
| 72 | + { |
| 73 | + "enabled": false, |
| 74 | + "check_on_raw": false, |
| 75 | + "max_size": -1, |
| 76 | + "max_size_kb": 0, |
| 77 | + "max_objects": -1 |
| 78 | + }, |
| 79 | + "user_quota": |
| 80 | + { |
| 81 | + "enabled": false, |
| 82 | + "check_on_raw": false, |
| 83 | + "max_size": -1, |
| 84 | + "max_size_kb": 0, |
| 85 | + "max_objects": -1 |
| 86 | + }, |
| 87 | + "temp_url_keys": [], |
| 88 | + "type": "rgw", |
| 89 | + "mfa_ids": [] |
| 90 | + } |
| 91 | + |
| 92 | +Copy the **keys** data, specifically **keys.access_key** and **keys.secret_key**. |
| 93 | + |
| 94 | +Install and Configure s3cmd |
| 95 | +--------------------------- |
| 96 | + |
| 97 | +S3cmd is a Python-based tool created and open-sourced by s3tools.org [s3tools.org/s3cmd](https://s3tools.org/s3cmd) |
| 98 | +and may be [downloaded here](https://sourceforge.net/projects/s3tools/files/s3cmd/). |
| 99 | + |
| 100 | +After s3cmd is installed and verified by :command:`s3cmd --version`, configure |
| 101 | +s3cmd with the built-in tool that will go through a series of questions: |
| 102 | +:command:`s3cmd --configure` |
| 103 | + |
| 104 | +1. Access key |
| 105 | + |
| 106 | +Enter the access key copied from **keys.access_key** above. If these keys are |
| 107 | +lost, they can be retrieved by an administrator with |
| 108 | + |
| 109 | +.. code-block:: none |
| 110 | +
|
| 111 | + admin@ceph-lab:~$ sudo radosgw-admin user info --uid=[userid] |
| 112 | +
|
| 113 | +1. Secret key |
| 114 | + |
| 115 | +Enter the secret key copied from **keys.secret_key** above. |
| 116 | + |
| 117 | +1. Default region |
| 118 | + |
| 119 | +Press enter to accept the default. |
| 120 | + |
| 121 | +1. S3 Endpoint |
| 122 | + |
| 123 | +This is URL or IP Address to your Microceph server. Example: **ceph.lab.example.com** |
| 124 | +or **172.16.1.100** |
| 125 | + |
| 126 | +(Naturally, if a DNS name is used istead of an IP, there must be a DNS entry or |
| 127 | +hosts file entry made in the appropriate place to resolve the name.) |
| 128 | + |
| 129 | +1. DNS-style bucket+hostname:port template |
| 130 | + |
| 131 | +***Important*** This is where the virtual-host-style requests are configured. |
| 132 | +Since Microceph does not yet support this, enter the *same value as the S3 |
| 133 | +endpoint*, e.g. ceph.lab.example.com or 172.16.1.100 |
| 134 | + |
| 135 | +1. Encryption, GPG, Use HTTPS, HTTP Proxy |
| 136 | + |
| 137 | +For this test, enter blank for all, except HTTPS: enter No. |
| 138 | + |
| 139 | +1. Test access |
| 140 | + |
| 141 | +Press enter to test connectivity. This will check that the S3 endpoint is |
| 142 | +reachable, the user exists, and the access_key and secret_key are valid. |
| 143 | +It does not exercise the bucket specification or the rights of the user. |
| 144 | + |
| 145 | +1. Save settings |
| 146 | + |
| 147 | +Enter Y to save the settings to ~/.s3cfg. Other parameters can be edited |
| 148 | +in that file, but these are enough for the test. |
| 149 | + |
| 150 | + |
| 151 | +Test Using the Bucket |
| 152 | +--------------------- |
| 153 | + |
| 154 | +Create a bucket. Bucket names have specific rules about length, case and |
| 155 | +characters. Generally, they must be 3-63 characters, lowercase letters, |
| 156 | +numbers, dots . and hyphens -. The protocol must be specified in lower |
| 157 | +case. |
| 158 | + |
| 159 | +:command:`s3cmd mb s3://test` |
| 160 | + |
| 161 | +A message that the bucket is created should appear. |
| 162 | + |
| 163 | +:command:`s3cmd put [filename] s3://test` |
| 164 | + |
| 165 | +Upload statistics should appear. |
| 166 | + |
| 167 | +:command:`s3cmd del s3://test/[filename]` |
| 168 | + |
| 169 | +Delete message should appear. |
| 170 | + |
| 171 | +:command:`s3cmd rb s3://test` |
| 172 | + |
| 173 | +Removed message should appear. |
| 174 | + |
| 175 | + |
| 176 | +.. LINKS |
| 177 | +
|
| 178 | +.. _Manager service: https://docs.ceph.com/en/latest/mgr/ |
| 179 | +.. _Monitor service: https://docs.ceph.com/en/latest/man/8/ceph-mon/ |
| 180 | +.. _Metadata service: https://docs.ceph.com/en/latest/man/8/ceph-mds/ |
| 181 | +.. _RADOS Gateway service: https://docs.ceph.com/en/latest/radosgw/ |
0 commit comments