スキップしてコンテンツを表示

既存の Amazon EKS クラスターに新しいサブネットを追加する方法を教えてください。

所要時間2分
0

Amazon Elastic Kubernetes サービス (Amazon EKS) クラスターコントロールプレーンに新しいサブネットを追加しようとしています。

簡単な説明

新しいアベイラビリティーゾーンにサブネットを追加したり、既存のアベイラビリティーゾーンからサブネットを削除したりすると、次のようなエラーメッセージが表示される場合があります。

「An error occurred (InvalidParameterException) when calling the UpdateClusterConfig operation: Provided subnets belong to the AZs 'us-west-2a,us-west-2c,us-west-2d'.But they should belong to the exact set of AZs 'us-west-2a,us-west-2c' in which subnets were provided during cluster creation. (指定されたサブネットは、アベイラビリティー 'us-west-2a,us-west-2c,us-west-2d' に属していますが、クラスターの作成時にサブネットに指定した AZ 'us-west-2a,us-west-2c,us-west-2d' と完全に一致させる必要があります)」

サブネットは、クラスターの作成時に AWS が選択したアベイラビリティーゾーンと同一のアベイラビリティーゾーンセットに属している必要があります。また、サブネットは、クラスターの作成時に AWS が指定した Amazon 仮想プライベートクラウド (Amazon VPC) と同じ VPC 内にある必要があります。VPC には、クラスターが使用するのに十分な IP アドレス数が必要です。詳細については、「サブネットを作成する」および「VPC の要件と考慮事項」を参照してください。

解決策

Amazon EKS クラスターサブネットの変更には、Amazon EKS コンソール、AWS CLI、または eksctl CLI を使用できます。

Amazon EKS コンソールを使用する

次の手順を実行します。

  1. Amazon EKS コンソールを開きます。
  2. ナビゲーションペインで [クラスター] を選択します。
  3. [ネットワーク] を選択し、[VPC リソースの管理] を選択します。
  4. [サブネット] メニューで、追加するサブネットを選択します。
  5. [保存] を選択します。
  6. [ネットワーク] セクションで、サブネットが追加されたことを確認します。

AWS CLI を使用する

注: AWS コマンドラインインターフェイス (AWS CLI) コマンドの実行中にエラーが発生した場合は、「AWS CLI で発生したエラーのトラブルシューティング」を参照してください。また、AWS CLI の最新バージョンを使用していることを確認してください。

この AWS CLI コマンドは、既存のクラスターサブネットを、コマンドで指定したサブネットに置き換えます。サブネットを追加するには、既存のサブネットと追加のサブネットを指定します。

  1. describe-subnets コマンドを実行すると、EKS クラスターに設定したアベイラビリティーゾーンを特定できます。

    aws ec2 describe-subnets --subnet-ids $(aws eks describe-cluster --name your-cluster-name --query 'cluster.resourcesVpcConfig.subnetIds' --output text) --query 'Subnets[*].AvailabilityZone'

    注: your-cluster-name を実際のクラスター名に、例示したサブネット ID を実際のサブネット ID に置き換えてください。
    出力例:

    [
        "us-west-2c",
        "us-west-2d",
        "us-west-2a"
    ]
  2. update-cluster-config コマンドを実行し、クラスターコントロールプレーンのサブネットを更新します。

    aws eks update-cluster-config --name your-cluster-name \
    --resources-vpc-config subnetIds=subnet-1234,subnet-5678,subnet-9101

    注: your-cluster-name を実際のクラスター名に、例示したサブネット ID を実際のサブネット ID に置き換えてください。新しいサブネットを追加する際は、元のセットの各アベイラビリティーゾーンを 1 つ以上のサブネットで表記する必要があります。アベイラビリティーゾーンで既存のサブネットを維持する場合は、コマンドでそのサブネットを指定してください。
    次の例では、EKS クラスターの現在のアベイラビリティーゾーンを取得し、既存のゾーンに新しいサブネットを追加します。update-cluster-config コマンドでは、元のサブネットと新しいサブネットを指定しています。これにより、クラスターのアベイラビリティーゾーン設定を維持し、各ゾーンのサブネットを拡張します。

    aws eks describe-cluster --name gpusharing-demo --query 'cluster.resourcesVpcConfig.subnetIds'
    [
        "subnet-03d59dfc8d9380b4c",
        "subnet-0c4f51f27d109fa32",
        "subnet-037b42db1a08da5ae"
    ]
    
    aws eks update-cluster-config --name gpusharing-demo --resources-vpc-config subnetIds=subnet-xxxxxxx80b4c,subnet-xxxxxxx8da5ae,subnet-xxxxxxx9fa32,subnet-xxxxxxee3bb,subnet-xxxxxxa761ac,subnet-xxxxxxde8b8
    {
    "update": {
    "id": "e7ed1fbf-01ab-3472-8204-149cdc3337be",
    "status": "InProgress",
    "type": "VpcConfigUpdate",
    "params": [
    {
    "type": "Subnets",
    "value": "[subnet-xxxxxxx80b4c, subnet-xxxxxxx8da5ae, subnet-xxxxxxxx9fa32, subnet-xxxxxxxee3bb, subnet-xxxxxxxxa761ac, subnet-xxxxxxde8b8]"
    }
    ],
    "createdAt": "2024-09-09T18:06:16.493000+00:00",
    "errors": []
    }
    }

eksctl CLI を使用する

eksctl CLIコマンドは、既存のクラスターサブネットをコマンドで指定したサブネットに置き換えます。サブネットを追加するには、既存のサブネットと追加のサブネットを指定します。

次の eksctl コマンドを実行すると、クラスターコントロールプレーンのサブネットが更新されます。

eksctl utils update-cluster-vpc-config --cluster=your-cluster-name \
--control-plane-subnet-ids=subnet-1234,subnet-5678 --approve

次の出力例は、アベイラビリティーゾーンごとに、クラスターが 1 つのサブネットに更新されたことを示しています。

eksctl utils update-cluster-vpc-config --cluster=gpusharing-demo  --control-plane-subnet-ids=subnet-03d59dfc8d9380b4c,subnet-0c4f51f27d109fa32,subnet-037b42db1a08da5ae --approve
2024-09-09 18:23:54 [ℹ]  using region us-west-2
2024-09-09 18:23:54 [ℹ]  will update control plane subnet IDs for cluster "gpusharing-demo" in "us-west-2" to: [subnet-xxxxxxx80b4c subnet-xxxxxxx9fa32 subnet-xxxxxx8da5ae]
2024-09-09 18:32:07 [✔]  control plane subnets and security groups for cluster "gpusharing-demo" in "us-west-2" have been updated to: controlPlaneSubnetIDs=[subnet-xxxxxxx80b4c subnet-xxxxxxxx9fa32 subnet-xxxxxxxx8da5ae], controlPlaneSecurityGroupIDs=[sg-xxxxx31d2]

config.yaml ファイルを使用してサブネットを更新するには、次のコマンドを実行します。

eksctl utils update-cluster-vpc-config -f config.yaml

出力例:

apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
  name: cluster
  region: us-west-2

vpc:
  controlPlaneSubnetIDs: [subnet-1234, subnet-5678, subnet-9101]
  controlPlaneSecurityGroupIDs: [sg-1234, sg-5678]

関連情報

VPC の柔軟性向上: Amazon EKS でサブネットとセキュリティグループを変更する

コントロールプレーンサブネットとセキュリティグループを更新する (eksctl のウェブサイト)

AWS公式更新しました 1年前
コメントはありません

関連するコンテンツ