LoginSignup
0
0

More than 1 year has passed since last update.

eksctlコマンドでEKSのクラスターを作成する

Posted at

eksctlコマンドを使ってEKSのクラスターを作成した際のメモ。
クラスター作成時に自動生成されたAWSリソースについてもまとめる。

準備

前提

  • awscliがインストール&設定済みであること
  • AWSのリージョンはap-northeast-1
  • kubectlがインストール済みであること
  • 実行環境
    • macOS Big Sur バージョン11.5.1

eksctlのインストール

インストール

brew install eksctl

バージョンが0.67.0以上であることを確認

eksctl version

クラスターの作成

公式ドキュメントに習い、以下のコマンドを実行

eksctl create cluster --name <name> --version 1.21 --with-oidc --without-nodegroup

↑のコマンドひとつでクラスターが立ち上がる。
--without-nodegroupオプションをつけているのでノードは作成されない)

作成されたクラスターの設定情報

  • ノードグループ
    • なし(作成しないオプションを設定したため)
  • VPC
    • 自動生成されたVPC
  • サービスIPv4範囲
    • 10.100.0.0/16
  • サブネット
    • 自動生成されたサブネット
      • パブリックサブネット * 3
      • プライベートサブネット * 3
  • セキュリティグループ
    • クラスターセキュリティグループ
      • eks-cluster-sg-<クラスター名>-xxxxxxxx
      • クラスターセキュリティグループは、Kubernetes コントロールプレーンとクラスター上のコンピューティングリソース間の通信を制御するために使用される統合セキュリティグループです。(公式より)
    • 追加のセキュリティグループ
      • eksctl-<クラスター名>-cluster-ControlPlaneSecurityGroup-xxxxxxxx
      • 追加のクラスターセキュリティグループは、Kubernetes コントロールプレーンからの通信を制御して、アカウントのリソースを計算します。(公式より)
  • APIサーバーエンドポイント
    • パブリック
  • パブリックアクセスソースの許可リスト
    • 0.0.0.0/0
  • アドオン
    • なし
  • ログ記録
    • なし

その他

eksctlを実行したローカル環境のkubeconfigも自動で設定される。
kubeconfigが設定されなかった(できなかった)場合は以下のコマンドで設定する。

aws eks --region [region] update-kubeconfig --name [cluster_name] --profile [profile]

クラスター作成時に自動生成されたもの

※上記コマンドオプションでクラスターを作成した場合

VPC

  • CIDR: 192.168.0.0/16
  • DNSホスト名:有効

サブネット

  • パブリックサブネット * 3
    • 3AZ
    • パブリックIPv4自動割当:はい
  • プライベートサブネット * 3
    • 3AZ
    • パブリックIPv4自動割当:いいえ

インターネットゲートウェイ

  • パブリックサブネットのルートテーブルに紐付け

NATゲートウェイ

  • プライベートサブネットのルートテーブルに紐付け

Elastic IP

  • NATゲートウェイに紐付け

セキュリティグループ

  • default
    • インバウンド
      • 自セキュリティグループ
    • アウトバウンド
      • 0.0.0.0/0
  • eks-cluster-sg-<クラスター名>-xxxxxxxx
    • EKS created security group applied to ENI that is attached to EKS Control Plane master nodes, as well as any managed workloads.
    • インバウンド
      • 自セキュリティグループ
      • eksctl-<クラスター名>-cluster-ClusterSharedNodeSecurityGroup-xxxxxxxx
    • アウトバウンド
      • 0.0.0.0/0
  • eksctl-<クラスター名>-cluster-ClusterSharedNodeSecurityGroup-xxxxxxxx
    • Communication between all nodes in the cluster
    • インバウンド
      • 自セキュリティグループ
      • eks-cluster-sg-<クラスター名>-xxxxxxxx
    • アウトバウンド
      • 0.0.0.0/0
  • eksctl-<クラスター名>-cluster-ControlPlaneSecurityGroup-xxxxxxxx
    • Communication between the control plane and worker nodegroups
    • インバウンド
      • なし
    • アウトバウンド
      • 0.0.0.0/0

IAM Role

  • AWSServiceRoleForAmazonEKS (未作成の場合)
    • AmazonEKSServiceRolePolicy
  • eksctl-<クラスター名>-cluster-ServiceRole-xxxxxxxx
    • AmazonEKSClusterPolicy
    • AmazonEKSVPCResourceController
    • eksctl-eks-test-cluster-PolicyCloudWatchMetrics(インラインポリシー)
    • eksctl-eks-test-cluster-PolicyELBPermissions(インラインポリシー)
  • eksctl-<クラスター名>-addon-iamserviceaccount-kube-Role1-xxxxxxxx
    • AmazonEKS_CNI_Policy
    • 信頼されたエンティティにoidcの設定あり

クラスターの削除

以下のコマンドを実行

eksctl delete cluster --name <name>

クラスター作成時に自動生成された関連リソースもすべて削除される。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0