すべてのプロダクト
Search
ドキュメントセンター

Container Registry:エッジクラスタでP2Pアクセラレーション機能を使用する

最終更新日:Jun 27, 2024

エッジクラスターでP2Pアクセラレーション機能を使用して、イメージプルを高速化し、アプリケーションのデプロイに使用する時間を短縮できます。 このトピックでは、エッジクラスタでP2Pアクセラレーション機能を使用する方法について説明します。

前提条件

  • Container Registry Enterprise Editionインスタンスが作成されました。 Container Registry Enterprise Editionインスタンスは、標準または高度なエディションである必要があります。 詳細については、「Container Registry Enterprise Editionインスタンスの作成」をご参照ください。

  • Container Registry Enterprise Editionインスタンスは、インターネット経由のエッジクラスターからのアクセスを許可するように設定されており、インスタンスのホワイトリストが設定されています。 詳細については、「インターネット経由のアクセスの設定」をご参照ください。

手順1: Container RegistryインスタンスのIDを取得する

  1. Container Registryコンソールにログインします。

  2. 上部のナビゲーションバーで、リージョンを選択します。

  3. 左側のナビゲーションウィンドウで、[インスタンス] をクリックします。

  4. [インスタンス] ページで、管理するEnterprise Editionインスタンスをクリックします。

  5. [概要] ページの左上隅にあるContainer RegistryインスタンスのIDを表示します。

ステップ2: P2Pコンポーネントのインストール

  1. ACKコンソールにログインします。

  2. ACKコンソールの左側のナビゲーションウィンドウで、[Marketplace] > [Marketplace] を選択します。

  3. アプリカタログページで、ack-edge-acr-acceleration-p2pコンポーネントを検索します。 ack-edge-acr-acceleration-p2pコンポーネントが見つかったら、コンポーネントのカードをクリックします。

  4. [デプロイ] ウィンドウで、エッジクラスターを選択します。

    重要

    パラメーターを設定する前に、エッジクラスターを選択する必要があります。 エッジクラスターを選択する前にパラメーターを設定した場合、パラメーターの設定は無効になります。

  5. コンポーネントの詳細ページの [パラメーター] タブで、registryInstancesパラメーターを手順1で取得したContainer RegistryインスタンスIDに設定します。

    複数のContainer Registryインスタンスが使用されている場合は、registryInstancesパラメーターを設定するときに、インスタンスIDをコンマ (,) で区切ります。

    説明

    デフォルトでは、P2Pコンポーネントはノードのポート65001を使用します。 ポート65001が別のコンポーネントで使用されている場合は、ビジネス要件に基づいてP2Pコンポーネントで使用されるポートを変更します。

    p2p:
      ...
      # Port of P2P Agent in host network
      port: 65001
    
      # Id of ACR registry instances, support multi, e.g. "cri-xxx,cri-yyy"
      registryInstances: <ACR instance Id>
  6. 、エッジクラスタの1つ以上のノードプールがP2PアクセラレーションのためにP2Pコンポーネントを使用できるように、plusModeパラメータを設定します。

    説明

    ノードプールの名前とIDを表示する方法の詳細については、「エッジクラスターでのノードプールの名前とIDの表示」をご参照ください。

    p2p:
      plusMode:   
        # Valid values: p2p and source. 
        # A value of p2p indicates that images are downloaded in P2P mode. 
        # A value of source indicates that images are downloaded from the registry-mirror component or a registry in the cloud. If you set the parameter to source, the scheduler component is not deployed to your cluster. 
        downloadPattern: "p2p"
        
        # The retention period of the data cached by the registry-mirror component. 
        cacheTTL: 24h
        
        # The path to which the data is cached by the registry-mirror component on the host. 
        # If this parameter is not specified, the cache will be lost when the registry-mirror container restarts. 
        cacheHostPath: ""    
    
        # Specify one or more node pools in the edge cluster. You can obtain the name and ID of each node pool in the Container Service for Kubernetes (ACK) console. 
        # name: the name of a node pool in the edge cluster. 
        # id: the ID of the node pool. 
        edgeNodePools:
          - name: ""
            id: ""      
        
        # If you set the parameter to true, the transfer acceleration feature of Object Storage Service (OSS) is enabled during the pull from origin over the Internet. This feature is applicable to scenarios where the Internet is unstable. For example, you can enable this feature when images are pulled across regions over the Internet. 
        # Before the configuration, make sure that the transfer acceleration feature is enabled in the OSS console. 
        ossInternetAccelerate: false    
       
        # If you set the parameter to true, the scheduler and registry-mirror components are deployed on a specified node. 
        # Before the configuration, you must add the following label to the node: k8s.aliyun.com/p2p-plus-node=true. 
        nodeSelectorEnable: false
  7. オプション: クラスターとContainer Registry Enterprise Editionインスタンスが異なるリージョンにある場合は、regionパラメーターをContainer Registry Enterprise Editionインスタンスのリージョンに設定します。

    # Your cluster and the Container Registry Enterprise Edition instance are in different regions. Specify the region of the Container Registry Enterprise Edition instance. 
    region: ""
  8. オプション: P2Pコンポーネントによるアップロードとダウンロードの合計帯域幅の上限を指定する場合は、ratelimitパラメーターを設定します。 デフォルト値は5メガバイト/秒です。 ノードの帯域幅に基づいて値を指定できます。

    p2p:
      # Total net rate limit (MBytes/s) for uploading and downloading
      ratelimit: "5M"
  9. [デプロイ] ウィンドウで、[作成] をクリックします。

ステップ3: P2Pアクセラレーションを有効にする

ポッドやデプロイメントなどのワークロードにP2Pアクセラレーションラベルを追加して、これらのワークロードのP2Pアクセラレーションを有効にすることができます。 ACKクラスターの名前空間にP2Pアクセラレーションラベルを追加することもできます。 このように、P2Pアクセラレーションは、この名前空間のアクセラレーション条件を満たすすべてのワークロードに対して有効になります。 これにより、P2Pアクセラレーションを有効にするために特定のワークロードのYAMLファイルを変更する必要がなくなります。 ビジネス要件に基づいてP2Pアクセラレーションラベルを追加する方法を選択します。

説明

P2Pアクセラレーションラベルの名前はk8s.aliyun.com/image-accelerate-modeで、値はp2pです。

  • ワークロードにP2Pアクセラレーションラベルを追加する

    この例では、展開にP2Pアクセラレーションラベルを追加します。 次のコマンドを実行して、デプロイのYAMLファイルを編集します。

    kubectl edit deploy <Deployment name>

    配置のYAMLファイルにラベルk8s.aliyun.com/image-accelerate-mode: p2pを追加します。

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: test
      labels:
        app: nginx
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            # enable P2P
            k8s.aliyun.com/image-accelerate-mode: p2p
            app: nginx
        spec:
          # your ACR instacne image pull secret
          imagePullSecrets:
          - name: test-registry
          containers:
          # your ACR instacne image
          - image: test-registry-vpc.cn-hangzhou.cr.aliyuncs.com/docker-builder/nginx:latest
            name: test
            command: ["sleep", "3600"]
  • P2Pアクセラレーションラベルを名前空間に追加する

    • ACKコンソールの名前空間にP2Pアクセラレーションラベルを追加する

      1. ACK コンソールにログインします。

      2. 左側のナビゲーションペインで、[クラスター] をクリックします。

      3. [クラスター] ページで、管理するクラスターを見つけ、クラスター名をクリックするか、[操作] 列の [詳細] をクリックします。

      4. 左側のナビゲーションウィンドウで、[名前空間とクォータ] をクリックします。

      5. [名前空間] ページで、設定する名前空間を見つけ、[操作] 列の [編集] をクリックします。

      6. [名前空間の編集] ダイアログボックスの [ラベル] セクションで、[変数キー] パラメーターをk8s.aliyun.com/image-accelerate-modeに、[変数値] パラメーターをp2pに設定し、[OK] をクリックします。

    • kubectlを使用してP2Pアクセラレーションラベルを名前空間に追加する

      kubectl label namespaces <your-namespace> k8s.aliyun.com/image-accelerate-mode=p2p

P2Pアクセラレーションの検証

ポッドに対してP2Pアクセラレーションを有効にすると、P2Pコンポーネントは自動的にP2P-related情報をポッドのYAMLファイルに追加します。 情報は、P2P-related注釈、P2P-accelerated画像のアドレス、およびP2P-accelerated画像をプルするための秘密を含む。

重要

P2P-acceleratedイメージをプルするためのSecretと元のイメージをプルするためのSecretは、イメージリポジトリのドメイン名が異なるだけです。 2つの秘密の他の構成は同じである。 元の画像をプルするためのシークレットでユーザー情報が無効である場合、P2P-accelerated画像もプルされません。

次のコマンドを実行して、ポッドのYAMLファイルを表示します。

kubectl get po <Pod name> -oyaml

期待される出力:

apiVersion: v1
kind: Pod
metadata:
  annotations:
    # inject p2p-annotations automatically
    k8s.aliyun.com/image-accelerate-mode: p2p
    k8s.aliyun.com/p2p-config: '...'
spec:
  containers:
   # inject image to p2p endpoint
   - image: test-registry-vpc.distributed.cn-hangzhou.cr.aliyuncs.com:65001/docker-builder/nginx:latest
  imagePullSecrets:
  - name: test-registry
  # inject image pull secret for p2p endpoint
  - name: acr-credential-test-registry-p2p

P2P-relatedのアノテーション、P2P-acceleratedイメージのアドレス、およびP2P-acceleratedイメージをプルするためのシークレットがYAMLファイルに存在する場合、P2Pアクセラレーションが有効になります。

エッジクラスター内のノードプールの名前とIDの表示

  1. ACKコンソールにログインします。

  2. ACKコンソールの左側のナビゲーションウィンドウで、[クラスター] をクリックします。

  3. [クラスター] ページで、管理するクラスターを見つけ、クラスターの名前をクリックするか、[操作] 列の [詳細] をクリックします。 クラスターの詳細ページが表示されます。

  4. 詳細ページの左側のナビゲーションウィンドウで、[ノード] > [ノードプール] を選択します。

  5. [ノードプール] ページで、すべてのノードプールの名前を表示します。 IDを表示するノードプールの名前をクリックします。

  6. ノードプールの詳細ページの [ノードプール情報] セクションで、ノードプールIDを表示します。