forked from yongkanghe/eks-k10
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigration-obs-location.sh
executable file
·50 lines (46 loc) · 1.57 KB
/
migration-obs-location.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
echo '-------Creating a S3 profile secret'
. ./setenv.sh
MY_PREFIX=$(echo $(whoami) | sed -e 's/\_//g' | sed -e 's/\.//g' | awk '{print tolower($0)}')
if [ ! -f hwcaccess ]; then
echo -n "Enter your Huawei Cloud Access Key ID and press [ENTER]: "
read HWC_AWS_ACCESS_KEY_ID
echo "" | awk '{print $1}'
echo $HWC_AWS_ACCESS_KEY_ID > hwcaccess
echo -n "Enter your Huawei Cloud Secret Access Key and press [ENTER]: "
read HWC_AWS_SECRET_ACCESS_KEY
echo $HWC_AWS_SECRET_ACCESS_KEY >> hwcaccess
fi
export MY_HW_REGION=ap-southeast-3
export MY_OBJECT_STORAGE_PROFILE=myobs-migration
export HWC_AWS_ACCESS_KEY_ID=$(cat hwcaccess | head -1)
export HWC_AWS_SECRET_ACCESS_KEY=$(cat hwcaccess | tail -1)
echo k10migration4yong > k10_migration_bucketname
kubectl create secret generic k10-obs-s3-secret \
--namespace kasten-io \
--type secrets.kanister.io/aws \
--from-literal=aws_access_key_id=$HWC_AWS_ACCESS_KEY_ID \
--from-literal=aws_secret_access_key=$HWC_AWS_SECRET_ACCESS_KEY
echo '-------Creating an OBS S3 profile'
cat <<EOF | kubectl apply -f -
apiVersion: config.kio.kasten.io/v1alpha1
kind: Profile
metadata:
name: $MY_OBJECT_STORAGE_PROFILE
namespace: kasten-io
spec:
type: Location
locationSpec:
credential:
secretType: AwsAccessKey
secret:
apiVersion: v1
kind: Secret
name: k10-obs-s3-secret
namespace: kasten-io
type: ObjectStore
objectStore:
name: $(cat k10_migration_bucketname)
objectStoreType: S3
region: $MY_HW_REGION
endpoint: obs.$MY_HW_REGION.myhuaweicloud.com
EOF