ノート:
- このチュートリアルではOracle Cloudへのアクセスが必要です。無料アカウントにサインアップするには、Oracle Cloud Infrastructure Free Tierの開始を参照してください。
- Oracle Cloud Infrastructure資格証明、テナンシおよびコンパートメントの値の例を使用します。演習を完了する場合は、これらの値をクラウド環境に固有の値に置き換えてください。
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
目的
- オブジェクト・ストレージ・バケットS3エンドポイントで使用する顧客秘密キーを作成します。
- AKSおよびOracle Cloud Infrastructure Container Engine for Kubernetes (OKE)にVeleroを設定します。
- バックアップおよびリストアを実行して、KubernetesネームスペースをOKEに移行します。
前提条件
- Kubernetesに関する中間知識。
- バックアップ・ポイントとして使用されるオブジェクト・ストレージ・バケット。
- オブジェクト・ストレージ・バケットでの読取り/書込みユーザー権限。
- Kubernetesクラスタへの接続に使用するコンピュータ、またはMicrosoft AzureとOCIの両方のクラウド・シェルの内部にあるVeleroバイナリ。
タスク1: 顧客秘密キーが内部にあるvelero-credentials
ファイルの作成
-
顧客秘密キーがまだない場合は、これらのステップに従ってください。
-
AKS/EKSおよびOKEクラスタ(またはCloud Shell)へのアクセスに使用するマシンで、次の内容のファイル
velero-credentials
を作成します:[default] aws_access_key_id=<<Access Key ID>> aws_secret_access_key=<<Generated Key>>
タスク2: Veleroのダウンロードとインストール
-
これらのステップに従ってクラスタへのアクセスに使用するマシンにVeleroをインストールするか、Cloud Shellを使用する場合はここからダウンロードします。
-
次のコマンドを使用して、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
-
次のコマンドを実行して、VeleroがAKSおよびOKEにインストールされたことを確認します。
> kubectl get deployment -n velero NAME READY UP-TO-DATE AVAILABLE AGE velero 1/1 1 1 47h
タスク3: クラスタのバックアップ
-
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.
-
クラスタがバックアップされていることを確認します。
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: 
タスク4: OKEへのリストアまたは移行
-
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
-
次のコマンドを使用して、OKEクラスタにconfigMapを適用します。
kubectl apply -f configMap.yaml
-
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>
-
次のコマンドを実行してリストアを作成します。
$ 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.
-
復元ステータスを確認します。
$ 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 ..........
-
クラスタが正常に移行されたことを確認します。
$ 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
関連リンク
承認
- Guido Alejandro Ferreyra(プリンシパル・クラウド・アーキテクト)
その他の学習リソース
docs.oracle.com/learnで他のラボをご覧いただくか、Oracle Learning YouTubeチャネルでより無料のラーニング・コンテンツにアクセスしてください。また、education.oracle.com/learning-explorerにアクセスして、Oracle Learning Explorerになります。
製品ドキュメントについては、Oracle Help Centerを参照してください。
Migrate your Azure Kubernetes Service Cluster or Amazon EKS Cluster to Container Engine for Kubernetes using Velero
F84712-01
August 2023
Copyright © 2023, Oracle and/or its affiliates.