-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d6326e1
Showing
3 changed files
with
275 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Credits | ||
# https://github.com/hetznercloud/ceph-s3-box | ||
# https://github.com/ceph/ceph-container | ||
|
||
FROM fedora:40 AS ceph | ||
ENV TZ=Etc/UTC | ||
RUN curl -JL "https://dl.filippo.io/mkcert/v1.4.4?for=linux/$(uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/)"\ | ||
-o mkcert \ | ||
&& chmod +x mkcert \ | ||
&& mv mkcert /usr/local/bin/mkcert \ | ||
&& mkcert -install | ||
RUN cat <<-EOF | tee /etc/dnf/dnf.conf | ||
[main] | ||
max_parallel_downloads=10 | ||
fastestmirror=True | ||
EOF | ||
RUN dnf -y upgrade --refresh \ | ||
--best \ | ||
--enhancement \ | ||
--newpackage \ | ||
--security \ | ||
--secseverity Critical \ | ||
--secseverity Important \ | ||
--secseverity Moderate \ | ||
--secseverity Low \ | ||
--bugfix \ | ||
--nodocs \ | ||
--allowerasing \ | ||
--setopt=install_weak_deps=False \ | ||
--verbose | ||
RUN dnf -y install \ | ||
hostname \ | ||
ceph-mon \ | ||
ceph-mgr \ | ||
ceph-osd \ | ||
ceph-radosgw \ | ||
s3cmd \ | ||
--best \ | ||
--nodocs \ | ||
--allowerasing \ | ||
--setopt=install_weak_deps=False \ | ||
--verbose | ||
RUN dnf -y autoremove | ||
RUN dnf clean all | ||
|
||
FROM ceph as radosgw | ||
ENV ACCESS_KEY="demo-key" | ||
ENV SECRET_KEY="demo-secret" | ||
ENV BUCKET_NAME="demo-bucket" | ||
|
||
EXPOSE 7480 7443 | ||
|
||
COPY ./entrypoint.sh /entrypoint | ||
ENTRYPOINT /entrypoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
## Lite Ceph S3 Gateway Testing Container | ||
|
||
### The container image provides a convenient test environment for AWS S3 compatible REST API | ||
|
||
The **Ceph OSD object store** utilizes **memstore** as a back-end and **RADOS REST Gateway** supports both **HTTP/HTTPS** protocols. | ||
|
||
### Environment Variables | ||
|
||
| Variable | Default value | | ||
|----------------|-----------------| | ||
| **ACCESS_KEY** | **demo-key** | | ||
| **SECRET_KEY** | **demo-secret** | | ||
| **BUCKET_NAME**| **demo-bucket** | | ||
|
||
### Ports | ||
|
||
- **7480 -> HTTP** | ||
- **7443 -> HTTPS** | ||
|
||
### Usage Instructions | ||
|
||
#### Pull | ||
``` | ||
podman pull docker.io/emadalblueshi/lite-ceph-s3-gw:v1.0.0 | ||
docker pull docker.io/emadalblueshi/lite-ceph-s3-gw:v1.0.0 | ||
``` | ||
#### Run | ||
``` | ||
podman run -d \ | ||
-p 7480:7480 \ | ||
-p 7443:7443 \ | ||
-e BUCKET_NAME="demo-bucket" \ | ||
-e ACCESS_KEY="demo-key" \ | ||
-e SECRET_KEY="demo-secret" \ | ||
-t emadalblueshi/lite-ceph-s3-gw:v1.0.0 | ||
docker run -d \ | ||
-p 7480:7480 \ | ||
-p 7443:7443 \ | ||
-e BUCKET_NAME="demo-bucket" \ | ||
-e ACCESS_KEY="demo-key" \ | ||
-e SECRET_KEY="demo-secret" \ | ||
-t emadalblueshi/lite-ceph-s3-gw:v1.0.0 | ||
``` | ||
### Test (HTTP) | ||
``` | ||
curl http://localhost:7480/demo-bucket/demo-object.txt | ||
``` | ||
### Test (HTTPS) | ||
``` | ||
curl -k https://localhost:7443/demo-bucket/demo-object.txt | ||
``` | ||
|
||
### Notes | ||
[The container image](https://github.com/EmadAlblueshi/lite-ceph-s3-gw) is lighter and faster than [ceph/demo](https://quay.io/repository/ceph/demo) because | ||
most modules are turned off except for the mandetory ones with `radosgw` during initializing. | ||
|
||
The main reason of this container image is to make **integration tests** easier for the projects. | ||
|
||
Honestly, **I'm NOT Ceph expert** but I did humble research to make the container image available for the community 🙂 | ||
|
||
### Contribution | ||
Suggestions and pull requests are welcome to optimize the container image for **testing environments** only. | ||
|
||
### Credits | ||
- [ceph-s3-box](https://github.com/hetznercloud/ceph-s3-box) | ||
- [yuezhu](https://gist.github.com/yuezhu/1b24e5d22054b56d271a3a61506a15de) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Credits | ||
# https://github.com/hetznercloud/ceph-s3-box | ||
# https://github.com/ceph/ceph-container | ||
|
||
set -eux | ||
set -o pipefail | ||
|
||
## | ||
# Configure s3cmd | ||
## | ||
|
||
cat <<-EOF | tee /root/.s3cfg | ||
[default] | ||
access_key = $ACCESS_KEY | ||
secret_key = $SECRET_KEY | ||
check_ssl_certificate = False | ||
guess_mime_type = False | ||
host_base = localhost:7480 | ||
host_bucket = localhost:7480/$BUCKET_NAME | ||
use_https = False | ||
EOF | ||
|
||
## | ||
# Create SSL for radosgw | ||
## | ||
|
||
mkcert -cert-file /etc/ssl/ceph.cert -key-file /etc/ssl/ceph.key localhost | ||
|
||
## | ||
# Configure ceph.conf | ||
## | ||
|
||
cat <<- EOF > /etc/ceph/ceph.conf | ||
[global] | ||
fsid = $(uuidgen) | ||
mon_host = $(hostname -i) | ||
auth_allow_insecure_global_id_reclaim = false | ||
mon_warn_on_pool_no_redundancy = false | ||
mon_osd_down_out_interval = 60 | ||
mon_osd_report_timeout = 300 | ||
mon_osd_down_out_subtree_limit = host | ||
mon_osd_reporter_subtree_level = rack | ||
osd_scrub_auto_repair = true | ||
osd_pool_default_size = 1 | ||
osd_pool_default_min_size = 1 | ||
osd_pool_default_pg_num = 1 | ||
osd_pool_default_pg_autoscale_mode = 1 | ||
osd_crush_chooseleaf_type = 0 | ||
osd_objectstore = memstore | ||
mgr_initial_modules = diskprediction_local stats | ||
mgr_standby_modules = 0 | ||
rgw_dns_name = localhost | ||
rgw_enable_usage_log = 1 | ||
[client.rgw.localhost] | ||
rgw_frontends ="beast port=7480 ssl_port=7443 ssl_certificate=/etc/ssl/ceph.cert ssl_private_key=/etc/ssl/ceph.key tcp_nodelay=0" | ||
EOF | ||
|
||
## | ||
# Create mon | ||
## | ||
|
||
ceph-authtool \ | ||
--create-keyring /tmp/ceph.mon.keyring \ | ||
--gen-key -n mon. \ | ||
--cap mon 'allow *' | ||
ceph-authtool \ | ||
--create-keyring /etc/ceph/ceph.client.admin.keyring \ | ||
--gen-key -n client.admin \ | ||
--cap mon 'allow *' \ | ||
--cap osd 'allow *' \ | ||
--cap mds 'allow *' \ | ||
--cap mgr 'allow *' | ||
ceph-authtool /tmp/ceph.mon.keyring \ | ||
--import-keyring /etc/ceph/ceph.client.admin.keyring | ||
|
||
monmaptool \ | ||
--create \ | ||
--add "localhost" "$(hostname -i)" \ | ||
--fsid "$(grep -oP '(?<=^fsid = )[0-9a-z-]*' /etc/ceph/ceph.conf)" \ | ||
--set-min-mon-release pacific \ | ||
--enable-all-features \ | ||
--clobber \ | ||
/tmp/monmap | ||
|
||
mkdir -p "/var/lib/ceph/mon/ceph-localhost" | ||
rm -rf "/var/lib/ceph/mon/ceph-localhost/*" | ||
ceph-mon --mkfs -i "localhost" --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring | ||
chown -R ceph:ceph /var/lib/ceph/mon/ | ||
ceph-mon --cluster ceph --id "localhost" --setuser ceph --setgroup ceph | ||
|
||
## | ||
# Create mgr | ||
## | ||
|
||
mkdir -p "/var/lib/ceph/mgr/ceph-localhost" | ||
ceph auth get-or-create "mgr.localhost" mon 'allow profile mgr' osd 'allow *' mds 'allow *' \ | ||
> "/var/lib/ceph/mgr/ceph-localhost/keyring" | ||
chown -R ceph:ceph /var/lib/ceph/mgr/ | ||
ceph-mgr --cluster ceph --id "localhost" --setuser ceph --setgroup ceph | ||
|
||
## | ||
# Create osd | ||
## | ||
|
||
OSD=$(ceph osd create) | ||
|
||
mkdir -p "/osd/osd.${OSD}/data" | ||
ceph auth get-or-create "osd.${OSD}" mon 'allow profile osd' mgr 'allow profile osd' osd 'allow *' \ | ||
> "/osd/osd.${OSD}/data/keyring" | ||
ceph-osd -i "${OSD}" --mkfs --osd-data "/osd/osd.${OSD}/data" | ||
chown -R ceph:ceph "/osd/osd.${OSD}/data" | ||
ceph-osd -i "${OSD}" --osd-data "/osd/osd.${OSD}/data" --keyring "/osd/osd.${OSD}/data/keyring" | ||
|
||
## | ||
# Create rgw | ||
## | ||
|
||
mkdir -p "/var/lib/ceph/radosgw/ceph-rgw.localhost" | ||
ceph auth get-or-create "client.rgw.localhost" osd 'allow rwx' mon 'allow rw' \ | ||
-o "/var/lib/ceph/radosgw/ceph-rgw.localhost/keyring" | ||
touch "/var/lib/ceph/radosgw/ceph-rgw.localhost/done" | ||
chown -R ceph:ceph /var/lib/ceph/radosgw | ||
|
||
## | ||
# Create admin user | ||
## | ||
|
||
radosgw-admin user create \ | ||
--uid=".admin" \ | ||
--display-name="admin" \ | ||
--system \ | ||
--key-type="s3" \ | ||
--access-key="${ACCESS_KEY}" \ | ||
--secret-key="${SECRET_KEY}" | ||
|
||
radosgw --cluster ceph --rgw-zone "default" --name "client.rgw.localhost" --setuser ceph --setgroup ceph | ||
|
||
s3cmd mb --quiet s3://$BUCKET_NAME | ||
|
||
echo "Successfully started" | ||
|
||
## | ||
# log output in forground | ||
## | ||
|
||
while ! tail -F /var/log/ceph/ceph* ; do | ||
sleep 0.1 | ||
done | ||
|
||
echo "Successfully terminated ..." |