ノート:

Veleroを使用したAzure Kubernetesサービス・クラスタまたはAmazon EKSクラスタのContainer Engine for Kubernetesへの移行

イントロダクション

Veleroは、安全なバックアップとリストア、ディザスタ・リカバリの実行、Kubernetesクラスタ・リソースと永続ボリュームの移行を行うためのオープン・ソース・ツールです。Oracle Cloud Infrastructure (OCI) Object StorageはS3-Compatibleであるため、VeleroのAWSプラグインを使用できます。このチュートリアルでは、Azure Kubernetes Service (AKS)を使用しますが、このステップはAmazon Elastic Kubernetes Service (Amazon EKS)でもシームレスに機能する必要があります。

次の図は、プロセスの動作の概要を示しています。

ダイアグラム

このチュートリアルでは、永続ボリューム要求がアタッチされ、カスタムindex.htmlファイルがアタッチされているNGINXポッドと、ダミーのシークレットを準備しました。

  > kubectl get pods --n nginx      
  NAME          READY   STATUS    RESTARTS   AGE
  task-pv-pod   1/1     Running   0          47h
  > kubectl exec -it task-pv-pod --n nginx -- curl localhost
  AKS to OKE Migration with PVC attached
  >kubectl get secrets --namespace nginx
  NAME           TYPE     DATA   AGE
  okemigration   Opaque   1      2s

目的

前提条件

タスク1: 顧客秘密キーが内部にあるvelero-credentialsファイルの作成

  1. 顧客秘密キーがまだない場合は、これらのステップに従ってください。

  2. AKS/EKSおよびOKEクラスタ(またはCloud Shell)へのアクセスに使用するマシンで、次の内容のファイルvelero-credentialsを作成します:

      [default]
      aws_access_key_id=<<Access Key ID>>
      aws_secret_access_key=<<Generated Key>>
    
    

タスク2: Veleroのダウンロードとインストール

  1. これらのステップに従ってクラスタへのアクセスに使用するマシンにVeleroをインストールするか、Cloud Shellを使用する場合はここからダウンロードします。

  2. 次のコマンドを使用して、AKSクラスタとOKEクラスタの両方にVeleroのインストールに進みます。

    ノート: バイナリをダウンロードした場合は、最初から./を使用してveleroを実行します:

    velero install \
    --provider aws \
    --bucket <<Bucket name>> \
    --prefix <<Tenancy name>> \
    --use-volume-snapshots=false \
    --plugins velero/velero-plugin-for-aws:v1.6.0 \
    --secret-file <<Location of the file created with the customer secret key>> \
    --backup-location-config region=<<Region>>,s3ForcePathStyle="true",s3Url=https://<<tenancy name>>.compat.objectstorage.<<region>>.oraclecloud.com \
    --use-node-agent
    
  3. 次のコマンドを実行して、VeleroがAKSおよびOKEにインストールされたことを確認します。

    > kubectl get deployment -n velero
    NAME     READY   UP-TO-DATE   AVAILABLE   AGE
    velero   1/1     1            1           47h
    

タスク3: クラスタのバックアップ

  1. AKSクラスタで、次のコマンドを実行します。このチュートリアルでは、Azure CLIでダウンロードしたベレロ バイナリを使用しています。

    velero-v1.11.1-rc.1-linux-amd64> ./velero backup create nginxoke --include-namespaces nginx --default-volumes-to-fs-backup
    Backup request "nginxoke" submitted successfully.
    Run `velero backup describe nginxoke` or `velero backup logs nginxoke` for more details.
    
  2. クラスタがバックアップされていることを確認します。

       velero-v1.11.1-rc.1-linux-amd64> ./velero backup describe nginxoke
       Name:         nginxoke
       Namespace:    velero
       Labels:       velero.io/storage-location=default
       Annotations:  velero.io/source-cluster-k8s-gitversion=v1.24.10
                   velero.io/source-cluster-k8s-major-version=1
                   velero.io/source-cluster-k8s-minor-version=24
       Phase:  Completed
       Namespaces:
       Included:  nginx
       Excluded:  <none>
       .................
    You can also check the Object Storage Bucket:
    ![bucket](./images/bucket.png "Storage Bucket")
    

タスク4: OKEへのリストアまたは移行

  1. AKS、EKSおよびOKEは永続ボリューム要求に異なるstorageClassNamesを使用するため、ソースstorageClassNamesをOCI互換クラス名に変換するconfigMapを作成する必要があります。これを行うには、次の内容を含むファイルconfigMap.yamlを作成します。ソースstorageClassNameに適応します。

    重要: ステップ1を完了する必要があります。完了しないと、ポッドは保留状態のままになります。

    apiVersion: v1
    kind: ConfigMap
    metadata:
    # any name can be used; Velero uses the labels (below)
    # to identify it rather than the name
    name: change-storage-class-config
    # must be in the velero namespace
    namespace: velero
    # the below labels should be used verbatim in your
    # ConfigMap.
    labels:
        # this value-less label identifies the ConfigMap as
        # config for a plugin (i.e. the built-in change storage
        # class restore item action plugin)
        velero.io/plugin-config: ""
        # this label identifies the name and kind of plugin
        # that this ConfigMap is for.
        velero.io/change-storage-class: RestoreItemAction
    data:
    # add 1+ key-value pairs here, where the key is the old
    # storage class name and the value is the new storage
    # class name.
    <old-storage-class>: oci-bv
    
  2. 次のコマンドを使用して、OKEクラスタにconfigMapを適用します。

    kubectl apply -f configMap.yaml

  3. OKEクラスタがオブジェクト・ストレージからのバックアップにアクセスできることを確認します。

    $ velero get backup
    NAME         STATUS            ERRORS   WARNINGS   CREATED                          EXPIRES   STORAGE LOCATION   SELECTOR
    nginxoke     Completed         0        0          2023-07-22 14:40:33 +0300 EEST   29d       default            <none>
    
  4. 次のコマンドを実行してリストアを作成します。

    $ velero restore create --from-backup nginxoke
    Restore request "nginxoke-20230722145553" submitted successfully.
    Run `velero restore describe nginxoke-20230722145553` or `velero restore logs nginxoke-20230722145553` for more details.
    
  5. 復元ステータスを確認します。

    $ velero restore describe nginxoke-20230722145553
    Name:         nginxoke-20230722145553
    Namespace:    velero
    Labels:       <none>
    Annotations:  <none>
    Phase:                       Completed
    Total items to be restored:  7
    Items restored:              7
    Started:    2023-07-22 14:55:54 +0300 EEST
    Completed:  2023-07-22 14:56:45 +0300 EEST
    ..........
    
  6. クラスタが正常に移行されたことを確認します。

    $ kubectl get pod -n nginx
    NAME          READY   STATUS    RESTARTS   AGE
    task-pv-pod   1/1     Running   0          2m15s
    $ kubectl get secrets -n nginx
    NAME           TYPE     DATA   AGE
    okemigration   Opaque   1      2m21s
    $ kubectl get pvc -n nginx
    NAME            STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
    task-pv-claim   Bound    csi-d03267f7-32cf-4068-8809-d29aa649dcba   50Gi       RWO            oci-bv         2m31s
    $ kubectl exec task-pv-pod -n nginx -- curl http://localhost
    AKS to OKE Migration with PVC attached
    

承認

その他の学習リソース

docs.oracle.com/learnで他のラボをご覧いただくか、Oracle Learning YouTubeチャネルでより無料のラーニング・コンテンツにアクセスしてください。また、education.oracle.com/learning-explorerにアクセスして、Oracle Learning Explorerになります。

製品ドキュメントについては、Oracle Help Centerを参照してください。