いかすEKS②

EKS

いかすESKエントリーの②です。
過去記事はこちら

クラスタの作成

クラスタは毎回、作業後に落とすので最初はクラスタの作成からです。節約です。前回、オプションを忘れてworker用にm5.largeを起動してしまったので、今回は慎重に。公式に書いてるとおりの内容です。

$ eksctl create cluster --name [cluster-name] --version 1.13 --nodegroup-name [worker-group-name] --node-type t3.medium --nodes 3 --nodes-min 1 --nodes-max 4 --node-ami auto

そこそこ時間がかかるので慌てずに。kubectlで接続できることを確認します。
オンプレ環境でkubeadmを使ってクラスタを作ったのに比べるととても楽ですね。

しかしエラーが出る

なぜかエラーが出ました。うーん、前回はちゃんとクラスタ作れたのに。違うのはオプションの内容だけなので、少しずつ削ってみるなどしてみます。AutoScalingなんとかとエラーが出ていたので、nodes-minとnodes-maxを削るもエラーが増える感じ。ハマってしまった感じがします。焦ります。
とりあえず、クラスタを削除して気持ちを落ち着かせます。

再度チャレンジ

前回と大きく違うのは、node-typeでt3.mediumを指定したところかなと思うので、そこを削ってみます。m5.largeでいいじゃないか(泣)

うまく起動できたので、今後のために、ちゃんと出力内容も読んでおきます。

$ eksctl create cluster --name ikasu --version 1.13 --nodegroup-name ikasu-workers
[ℹ]  using region ap-northeast-1
[ℹ]  setting availability zones to [ap-northeast-1a ap-northeast-1c ap-northeast-1d]
[ℹ]  subnets for ap-northeast-1a - public:192.168.0.0/19 private:192.168.96.0/19
[ℹ]  subnets for ap-northeast-1c - 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 "ikasu-workers" will use "ami-0a67c71d2ab43d36f" [AmazonLinux2/1.13]
[ℹ]  using Kubernetes version 1.13
[ℹ]  creating EKS cluster "ikasu" 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 --name=ikasu'
[ℹ]  CloudWatch logging will not be enabled for cluster "ikasu" in "ap-northeast-1"
[ℹ]  you can enable it with 'eksctl utils update-cluster-logging --region=ap-northeast-1 --name=ikasu'
[ℹ]  2 sequential tasks: { create cluster control plane "ikasu", create nodegroup "ikasu-workers" }
[ℹ]  building cluster stack "eksctl-ikasu-cluster"
[ℹ]  deploying stack "eksctl-ikasu-cluster"
[ℹ]  building nodegroup stack "eksctl-ikasu-nodegroup-ikasu-workers"
[ℹ]  --nodes-min=2 was set automatically for nodegroup ikasu-workers
[ℹ]  --nodes-max=2 was set automatically for nodegroup ikasu-workers
[ℹ]  deploying stack "eksctl-ikasu-nodegroup-ikasu-workers"
[✔]  all EKS cluster resource for "ikasu" had been created
[✔]  saved kubeconfig as "/home/hideo/.kube/config-first-eks-cluster"
[ℹ]  adding role "arn:aws:iam::313028364465:role/eksctl-ikasu-nodegroup-ikasu-work-NodeInstanceRole-B5H6FNMHI28Y" to auth ConfigMap
[ℹ]  nodegroup "ikasu-workers" has 0 node(s)
[ℹ]  waiting for at least 2 node(s) to become ready in "ikasu-workers"
[ℹ]  nodegroup "ikasu-workers" has 2 node(s)
[ℹ]  node "ip-192-168-54-59.ap-northeast-1.compute.internal" is ready
[ℹ]  node "ip-192-168-7-9.ap-northeast-1.compute.internal" is ready
[ℹ]  kubectl command should work with "/home/hideo/.kube/config-first-eks-cluster", try 'kubectl --kubeconfig=/home/hideo/.kube/config-first-eks-cluster get nodes'
[✔]  EKS cluster "ikasu" in "ap-northeast-1" region is ready

ゲストブックの起動

Kubernetesのゲストブックアプリケーションを起動します。EKSクラスタのテストですね。どうやら、このリポジトリのようです。
https://github.com/kubernetes/examples/tree/master/guestbook-go

公式に書いてあるとおりに実行していきます。yamlじゃないんですね。
最後にExternalIPを確認します。

$ kubectl get svc -o wide
NAME           TYPE           CLUSTER-IP       EXTERNAL-IP                                                                    PORT(S)          AGE     SELECTOR
guestbook      LoadBalancer   10.100.156.158   a879b183ee57c11e9970906dc18345ed-1049393403.ap-northeast-1.elb.amazonaws.com   3000:32031/TCP   18s     app=guestbook
kubernetes     ClusterIP      10.100.0.1       <none>                                                                         443/TCP          15m     <none>
redis-master   ClusterIP      10.100.144.119   <none>                                                                         6379/TCP         2m34s   app=redis,role=master
redis-slave    ClusterIP      10.100.180.106   <none>                                                                         6379/TCP         85s     app=redis,role=slave

ブラウザで当該URLにアクセスしてみるも「サーバが見つかりません」となりました。公式に書いてあるようにDNSの反映に少し時間がかかるようです。少し待つとアクセスできました!

ゲストブックアプリケーションの起動

最後に

お小遣いを無駄にしないために、クリーンアップを忘れないようにします。

投稿者: green pepper

子ども2人の育児に奮闘する情シスです。 勉強したことや、その日の出来事などを記録していきたいです。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です