Migrazione di applicazioni e dati Cloud Object Storage (COS) tra gli account IBM Cloud

Infrastruttura classica Virtual Private Cloud

In questa esercitazione, migreremo un'applicazione COS e i dati da un cluster IBM Cloud Kubernetes Service in un account, a un cluster Red Hat OpenShift on IBM Cloud in un account separato.

Prerequisiti

Conto 1

Nel Conto 1, è necessario disporre di quanto segue.

Conto 2

Nell'account 2, l'account di destinazione verso cui eseguire la migrazione, è necessario disporre di quanto segue.

Facoltativo: distribuire un'app nel cluster

Conto 1

Se non si dispone già di un'applicazione da migrare, è possibile distribuire la seguente applicazione di esempio.

  1. Creare un PVC che faccia riferimento alla configurazione di archiviazione degli oggetti.

    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.
    
  2. Crea la PVC nel tuo cluster.

    oc apply -f pvc-cos.yaml
    
  3. Creare un file di configurazione YAML per un pod che monti il PVC creato.

    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
    
  4. Crea il pod nel tuo cluster.

    oc apply -f demo-pod.yaml
    
  5. Verificare che il pod sia stato distribuito. Si noti che potrebbero essere necessari alcuni minuti prima che l'app entri in uno Running stato.

    oc get pods
    
    NAME                                READY   STATUS    RESTARTS   AGE
    demo-pod                            1/1     Running   0          2m58s
    
  6. Verificare che l'applicazione possa scrivere sul volume di archiviazione a blocchi accedendo al pod.

    oc exec demo-pod -- bash -c "ls /mnt/cosvol"
    

Ottieni i dettagli della tua app

Conto 1

  1. Elencare i pod e i PVC.
    oc get pods
    
  2. Descrivete il vostro PVC, rivedete i dettagli e annotate il nome del secchio.
    oc describe PVC -o yaml
    

Installa rclone

Seguire i documenti rclone per le fasi di installazione.

Configurare 'rclone per il proprio bucket nell'Account 1

Conto 1

Dopo aver installato rclone, è necessario generare un file di configurazione che definisca l'istanza COS da cui si desidera migrare i dati.

  1. Eseguite il comando rclone config.

    rclone config
    

    Output di esempio

    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
    
  2. accedere n per configurare un nuovo telecomando, quindi fornire un nome per il telecomando.

    n/s/q> n
    

    Esempio di nome remoto

    name> cos-instance-1
    
  3. Dall'elenco dei fornitori, seleziona Amazon S3 Compliant Storage Provider che include 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
    
  4. Seleziona IBM COS come tuo s3 fornitore.

    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"
    
  5. Aggiungi le tue credenziali COS selezionando l'opzione 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
    
  6. Quando richiesto, fornire il file access_key_id E secret_access_key della tua istanza COS. Per ulteriori informazioni, vedere Credenziali del servizio.

    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
    
  7. Nel Region to connect to richiesta, selezionare l'opzione 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
    
  8. Nel Endpoint for IBM COS S3 API richiesta, selezionare l'opzione 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
    
  9. Nel Location constraint richiesta, premere Ritorno per utilizzare l'impostazione predefinita.

    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"
    ...
    
  10. Nella richiesta del criterio ACL, selezionare 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
    
  11. Salta l'opzione di configurazione avanzata e conferma la configurazione.

    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
    
  12. Ripetere i passaggi precedenti per aggiungere l'istanza COS al secondo account. Una volta verificate le informazioni, premere q per uscire dal processo di configurazione.

Configurare 'rclone per il proprio bucket nell'Account 2

Conto 2

Ripetere i passaggi per configurare rclone per l'Account 2.

  1. Eseguite il comando rclone config.

    rclone config
    

    Output di esempio

    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
    
  2. accedere n per configurare un nuovo telecomando, quindi fornire un nome per il telecomando.

    n/s/q> n
    

    Esempio di nome remoto

    name> cos-instance-2
    
  3. Dall'elenco dei fornitori, seleziona Amazon S3 Compliant Storage Provider che include 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
    
  4. Seleziona IBM COS come tuo s3 fornitore.

    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"
    
  5. Aggiungi le tue credenziali COS selezionando l'opzione 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
    
  6. Quando richiesto, fornire il file access_key_id E secret_access_key della tua istanza COS. Per ulteriori informazioni, vedere Credenziali del servizio.

    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
    
  7. Nel Region to connect to richiesta, selezionare l'opzione 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
    
  8. Nel Endpoint for IBM COS S3 API richiesta, selezionare l'opzione 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
    
  9. Nel Location constraint richiesta, premere Ritorno per utilizzare l'impostazione predefinita.

    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"
    ...
    
  10. Nella richiesta del criterio ACL, selezionare 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
    
  11. Salta l'opzione di configurazione avanzata e conferma la configurazione.

    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
    
  12. Ripetere i passaggi precedenti per aggiungere l'istanza COS al secondo account. Una volta verificate le informazioni, premere q per uscire dal processo di configurazione.

Visualizzare il contenuto dei bucket COS

Conto 1 Conto 2

Dopo aver configurato rclone, esaminare il contenuto di ciascun bucket e sincronizzare i dati tra i bucket di ciascun account.

  1. Visualizza in prima istanza il contenuto del bucket.

    rclone ls cos-instance-1:bucket-1
        45338 test.txt
    
  2. Visualizza il contenuto del bucket nell'istanza 2. In questo esempio il nome del bucket è bucket-2.

    rclone ls cos-instance-2:bucket-2
    

Sincronizzazione dei contenuti tra bucket

Conto 1 Conto 2

  1. Per spostare i dati da un bucket all'altro, puoi utilizzare il file rclone sync comando. In questo esempio cos-instance-1:bucket-1 è in un account mentre cos-instance-2:bucket-2 è una seconda istanza di COS in un conto separato.

    Esempio

    rclone sync -P cos-instance-1:bucket-1 cos-instance-2:bucket-2
    

    Output di esempio

    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
    
  2. Verificare il contenuto del secchio cos-instance-1 sono stati sincronizzati con il bucket in cos-instance-2.

    rclone ls cos-instance-2:bucket-2
    

    Output di esempio

    45338 test.txt
    

Reimpiegare l'applicazione nell'account 2

Conto 2

  1. Accedi al tuo cluster Red Hat OpenShift.

  2. Copia il seguente codice PVC e salvalo in un file chiamato pvc.yaml

    kind: 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.
    
  3. Crea la PVC nel tuo cluster.

    oc apply -f pvc.yaml
    
  4. Creare un file di configurazione YAML per un pod che monti il PVC creato.

    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
    
  5. Crea il pod nel tuo cluster.

    oc apply -f demo-pod.yaml
    
  6. Verificare che il pod sia stato distribuito. Si noti che potrebbero essere necessari alcuni minuti prima che l'app entri in uno Running stato.

    oc get pods
    
    NAME                                READY   STATUS    RESTARTS   AGE
    demo-pod                            1/1     Running   0          2m58s
    
  7. Verificare che l'applicazione possa scrivere sul volume di archiviazione a blocchi accedendo al pod.

    oc exec demo-pod -- bash -c "ls /mnt/cosvol"
    
    test.txt