blob: 3ec34e5c7aaf67a28519247d6929520d82ef6666 [file] [log] [blame]
Piotr Dobrowolski2c5391b2019-04-09 23:30:38 +02001#!/bin/bash
2
3# Generates s3cmd config from rook.io CephObjectStoreUser secrets fetched from
4# Kubernetes apiserver. Accepts extra K8S_INTERNAL=1 environment variable flag
5# that generates config that connects to internal rgw service.
6#
7# Usage:
8# ./rook-s3cmd-config USERNAME STORENAME CLUSTERNAME > config
9# s3cmd -c config --region "STORENAME:default-placement" mb s3://test/
10
11set -e
12
13username="${1:-registry}"
Sergiusz Bazanski9496d992019-09-02 16:32:40 +020014storename="${2:-waw-hdd-redundant-2-object}"
15clustername="${3:-ceph-waw2}"
Piotr Dobrowolski2c5391b2019-04-09 23:30:38 +020016
17secret="$(kubectl get secrets rook-ceph-object-user-$storename-$username -n $clustername -o json)"
18accesskey="$(echo "$secret" | jq -r '.data.AccessKey' | base64 -d)"
19secretkey="$(echo "$secret" | jq -r '.data.SecretKey' | base64 -d)"
20
21if [[ ! -z "$K8S_INTERNAL" ]]; then
22 domain="rook-ceph-rgw-$storename.$clustername.svc.cluster.local"
23else
24 domain="object.$clustername.hswaw.net"
25fi
26
27cat <<EOF
28[default]
29access_key = $accesskey
30secret_key = $secretkey
31host_base = $domain
32host_bucket = $domain
33EOF
34
35if [[ ! -z "$K8S_INTERNAL" ]]; then
36 echo "use_https = False"
37fi