|
2 | 2 |
|
3 | 3 | cd "$WALE_ENVDIR" |
4 | 4 |
|
5 | | -# access-key-id and access-secret-key files are mounted in via kubernetes secrets |
6 | | -AWS_ACCESS_KEY_ID=$(cat access-key-id) |
7 | | -AWS_SECRET_ACCESS_KEY=$(cat access-secret-key) |
8 | | -AWS_DEFAULT_REGION="us-east-1" |
9 | | -BUCKET_NAME="dbwal" |
10 | | - |
11 | | -if [ "$DATABASE_STORAGE" == "s3" ]; then |
| 5 | +if [[ "$DATABASE_STORAGE" == "s3" || "$DATABASE_STORAGE" == "minio" ]]; then |
12 | 6 | AWS_ACCESS_KEY_ID=$(cat /var/run/secrets/deis/objectstore/creds/accesskey) |
13 | 7 | AWS_SECRET_ACCESS_KEY=$(cat /var/run/secrets/deis/objectstore/creds/secretkey) |
14 | | - AWS_DEFAULT_REGION=$(cat /var/run/secrets/deis/objectstore/creds/region) |
15 | | - BUCKET_NAME=$(cat /var/run/secrets/deis/objectstore/creds/database-bucket) |
16 | | -else |
17 | | - # these only need to be set if we're not accessing S3 (boto will figure this out) |
18 | | - echo "http://$DEIS_MINIO_SERVICE_HOST:$DEIS_MINIO_SERVICE_PORT" > WALE_S3_ENDPOINT |
19 | | - if [ "$DEIS_MINIO_SERVICE_PORT" == "80" ]; then |
20 | | - # If you add port 80 to the end of the endpoint_url, boto3 freaks out. |
21 | | - # God I hate boto3 some days. |
22 | | - echo "http://$DEIS_MINIO_SERVICE_HOST" > S3_URL |
| 8 | + if [[ "$DATABASE_STORAGE" == "s3" ]]; then |
| 9 | + AWS_DEFAULT_REGION=$(cat /var/run/secrets/deis/objectstore/creds/region) |
| 10 | + BUCKET_NAME=$(cat /var/run/secrets/deis/objectstore/creds/database-bucket) |
23 | 11 | else |
24 | | - echo "http://$DEIS_MINIO_SERVICE_HOST:$DEIS_MINIO_SERVICE_PORT" > S3_URL |
| 12 | + # these only need to be set if we're not accessing S3 (boto will figure this out) |
| 13 | + echo "http://$DEIS_MINIO_SERVICE_HOST:$DEIS_MINIO_SERVICE_PORT" > WALE_S3_ENDPOINT |
| 14 | + if [ "$DEIS_MINIO_SERVICE_PORT" == "80" ]; then |
| 15 | + # If you add port 80 to the end of the endpoint_url, boto3 freaks out. |
| 16 | + # God I hate boto3 some days. |
| 17 | + echo "http://$DEIS_MINIO_SERVICE_HOST" > S3_URL |
| 18 | + else |
| 19 | + echo "http://$DEIS_MINIO_SERVICE_HOST:$DEIS_MINIO_SERVICE_PORT" > S3_URL |
| 20 | + fi |
| 21 | + AWS_DEFAULT_REGION="us-east-1" |
| 22 | + BUCKET_NAME="dbwal" |
25 | 23 | fi |
| 24 | + echo "s3://$BUCKET_NAME" > WALE_S3_PREFIX |
| 25 | + echo $AWS_ACCESS_KEY_ID > AWS_ACCESS_KEY_ID |
| 26 | + echo $AWS_SECRET_ACCESS_KEY > AWS_SECRET_ACCESS_KEY |
| 27 | + echo $AWS_DEFAULT_REGION > AWS_DEFAULT_REGION |
| 28 | + echo $BUCKET_NAME > BUCKET_NAME |
| 29 | +elif [ "$DATABASE_STORAGE" == "gcs" ]; then |
| 30 | + GS_APPLICATION_CREDS="/var/run/secrets/deis/objectstore/creds/key.json" |
| 31 | + BUCKET_NAME=$(cat /var/run/secrets/deis/objectstore/creds/database-bucket) |
| 32 | + echo "gs://$BUCKET_NAME" > WALE_GS_PREFIX |
| 33 | + echo $GS_APPLICATION_CREDS > GS_APPLICATION_CREDS |
| 34 | + echo $BUCKET_NAME > BUCKET_NAME |
| 35 | +elif [ "$DATABASE_STORAGE" == "azure" ]; then |
| 36 | + WABS_ACCOUNT_NAME=$(cat /var/run/secrets/deis/objectstore/creds/accountname) |
| 37 | + WABS_ACCESS_KEY=$(cat /var/run/secrets/deis/objectstore/creds/accountkey) |
| 38 | + BUCKET_NAME=$(cat /var/run/secrets/deis/objectstore/creds/database-container) |
| 39 | + echo $WABS_ACCOUNT_NAME > WABS_ACCOUNT_NAME |
| 40 | + echo $WABS_ACCESS_KEY > WABS_ACCESS_KEY |
| 41 | + echo "wabs://$BUCKET_NAME" > WALE_WABS_PREFIX |
| 42 | + echo $BUCKET_NAME > BUCKET_NAME |
26 | 43 | fi |
27 | | - |
28 | | -echo $AWS_ACCESS_KEY_ID > AWS_ACCESS_KEY_ID |
29 | | -echo $AWS_SECRET_ACCESS_KEY > AWS_SECRET_ACCESS_KEY |
30 | | -echo $AWS_DEFAULT_REGION > AWS_DEFAULT_REGION |
31 | | -echo $BUCKET_NAME > BUCKET_NAME |
32 | | - |
33 | | -# setup envvars for wal-e |
34 | | -echo "s3://$BUCKET_NAME" > WALE_S3_PREFIX |
35 | | - |
36 | | - |
37 | | -# setup boto config |
38 | | -mkdir -p /root/.aws /home/postgres/.aws |
39 | | - |
40 | | -cat << EOF > /root/.aws/credentials |
41 | | -[default] |
42 | | -aws_access_key_id = $AWS_ACCESS_KEY_ID |
43 | | -aws_secret_access_key = $AWS_SECRET_ACCESS_KEY |
44 | | -EOF |
45 | | - |
46 | | -if [ "$DATABASE_STORAGE" == "s3" ]; then |
47 | | - cat << EOF > /root/.aws/config |
48 | | -[default] |
49 | | -region = $AWS_DEFAULT_REGION |
50 | | -EOF |
51 | | -else |
52 | | - # HACK (bacongobbler): minio *must* use us-east-1 and signature version 4 |
53 | | - # for authentication. |
54 | | - # see https://github.com/minio/minio#how-to-use-aws-cli-with-minio |
55 | | - cat << EOF > /root/.aws/config |
56 | | -[default] |
57 | | -region = $AWS_DEFAULT_REGION |
58 | | -s3 = |
59 | | - signature_version = s3v4 |
60 | | -EOF |
61 | | -fi |
62 | | - |
63 | | -# write AWS config to postgres homedir as well |
64 | | -cp /root/.aws/* /home/postgres/.aws/ |
65 | | -chown -R postgres:postgres /home/postgres |
0 commit comments