|
2 | 2 |
|
3 | 3 | # Install AWS CLI
|
4 | 4 | sudo snap install aws-cli --classic
|
5 |
| - |
| 5 | +set -x |
6 | 6 |
|
7 | 7 | get_s3_endpoint(){
|
8 |
| - # Get S3 endpoint from MinIO |
9 |
| - kubectl get service minio -n minio-operator -o jsonpath='{.spec.clusterIP}' |
| 8 | + # Print the endpoint where the S3 bucket is exposed on. |
| 9 | + kubectl get service minio -n minio-operator -o jsonpath='{.spec.clusterIP}' |
| 10 | +} |
| 11 | + |
| 12 | + |
| 13 | +get_s3_access_key(){ |
| 14 | + # Print the S3 Access Key by reading it from K8s secret or by outputting the default value |
| 15 | + kubectl get secret -n minio-operator microk8s-user-1 &> /dev/null |
| 16 | + if [ $? -eq 0 ]; then |
| 17 | + # echo "Use access-key from secret" |
| 18 | + access_key=$(kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_ACCESS_KEY}' | base64 -d) |
| 19 | + else |
| 20 | + # echo "use default access-key" |
| 21 | + access_key="minio" |
| 22 | + fi |
| 23 | + echo "$access_key" |
10 | 24 | }
|
11 | 25 |
|
12 | 26 |
|
| 27 | +get_s3_secret_key(){ |
| 28 | + # Print the S3 Secret Key by reading it from K8s secret or by outputting the default value |
| 29 | + kubectl get secret -n minio-operator microk8s-user-1 &> /dev/null |
| 30 | + if [ $? -eq 0 ]; then |
| 31 | + # echo "Use access-key from secret" |
| 32 | + secret_key=$(kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_SECRET_KEY}' | base64 -d) |
| 33 | + else |
| 34 | + # echo "use default access-key" |
| 35 | + secret_key="minio123" |
| 36 | + fi |
| 37 | + echo "$secret_key" |
| 38 | +} |
| 39 | + |
13 | 40 | wait_and_retry(){
|
14 | 41 | # Retry a command for a number of times by waiting a few seconds.
|
15 | 42 |
|
@@ -37,8 +64,8 @@ wait_and_retry get_s3_endpoint
|
37 | 64 |
|
38 | 65 | S3_ENDPOINT=$(get_s3_endpoint)
|
39 | 66 | DEFAULT_REGION="us-east-2"
|
40 |
| -ACCESS_KEY=$(kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_ACCESS_KEY}' | base64 -d) |
41 |
| -SECRET_KEY=$(kubectl get secret -n minio-operator microk8s-user-1 -o jsonpath='{.data.CONSOLE_SECRET_KEY}' | base64 -d) |
| 67 | +ACCESS_KEY=$(get_s3_access_key) |
| 68 | +SECRET_KEY=$(get_s3_secret_key) |
42 | 69 |
|
43 | 70 | # Configure AWS CLI credentials
|
44 | 71 | aws configure set aws_access_key_id $ACCESS_KEY
|
|
0 commit comments