翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
EKS Fargate のサポート
AWS Fargate
Amazon EKS は AWS Fargate でポッドを起動できるようになりました。これにより、ポッドのインフラストラクチャをプロビジョニングまたは管理する方法について心配する必要がなくなり、AWS での高性能で可用性の高い Kubernetes アプリケーションの構築と実行が容易になります。
Fargate サポートを使用したクラスターの作成
Fargate をサポートするクラスターは、以下を使用して追加できます。
eksctl create cluster --fargate [ℹ] eksctl version 0.11.0 [ℹ] using region ap-northeast-1 [ℹ] setting availability zones to [ap-northeast-1a ap-northeast-1d ap-northeast-1c] [ℹ] subnets for ap-northeast-1a - public:192.168.0.0/19 private:192.168.96.0/19 [ℹ] subnets for ap-northeast-1d - public:192.168.32.0/19 private:192.168.128.0/19 [ℹ] subnets for ap-northeast-1c - public:192.168.64.0/19 private:192.168.160.0/19 [ℹ] nodegroup "ng-dba9d731" will use "ami-02e124a380df41614" [AmazonLinux2/1.14] [ℹ] using Kubernetes version 1.14 [ℹ] creating EKS cluster "ridiculous-painting-1574859263" in "ap-northeast-1" region [ℹ] will create 2 separate CloudFormation stacks for cluster itself and the initial nodegroup [ℹ] if you encounter any issues, check CloudFormation console or try 'eksctl utils describe-stacks --region=ap-northeast-1 --cluster=ridiculous-painting-1574859263' [ℹ] CloudWatch logging will not be enabled for cluster "ridiculous-painting-1574859263" in "ap-northeast-1" [ℹ] you can enable it with 'eksctl utils update-cluster-logging --enable-types={SPECIFY-YOUR-LOG-TYPES-HERE (e.g. all)} --region=ap-northeast-1 --cluster=ridiculous-painting-1574859263' [ℹ] Kubernetes API endpoint access will use default of {publicAccess=true, privateAccess=false} for cluster "ridiculous-painting-1574859263" in "ap-northeast-1" [ℹ] 2 sequential tasks: { create cluster control plane "ridiculous-painting-1574859263", create nodegroup "ng-dba9d731" } [ℹ] building cluster stack "eksctl-ridiculous-painting-1574859263-cluster" [ℹ] deploying stack "eksctl-ridiculous-painting-1574859263-cluster" [ℹ] building nodegroup stack "eksctl-ridiculous-painting-1574859263-nodegroup-ng-dba9d731" [ℹ] --nodes-min=2 was set automatically for nodegroup ng-dba9d731 [ℹ] --nodes-max=2 was set automatically for nodegroup ng-dba9d731 [ℹ] deploying stack "eksctl-ridiculous-painting-1574859263-nodegroup-ng-dba9d731" [✔] all EKS cluster resources for "ridiculous-painting-1574859263" have been created [✔] saved kubeconfig as "/Users/marc/.kube/config" [ℹ] adding identity "arn:aws:iam::123456789012:role/eksctl-ridiculous-painting-157485-NodeInstanceRole-104DXUJOFDPO5" to auth ConfigMap [ℹ] nodegroup "ng-dba9d731" has 0 node(s) [ℹ] waiting for at least 2 node(s) to become ready in "ng-dba9d731" [ℹ] nodegroup "ng-dba9d731" has 2 node(s) [ℹ] node "ip-192-168-27-156.ap-northeast-1.compute.internal" is ready [ℹ] node "ip-192-168-95-177.ap-northeast-1.compute.internal" is ready [ℹ] creating Fargate profile "default" on EKS cluster "ridiculous-painting-1574859263" [ℹ] created Fargate profile "default" on EKS cluster "ridiculous-painting-1574859263" [ℹ] kubectl command should work with "/Users/marc/.kube/config", try 'kubectl get nodes' [✔] EKS cluster "ridiculous-painting-1574859263" in "ap-northeast-1" region is ready
このコマンドは、クラスターと Fargate プロファイルを作成します。このプロファイルには、Fargate でポッドをインスタンス化するために AWS が必要とする特定の情報が含まれています。次のようなものがあります。
-
ポッドを実行するために必要なアクセス許可と、ポッドを実行するためのネットワークの場所 (サブネット) を定義するポッド実行ロール。これにより、同じネットワークとセキュリティのアクセス許可を複数の Fargate ポッドに適用でき、クラスター上の既存のポッドを Fargate に移行することが容易になります。
-
Fargate で実行するポッドを定義するセレクタ。これは、
namespace
と で構成されますlabels
。
プロファイルが指定されていないが Fargate のサポートが有効になってい--fargate
る場合、デフォルトの Fargate プロファイルが作成されます。このプロファイルは、 default
および kube-system
名前空間をターゲットにして、それらの名前空間のポッドが Fargate で実行されるようにします。
作成された Fargate プロファイルは、次のコマンドで確認できます。
eksctl get fargateprofile --cluster ridiculous-painting-1574859263 -o yaml - name: fp-default podExecutionRoleARN: arn:aws:iam::123456789012:role/eksctl-ridiculous-painting-1574859263-ServiceRole-EIFQOH0S1GE7 selectors: - namespace: default - namespace: kube-system subnets: - subnet-0b3a5522f3b48a742 - subnet-0c35f1497067363f3 - subnet-0a29aa00b25082021
セレクタの詳細については、「Fargate プロファイルの設計」を参照してください。
設定ファイルを使用した Fargate サポートによるクラスターの作成
次の設定ファイルは、1 つの EC2 m5.large
インスタンスと 2 つの Fargate プロファイルで構成されるノードグループの両方を持つ EKS クラスターを宣言します。default
および kube-system
名前空間で定義されたすべてのポッドは Fargate で実行されます。ラベルも付いているdev
名前空間内のすべてのポッドdev=passed
も Fargate で実行されます。その他のポッドは、 のノードでスケジュールされますng-1
。
# An example of ClusterConfig with a normal nodegroup and a Fargate profile. --- apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: fargate-cluster region: ap-northeast-1 nodeGroups: - name: ng-1 instanceType: m5.large desiredCapacity: 1 fargateProfiles: - name: fp-default selectors: # All workloads in the "default" Kubernetes namespace will be # scheduled onto Fargate: - namespace: default # All workloads in the "kube-system" Kubernetes namespace will be # scheduled onto Fargate: - namespace: kube-system - name: fp-dev selectors: # All workloads in the "dev" Kubernetes namespace matching the following # label selectors will be scheduled onto Fargate: - namespace: dev labels: env: dev checks: passed
eksctl create cluster -f cluster-fargate.yaml [ℹ] eksctl version 0.11.0 [ℹ] using region ap-northeast-1 [ℹ] setting availability zones to [ap-northeast-1c ap-northeast-1a ap-northeast-1d] [ℹ] subnets for ap-northeast-1c - public:192.168.0.0/19 private:192.168.96.0/19 [ℹ] subnets for ap-northeast-1a - public:192.168.32.0/19 private:192.168.128.0/19 [ℹ] subnets for ap-northeast-1d - public:192.168.64.0/19 private:192.168.160.0/19 [ℹ] nodegroup "ng-1" will use "ami-02e124a380df41614" [AmazonLinux2/1.14] [ℹ] using Kubernetes version 1.14 [ℹ] creating EKS cluster "fargate-cluster" in "ap-northeast-1" region with Fargate profile and un-managed nodes [ℹ] 1 nodegroup (ng-1) was included (based on the include/exclude rules) [ℹ] will create a CloudFormation stack for cluster itself and 1 nodegroup stack(s) [ℹ] will create a CloudFormation stack for cluster itself and 0 managed nodegroup stack(s) [ℹ] if you encounter any issues, check CloudFormation console or try 'eksctl utils describe-stacks --region=ap-northeast-1 --cluster=fargate-cluster' [ℹ] CloudWatch logging will not be enabled for cluster "fargate-cluster" in "ap-northeast-1" [ℹ] you can enable it with 'eksctl utils update-cluster-logging --enable-types={SPECIFY-YOUR-LOG-TYPES-HERE (e.g. all)} --region=ap-northeast-1 --cluster=fargate-cluster' [ℹ] Kubernetes API endpoint access will use default of {publicAccess=true, privateAccess=false} for cluster "fargate-cluster" in "ap-northeast-1" [ℹ] 2 sequential tasks: { create cluster control plane "fargate-cluster", create nodegroup "ng-1" } [ℹ] building cluster stack "eksctl-fargate-cluster-cluster" [ℹ] deploying stack "eksctl-fargate-cluster-cluster" [ℹ] building nodegroup stack "eksctl-fargate-cluster-nodegroup-ng-1" [ℹ] --nodes-min=1 was set automatically for nodegroup ng-1 [ℹ] --nodes-max=1 was set automatically for nodegroup ng-1 [ℹ] deploying stack "eksctl-fargate-cluster-nodegroup-ng-1" [✔] all EKS cluster resources for "fargate-cluster" have been created [✔] saved kubeconfig as "/home/user1/.kube/config" [ℹ] adding identity "arn:aws:iam::123456789012:role/eksctl-fargate-cluster-nod-NodeInstanceRole-42Q80B2Z147I" to auth ConfigMap [ℹ] nodegroup "ng-1" has 0 node(s) [ℹ] waiting for at least 1 node(s) to become ready in "ng-1" [ℹ] nodegroup "ng-1" has 1 node(s) [ℹ] node "ip-192-168-71-83.ap-northeast-1.compute.internal" is ready [ℹ] creating Fargate profile "fp-default" on EKS cluster "fargate-cluster" [ℹ] created Fargate profile "fp-default" on EKS cluster "fargate-cluster" [ℹ] creating Fargate profile "fp-dev" on EKS cluster "fargate-cluster" [ℹ] created Fargate profile "fp-dev" on EKS cluster "fargate-cluster" [ℹ] "coredns" is now schedulable onto Fargate [ℹ] "coredns" is now scheduled onto Fargate [ℹ] "coredns" is now scheduled onto Fargate [ℹ] "coredns" pods are now scheduled onto Fargate [ℹ] kubectl command should work with "/home/user1/.kube/config", try 'kubectl get nodes' [✔] EKS cluster "fargate-cluster" in "ap-northeast-1" region is ready
Fargate プロファイルの設計
各セレクタエントリには、名前空間とキーと値のペアのリストという最大 2 つのコンポーネントがあります。セレクタエントリを作成するには、名前空間コンポーネントのみが必要です。セレクタエントリと一致するには、すべてのルール (名前空間、キーと値のペア) がポッドに適用されている必要があります。ポッドは、プロファイルで実行するセレクタエントリを 1 つだけ一致させる必要があります。セレクタフィールドのすべての条件に一致するポッドは、Fargate で実行されるようにスケジュールされます。ホワイトリストに登録されている名前空間のいずれとも一致しないポッドでも、ユーザーが手動でスケジューラを設定すると、Fargate での実行が許可されていないため、fargate-scheduler filed は保留状態のままになります。
プロファイルは次の要件を満たしている必要があります。
-
プロファイルごとに 1 つのセレクタが必須
-
各セレクタには名前空間を含める必要があります。ラベルはオプションです
例: Fargate でのワークロードのスケジューリング
上記の例の Fargate でポッドをスケジュールするには、例えば、 という名前空間を作成し、そこにワークロードをdev
デプロイします。
kubectl create namespace dev namespace/dev created kubectl run nginx --image=nginx --restart=Never --namespace dev pod/nginx created kubectl get pods --all-namespaces --output wide NAMESPACE NAME READY STATUS AGE IP NODE dev nginx 1/1 Running 75s 192.168.183.140 fargate-ip-192-168-183-140.ap-northeast-1.compute.internal kube-system aws-node-44qst 1/1 Running 21m 192.168.70.246 ip-192-168-70-246.ap-northeast-1.compute.internal kube-system aws-node-4vr66 1/1 Running 21m 192.168.23.122 ip-192-168-23-122.ap-northeast-1.compute.internal kube-system coredns-699bb99bf8-84x74 1/1 Running 26m 192.168.2.95 ip-192-168-23-122.ap-northeast-1.compute.internal kube-system coredns-699bb99bf8-f6x6n 1/1 Running 26m 192.168.90.73 ip-192-168-70-246.ap-northeast-1.compute.internal kube-system kube-proxy-brxhg 1/1 Running 21m 192.168.23.122 ip-192-168-23-122.ap-northeast-1.compute.internal kube-system kube-proxy-zd7s8 1/1 Running 21m 192.168.70.246 ip-192-168-70-246.ap-northeast-1.compute.internal
最後のkubectl get pods
コマンドの出力から、ポッドが nginx
というノードにデプロイされていることを確認できますfargate-ip-192-168-183-140.ap-northeast-1.compute.internal
。
Fargate プロファイルの管理
Fargate に Kubernetes ワークロードをデプロイするには、EKS に Fargate プロファイルが必要です。上記の例のようなクラスターを作成する場合、 eksctl
はデフォルトのプロファイルを作成してこれを処理します。既存のクラスターがある場合、 eksctl create fargateprofile
コマンドを使用して Fargate プロファイルを作成することもできます。
注記
このオペレーションは、EKS プラットフォームバージョン eks.5
以降で実行されるクラスターでのみサポートされます。
注記
既存の が 0.11.0 eksctl
より前のバージョンで作成されている場合は、Fargate プロファイルを作成するeksctl upgrade cluster
前に を実行する必要があります。
eksctl create fargateprofile --namespace dev --cluster fargate-example-cluster [ℹ] creating Fargate profile "fp-9bfc77ad" on EKS cluster "fargate-example-cluster" [ℹ] created Fargate profile "fp-9bfc77ad" on EKS cluster "fargate-example-cluster"
作成する Fargate プロファイルの名前を指定することもできます。この名前はプレフィックス で始まることはできませんeks-
。
eksctl create fargateprofile --namespace dev --cluster fargate-example-cluster --name fp-development [ℹ] created Fargate profile "fp-development" on EKS cluster "fargate-example-cluster"
このコマンドを CLI フラグ eksctl で使用すると、シンプルなセレクタを持つ単一の Fargate プロファイルのみを作成できます。名前空間が多いなど、より複雑なセレクタの場合、eksctl は設定ファイルの使用をサポートします。
apiVersion: eksctl.io/v1alpha5 kind: ClusterConfig metadata: name: fargate-example-cluster region: ap-northeast-1 fargateProfiles: - name: fp-default selectors: # All workloads in the "default" Kubernetes namespace will be # scheduled onto Fargate: - namespace: default # All workloads in the "kube-system" Kubernetes namespace will be # scheduled onto Fargate: - namespace: kube-system - name: fp-dev selectors: # All workloads in the "dev" Kubernetes namespace matching the following # label selectors will be scheduled onto Fargate: - namespace: dev labels: env: dev checks: passed
eksctl create fargateprofile -f fargate-example-cluster.yaml [ℹ] creating Fargate profile "fp-default" on EKS cluster "fargate-example-cluster" [ℹ] created Fargate profile "fp-default" on EKS cluster "fargate-example-cluster" [ℹ] creating Fargate profile "fp-dev" on EKS cluster "fargate-example-cluster" [ℹ] created Fargate profile "fp-dev" on EKS cluster "fargate-example-cluster" [ℹ] "coredns" is now scheduled onto Fargate [ℹ] "coredns" pods are now scheduled onto Fargate
クラスター内の既存の Fargate プロファイルを表示するには:
eksctl get fargateprofile --cluster fargate-example-cluster NAME SELECTOR_NAMESPACE SELECTOR_LABELS POD_EXECUTION_ROLE_ARN SUBNETS fp-9bfc77ad dev <none> arn:aws:iam::123456789012:role/eksctl-fargate-example-cluster-ServiceRole-1T5F78E5FSH79 subnet-00adf1d8c99f83381,subnet-04affb163ffab17d4,subnet-035b34379d5ef5473
また、 yaml
形式で表示するには:
eksctl get fargateprofile --cluster fargate-example-cluster -o yaml - name: fp-9bfc77ad podExecutionRoleARN: arn:aws:iam::123456789012:role/eksctl-fargate-example-cluster-ServiceRole-1T5F78E5FSH79 selectors: - namespace: dev subnets: - subnet-00adf1d8c99f83381 - subnet-04affb163ffab17d4 - subnet-035b34379d5ef5473
または json
形式:
eksctl get fargateprofile --cluster fargate-example-cluster -o json [ { "name": "fp-9bfc77ad", "podExecutionRoleARN": "arn:aws:iam::123456789012:role/eksctl-fargate-example-cluster-ServiceRole-1T5F78E5FSH79", "selectors": [ { "namespace": "dev" } ], "subnets": [ "subnet-00adf1d8c99f83381", "subnet-04affb163ffab17d4", "subnet-035b34379d5ef5473" ] } ]
Fargate プロファイルは、設計上イミュータブルです。何かを変更するには、必要な変更を含む新しい Fargate プロファイルを作成し、次の例のように eksctl delete fargateprofile
コマンドを使用して古いプロファイルを削除します。
eksctl delete fargateprofile --cluster fargate-example-cluster --name fp-9bfc77ad --wait 2019-11-27T19:04:26+09:00 [ℹ] deleting Fargate profile "fp-9bfc77ad" ClusterName: "fargate-example-cluster", FargateProfileName: "fp-9bfc77ad" }
プロファイルの削除は、数分かかる場合があるプロセスであることに注意してください。--wait
フラグが指定されていない場合、 はプロファイルの削除をeksctl
楽観的に想定し、AWS API リクエストが送信されるとすぐに を返します。プロファイルが正常に削除されるまでeksctl
待機するには、上記の例--wait
のように を使用します。