先日マネージドノードグループで EKS を作成しましたが、今回はノードに Fargate を利用して作成してみます。
EKS クラスターの作成
$ eksctl create cluster --name fargate --fargate
2023-02-17 20:49:48 [ℹ] eksctl version 0.129.0
2023-02-17 20:49:48 [ℹ] using region ap-northeast-1
2023-02-17 20:49:48 [ℹ] setting availability zones to [ap-northeast-1a ap-northeast-1c ap-northeast-1d]
2023-02-17 20:49:48 [ℹ] subnets for ap-northeast-1a - public:192.168.0.0/19 private:192.168.96.0/19
2023-02-17 20:49:48 [ℹ] subnets for ap-northeast-1c - public:192.168.32.0/19 private:192.168.128.0/19
2023-02-17 20:49:48 [ℹ] subnets for ap-northeast-1d - public:192.168.64.0/19 private:192.168.160.0/19
2023-02-17 20:49:48 [ℹ] using Kubernetes version 1.24
2023-02-17 20:49:48 [ℹ] creating EKS cluster "fargate" in "ap-northeast-1" region with Fargate profile
2023-02-17 20:49:48 [ℹ] if you encounter any issues, check CloudFormation console or try 'eksctl utils describe-stacks --region=ap-northeast-1 --cluster=fargate'
2023-02-17 20:49:48 [ℹ] Kubernetes API endpoint access will use default of {publicAccess=true, privateAccess=false} for cluster "fargate" in "ap-northeast-1"
2023-02-17 20:49:48 [ℹ] CloudWatch logging will not be enabled for cluster "fargate" in "ap-northeast-1"
2023-02-17 20:49:48 [ℹ] 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'
2023-02-17 20:49:48 [ℹ]
2 sequential tasks: { create cluster control plane "fargate",
2 sequential sub-tasks: {
wait for control plane to become ready,
create fargate profiles,
}
}
2023-02-17 20:49:48 [ℹ] building cluster stack "eksctl-fargate-cluster"
2023-02-17 20:49:49 [ℹ] deploying stack "eksctl-fargate-cluster"
2023-02-17 20:50:19 [ℹ] waiting for CloudFormation stack "eksctl-fargate-cluster"
2023-02-17 20:50:49 [ℹ] waiting for CloudFormation stack "eksctl-fargate-cluster"
2023-02-17 20:51:49 [ℹ] waiting for CloudFormation stack "eksctl-fargate-cluster"
2023-02-17 20:52:49 [ℹ] waiting for CloudFormation stack "eksctl-fargate-cluster"
2023-02-17 20:53:50 [ℹ] waiting for CloudFormation stack "eksctl-fargate-cluster"
2023-02-17 20:54:50 [ℹ] waiting for CloudFormation stack "eksctl-fargate-cluster"
2023-02-17 20:55:50 [ℹ] waiting for CloudFormation stack "eksctl-fargate-cluster"
2023-02-17 20:56:50 [ℹ] waiting for CloudFormation stack "eksctl-fargate-cluster"
2023-02-17 20:57:50 [ℹ] waiting for CloudFormation stack "eksctl-fargate-cluster"
2023-02-17 20:58:51 [ℹ] waiting for CloudFormation stack "eksctl-fargate-cluster"
2023-02-17 20:59:51 [ℹ] waiting for CloudFormation stack "eksctl-fargate-cluster"
2023-02-17 21:00:51 [ℹ] waiting for CloudFormation stack "eksctl-fargate-cluster"
2023-02-17 21:02:53 [ℹ] creating Fargate profile "fp-default" on EKS cluster "fargate"
2023-02-17 21:05:04 [ℹ] created Fargate profile "fp-default" on EKS cluster "fargate"
2023-02-17 21:05:34 [ℹ] "coredns" is now schedulable onto Fargate
2023-02-17 21:06:38 [ℹ] "coredns" is now scheduled onto Fargate
2023-02-17 21:06:38 [ℹ] "coredns" pods are now scheduled onto Fargate
2023-02-17 21:06:38 [ℹ] waiting for the control plane to become ready
2023-02-17 21:06:38 [✔] saved kubeconfig as "/Users/xxx/.kube/config"
2023-02-17 21:06:38 [ℹ] no tasks
2023-02-17 21:06:38 [✔] all EKS cluster resources for "fargate" have been created
2023-02-17 21:06:39 [ℹ] kubectl command should work with "/Users/xxx/.kube/config", try 'kubectl get nodes'
2023-02-17 21:06:39 [✔] EKS cluster "fargate" in "ap-northeast-1" region is ready
マネージドノードグループと違い、CloudFormation は 1 つだけ作成されていました。
Fargate プロファイルも作成されていましたが、CloudFormation ではなく API で直接作成されていました。
なお、Fargate プロファイルは、Pod を Fargate ノードでスケジュールするために必要な仕組みです。
Fargate で利用する IAM ロールや、実行するサブネットなどを指定できます。
Kubernetes リソースの表示
$ kubectl get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
fargate-ip-192-168-167-219.ap-northeast-1.compute.internal Ready <none> 13m v1.24.9-eks-300e41d 192.168.167.219 <none> Amazon Linux 2 4.14.294-220.533.amzn2.x86_64 containerd://1.6.6
fargate-ip-192-168-178-134.ap-northeast-1.compute.internal Ready <none> 13m v1.24.9-eks-300e41d 192.168.178.134 <none> Amazon Linux 2 4.14.294-220.533.amzn2.x86_64 containerd://1.6.6
$ kubectl get pods -A -o wide
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
kube-system coredns-96cd84d87-g68cl 1/1 Running 0 16m 192.168.178.134 fargate-ip-192-168-178-134.ap-northeast-1.compute.internal <none> <none>
kube-system coredns-96cd84d87-rvt94 1/1 Running 0 16m 192.168.167.219 fargate-ip-192-168-167-219.ap-northeast-1.compute.internal <none> <none>
クラスターと Fargate プロファイルを削除する
$ eksctl delete cluster fargate
2023-02-17 21:33:29 [ℹ] deleting EKS cluster "fargate"
2023-02-17 21:33:29 [ℹ] deleting Fargate profile "fp-default"
2023-02-17 21:37:46 [ℹ] deleted Fargate profile "fp-default"
2023-02-17 21:37:46 [ℹ] deleted 1 Fargate profile(s)
2023-02-17 21:37:47 [✔] kubeconfig has been updated
2023-02-17 21:37:47 [ℹ] cleaning up AWS load balancers created by Kubernetes objects of Kind Service or Ingress
2023-02-17 21:37:49 [ℹ] 1 task: { delete cluster control plane "fargate" [async] }
2023-02-17 21:37:49 [ℹ] will delete stack "eksctl-fargate-cluster"
2023-02-17 21:37:49 [✔] all cluster resources were deleted