Cloud Object Storage (COS) アプリケーションとデータを IBM Cloud アカウント間で移行する
クラシック・インフラストラクチャー 仮想プライベートクラウド
このチュートリアルでは、あるアカウントの IBM Cloud Kubernetes Service クラスタから、別のアカウントの Red Hat OpenShift on IBM Cloud クラスタに COS アプリとデータを移行します。
前提条件
アカウント
アカウント1では、以下のものが必要です。
-
IBM Cloud Kubernetes Serviceクラスタ。
-
COSインスタンスとHMACクレデンシャルのセット。 詳細については、サービス認証情報。
-
クラスタにインストールされている COSプラグイン。
アカウント
移行先のアカウント2には、以下のものが必要です。
オプション: クラスターにアプリをデプロイする
アカウント
まだ移行したいアプリがない場合は、以下のサンプルアプリをデプロイできます。
-
オブジェクト・ストレージ構成を参照するPVCを作成します。
kind: PersistentVolumeClaim apiVersion: v1 metadata: name: demo #Enter a name for your PVC. namespace: default annotations: ibm.io/auto-create-bucket: "true" ibm.io/auto-delete-bucket: "false" ibm.io/secret-name: SECRET-NAME #Enter the name of the secret you created earlier. ibm.io/secret-namespace: NAMESPACE #Enter the namespace where you want to create the PVC. spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi storageClassName: ibmc-s3fs-cos #The storage class that you want to use. -
クラスター内に PVC を作成します。
oc apply -f pvc-cos.yaml -
作成したPVCをマウントするポッド用のYAML構成ファイルを作成します。
apiVersion: v1 kind: Pod metadata: name: demo-pod namespace: default spec: securityContext: runAsUser: 2000 fsGroup: 2000 volumes: - name: demo-vol persistentVolumeClaim: claimName: demo containers: - name: test image: nginxinc/nginx-unprivileged imagePullPolicy: Always volumeMounts: - name: demo-vol mountPath: /mnt/cosvol -
クラスター内にポッドを作成します。
oc apply -f demo-pod.yaml -
ポッドがデプロイされたことを確認します。 アプリが
Running状態になるまでに数分かかることがあることに注意してください。oc get podsNAME READY STATUS RESTARTS AGE demo-pod 1/1 Running 0 2m58s -
ポッドにログインして、アプリがブロック・ストレージ・ボリュームに書き込み可能であることを確認します。
oc exec demo-pod -- bash -c "ls /mnt/cosvol"
アプリの詳細を確認する
アカウント
- ポッドとPVCのリスト。
oc get pods - PVCについて説明し、詳細を確認し、バケツの名前をメモする。
oc describe PVC -o yaml
install rclone
インストール手順 については、rclone のドキュメントに従ってください。
アカウント1のバケットに'rclone を設定します
アカウント
rclone をインストールしたら、データを移行したいCOSインスタンスを定義する設定ファイルを生成する必要があります。
-
rclone configコマンドを実行します。rclone config出力例
2020/01/16 09:39:33 NOTICE: Config file "/Users/ryan/.config/rclone/rclone.conf" not found - using defaults No remotes found - make a new one n) New remote s) Set configuration password q) Quit config -
入力
n新しいリモコンを設定するには、リモコンの名前を入力します。n/s/q> nリモート名の例
name> cos-instance-1 -
プロバイダーのリストから選択
Amazon S3 Compliant Storage ProviderこれにはIBM COS。Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / 1Fichier \ "fichier" 2 / Alias for an existing remote \ "alias" 3 / Amazon Drive \ "amazon cloud drive" 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc) \ "s3" 5 / Backblaze B2 \ "b2" ... provider> 4 -
プロバイダー s3 として
IBM COSを選択してください。Choose your S3 provider. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / Amazon Web Services (AWS) S3 \ "AWS" 2 / Alibaba Cloud Object Storage System (OSS) formerly Aliyun \ "Alibaba" 3 / Ceph Object Storage \ "Ceph" 4 / Digital Ocean Spaces \ "DigitalOcean" 5 / Dreamhost DreamObjects \ "Dreamhost" 6 / IBM COS S3 \ "IBMCOS" 7 / Minio Object Storage \ "Minio" 8 / Netease Object Storage (NOS) \ "Netease" 9 / Wasabi Object Storage \ "Wasabi" 10 / Any other S3 compatible provider \ "Other" -
オプションを選択してCOS認証情報を追加します
1。Option env_auth. Get AWS credentials from runtime (environment variables or EC2/ECS meta data if no env vars). Only applies if access_key_id and secret_access_key is blank. Choose a number from below, or type in your own boolean value (true or false). Press Enter for the default (false). 1 / Enter AWS credentials in the next step. \ (false) 2 / Get AWS credentials from the environment (env vars or IAM). \ (true) env_auth> 1 -
プロンプトが表示されたら、
access_key_idそしてsecret_access_keyCOS インスタンスの。 詳細については、サービス認証情報。AWS Access Key ID. Leave blank for anonymous access or runtime credentials. Enter a string value. Press Enter for the default (""). access_key_id> xxxxxxxxxxxxxxxxxxxxx AWS Secret Access Key (password) Leave blank for anonymous access or runtime credentials. Enter a string value. Press Enter for the default (""). secret_access_key> xxxxxxxxxxxxxxxxxxxxxxxxxxxxx -
の中に
Region to connect toプロンプト、オプションを選択1。Region to connect to. Leave blank if you are using an S3 clone and you don't have a region. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / Use this if unsure. Will use v4 signatures and an empty region. \ "" 2 / Use this only if v4 signatures don't work, eg pre Jewel/v10 CEPH. \ "other-v2-signature" region> 1 -
の中に
Endpoint for IBM COS S3 APIプロンプト、オプションを選択1。Endpoint for IBM COS S3 API. Specify if using an IBM COS On Premise. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / US Cross Region Endpoint \ "s3-api.us-geo.objectstorage.softlayer.net" 2 / US Cross Region Dallas Endpoint \ "s3-api.dal.us-geo.objectstorage.softlayer.net" 3 / US Cross Region Washington DC Endpoint \ "s3-api.wdc-us-geo.objectstorage.softlayer.net" ... endpoint> 1 -
の中に
Location constraintプロンプト、押す戻るデフォルトを使用します。Location constraint - must match endpoint when using IBM Cloud Public. For on-prem COS, do not make a selection from this list, hit enter Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / US Cross Region Standard \ "us-standard" 2 / US Cross Region Vault \ "us-vault" 3 / US Cross Region Cold \ "us-cold" 4 / US Cross Region Flex \ "us-flex" ... -
ACLポリシープロンプトで、
private。Note that this ACL is applied when server side copying objects as S3 doesn't copy the ACL from the source but rather writes a fresh one. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / Owner gets FULL_CONTROL. No one else has access rights (default). This acl is available on IBM Cloud (Infra), IBM Cloud (Storage), On-Premise COS \ "private" 2 / Owner gets FULL_CONTROL. The AllUsers group gets READ access. This acl is available on IBM Cloud (Infra), IBM Cloud (Storage), On-Premise IBM COS \ "public-read" 3 / Owner gets FULL_CONTROL. The AllUsers group gets READ and WRITE access. This acl is available on IBM Cloud (Infra), On-Premise IBM COS \ "public-read-write" 4 / Owner gets FULL_CONTROL. The AuthenticatedUsers group gets READ access. Not supported on Buckets. This acl is available on IBM Cloud (Infra) and On-Premise IBM COS \ "authenticated-read" acl> 1 -
高度な設定オプションをスキップして、セットアップを確認します。
Edit advanced config? (y/n) y) Yes n) No y/n> n Remote config -------------------- [cos-instance-1] type = s3 provider = IBMCOS env_auth = false access_key_id = xxxxxx secret_access_key = xxxxxxxxx endpoint = s3-api.us-geo.objectstorage.softlayer.net location_constraint = us-standard acl = private -------------------- y) Yes this is OK e) Edit this remote d) Delete this remote y/e/d> y Current remotes: Name Type ==== ==== cos-instance-1 s3 -
2つ目のアカウントにCOSインスタンスを追加するには、前の手順を繰り返します。 情報を確認したら、
qを押して設定プロセスを終了します。
アカウント2のバケットに'rclone を設定する
アカウント
アカウント2の rclone を設定するために、この手順を繰り返します。
-
rclone configコマンドを実行します。rclone config出力例
2020/01/16 09:39:33 NOTICE: Config file "/Users/ryan/.config/rclone/rclone.conf" not found - using defaults No remotes found - make a new one n) New remote s) Set configuration password q) Quit config -
入力
n新しいリモコンを設定するには、リモコンの名前を入力します。n/s/q> nリモート名の例
name> cos-instance-2 -
プロバイダーのリストから選択
Amazon S3 Compliant Storage ProviderこれにはIBM COS。Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / 1Fichier \ "fichier" 2 / Alias for an existing remote \ "alias" 3 / Amazon Drive \ "amazon cloud drive" 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc) \ "s3" 5 / Backblaze B2 \ "b2" ... provider> 4 -
プロバイダー s3 として
IBM COSを選択してください。Choose your S3 provider. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / Amazon Web Services (AWS) S3 \ "AWS" 2 / Alibaba Cloud Object Storage System (OSS) formerly Aliyun \ "Alibaba" 3 / Ceph Object Storage \ "Ceph" 4 / Digital Ocean Spaces \ "DigitalOcean" 5 / Dreamhost DreamObjects \ "Dreamhost" 6 / IBM COS S3 \ "IBMCOS" 7 / Minio Object Storage \ "Minio" 8 / Netease Object Storage (NOS) \ "Netease" 9 / Wasabi Object Storage \ "Wasabi" 10 / Any other S3 compatible provider \ "Other" -
オプションを選択してCOS認証情報を追加します
1。Option env_auth. Get AWS credentials from runtime (environment variables or EC2/ECS meta data if no env vars). Only applies if access_key_id and secret_access_key is blank. Choose a number from below, or type in your own boolean value (true or false). Press Enter for the default (false). 1 / Enter AWS credentials in the next step. \ (false) 2 / Get AWS credentials from the environment (env vars or IAM). \ (true) env_auth> 1 -
プロンプトが表示されたら、
access_key_idそしてsecret_access_keyCOS インスタンスの。 詳細については、サービス認証情報。AWS Access Key ID. Leave blank for anonymous access or runtime credentials. Enter a string value. Press Enter for the default (""). access_key_id> xxxxxxxxxxxxxxxxxxxxx AWS Secret Access Key (password) Leave blank for anonymous access or runtime credentials. Enter a string value. Press Enter for the default (""). secret_access_key> xxxxxxxxxxxxxxxxxxxxxxxxxxxxx -
の中に
Region to connect toプロンプト、オプションを選択1。Region to connect to. Leave blank if you are using an S3 clone and you don't have a region. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / Use this if unsure. Will use v4 signatures and an empty region. \ "" 2 / Use this only if v4 signatures don't work, eg pre Jewel/v10 CEPH. \ "other-v2-signature" region> 1 -
の中に
Endpoint for IBM COS S3 APIプロンプト、オプションを選択1。Endpoint for IBM COS S3 API. Specify if using an IBM COS On Premise. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / US Cross Region Endpoint \ "s3-api.us-geo.objectstorage.softlayer.net" 2 / US Cross Region Dallas Endpoint \ "s3-api.dal.us-geo.objectstorage.softlayer.net" 3 / US Cross Region Washington DC Endpoint \ "s3-api.wdc-us-geo.objectstorage.softlayer.net" ... endpoint> 1 -
の中に
Location constraintプロンプト、押す戻るデフォルトを使用します。Location constraint - must match endpoint when using IBM Cloud Public. For on-prem COS, do not make a selection from this list, hit enter Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / US Cross Region Standard \ "us-standard" 2 / US Cross Region Vault \ "us-vault" 3 / US Cross Region Cold \ "us-cold" 4 / US Cross Region Flex \ "us-flex" ... -
ACLポリシープロンプトで、
private。Note that this ACL is applied when server side copying objects as S3 doesn't copy the ACL from the source but rather writes a fresh one. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / Owner gets FULL_CONTROL. No one else has access rights (default). This acl is available on IBM Cloud (Infra), IBM Cloud (Storage), On-Premise COS \ "private" 2 / Owner gets FULL_CONTROL. The AllUsers group gets READ access. This acl is available on IBM Cloud (Infra), IBM Cloud (Storage), On-Premise IBM COS \ "public-read" 3 / Owner gets FULL_CONTROL. The AllUsers group gets READ and WRITE access. This acl is available on IBM Cloud (Infra), On-Premise IBM COS \ "public-read-write" 4 / Owner gets FULL_CONTROL. The AuthenticatedUsers group gets READ access. Not supported on Buckets. This acl is available on IBM Cloud (Infra) and On-Premise IBM COS \ "authenticated-read" acl> 1 -
高度な設定オプションをスキップして、セットアップを確認します。
Edit advanced config? (y/n) y) Yes n) No y/n> n Remote config -------------------- [cos-instance-2] type = s3 provider = IBMCOS env_auth = false access_key_id = xxxxxx secret_access_key = xxxxxxxxx endpoint = s3-api.us-geo.objectstorage.softlayer.net location_constraint = us-standard acl = private -------------------- y) Yes this is OK e) Edit this remote d) Delete this remote y/e/d> y Current remotes: Name Type ==== ==== cos-instance-1 s3 cos-instance-2 s3 -
2つ目のアカウントにCOSインスタンスを追加するには、前の手順を繰り返します。 情報を確認したら、
qを押して設定プロセスを終了します。
COSバケットの中身を見る
アカウント アカウント
rclone を設定した後、各バケットの内容を確認し、各アカウントのバケット間でデータを同期します。
-
最初のインスタンスでバケットの内容を表示します。
rclone ls cos-instance-1:bucket-1 45338 test.txt -
インスタンス 2 のバケットの内容を表示します。 この例では、バケツ名は
bucket-2です。rclone ls cos-instance-2:bucket-2
バケット間のコンテンツの同期
アカウント アカウント
-
あるバケットから別のバケットにデータを移動するには、
rclone sync指示。 この例ではcos-instance-1:bucket-11つのアカウントにcos-instance-2:bucket-2別のアカウントにある COS の 2 番目のインスタンスです。例
rclone sync -P cos-instance-1:bucket-1 cos-instance-2:bucket-2出力例
Transferred: 754.933k / 754.933 kBytes, 100%, 151.979 kBytes/s, ETA 0s Errors: 0 Checks: 0 / 0, - Transferred: 18 / 18, 100% Elapsed time: 4.9 -
バケットの内容を確認する
cos-instance-1バケットに同期されましたcos-instance-2。rclone ls cos-instance-2:bucket-2出力例
45338 test.txt
アカウント2にアプリを再デプロイする
アカウント
-
以下のPVCをコピーし、ファイル名として
pvc.yamlkind: PersistentVolumeClaim apiVersion: v1 metadata: name: demo # Enter a name for your PVC. namespace: default annotations: ibm.io/bucket-name: "bucket-2" # Enter the name of the bucket in Account 2 ibm.io/auto-create-bucket: "false" ibm.io/auto-delete-bucket: "false" ibm.io/secret-name: SECRET-NAME #Enter the name of the secret you created earlier. ibm.io/secret-namespace: NAMESPACE #Enter the namespace where you want to create the PVC. spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi storageClassName: ibmc-s3fs-cos #The storage class that you want to use. -
クラスター内に PVC を作成します。
oc apply -f pvc.yaml -
作成したPVCをマウントするポッド用のYAML構成ファイルを作成します。
apiVersion: v1 kind: Pod metadata: name: demo-pod namespace: default spec: securityContext: runAsUser: 2000 fsGroup: 2000 volumes: - name: demo-vol persistentVolumeClaim: claimName: demo containers: - name: test image: nginxinc/nginx-unprivileged imagePullPolicy: Always volumeMounts: - name: demo-vol mountPath: /mnt/cosvol -
クラスター内にポッドを作成します。
oc apply -f demo-pod.yaml -
ポッドがデプロイされたことを確認します。 アプリが
Running状態になるまでに数分かかることがあることに注意してください。oc get podsNAME READY STATUS RESTARTS AGE demo-pod 1/1 Running 0 2m58s -
ポッドにログインして、アプリがブロック・ストレージ・ボリュームに書き込み可能であることを確認します。
oc exec demo-pod -- bash -c "ls /mnt/cosvol"test.txt