LoginSignup
0
1

More than 1 year has passed since last update.

EKS AnywhereでKubernetes環境を構築してみた

Posted at

テスト環境

項目 内容
ホスト環境 Windows 11
仮想化環境 Multipass

仮想環境の作成

項目
CPU 2コア
メモリ 8GB
ストレージ 20GB
コマンドプロンプト
multipass launch -n eks-anywhere2 -c 2 -m 8G -d 20G
multipass shell eks-anywhere

環境構築

Dockerのインストール

ubuntu
curl -fsSL https://get.docker.com -o get-docker.sh && \
sh ./get-docker.sh && \
sudo usermod -aG docker $USER

一度ログアウトして再ログイン

ubuntu
exit
コマンドプロンプト
multipass shell eks-anywhere

kubectlのインストール

ubuntu
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" && \
chmod +x ./kubectl && \
sudo mv ./kubectl /usr/local/bin/kubectl

EKS Anywhere CLIツールのインストール

ubuntu
curl "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" \
    --silent --location \
    | tar xz -C /tmp && \
sudo mv /tmp/eksctl /usr/local/bin/
ubuntu
export EKSA_RELEASE="0.6.0" OS="$(uname -s | tr A-Z a-z)" RELEASE_NUMBER=2 && \
curl "https://anywhere-assets.eks.amazonaws.com/releases/eks-a/${RELEASE_NUMBER}/artifacts/eks-a/v${EKSA_RELEASE}/${OS}/eksctl-anywhere-v${EKSA_RELEASE}-${OS}-amd64.tar.gz" \
    --silent --location \
    | tar xz ./eksctl-anywhere && \
sudo mv ./eksctl-anywhere /usr/local/bin/

インストール確認

ubuntu
eksctl anywhere version

EKSクラスターの作成

configファイルの生成

ubuntu
CLUSTER_NAME=dev-cluster
eksctl anywhere generate clusterconfig $CLUSTER_NAME \
   --provider docker > $CLUSTER_NAME.yaml

クラスターの作成

ubuntu
eksctl anywhere create cluster -f $CLUSTER_NAME.yaml

できた。超簡単。

ubuntu
export KUBECONFIG=${PWD}/${CLUSTER_NAME}/${CLUSTER_NAME}-eks-a-cluster.kubeconfig
kubectl get ns
ubuntu@eks-anywhere:~$ kubectl get ns
NAME                                STATUS   AGE
capd-system                         Active   110s
capi-kubeadm-bootstrap-system       Active   2m8s
capi-kubeadm-control-plane-system   Active   114s
capi-system                         Active   2m16s
capi-webhook-system                 Active   2m19s
cert-manager                        Active   3m40s
default                             Active   4m33s
eksa-system                         Active   61s
etcdadm-bootstrap-provider-system   Active   2m4s
etcdadm-controller-system           Active   2m1s
kube-node-lease                     Active   4m35s
kube-public                         Active   4m35s
kube-system                         Active   4m35s
ubuntu@eks-anywhere:~$

テストアプリケーションのデプロイ

ubuntu
kubectl apply -f "https://anywhere.eks.amazonaws.com/manifests/hello-eks-a.yaml"
ubuntu@eks-anywhere:~$ kubectl get pods -l app=hello-eks-a
NAME                          READY   STATUS    RESTARTS   AGE
hello-eks-a-9644dd8dc-f2czp   1/1     Running   0          27s
ubuntu@eks-anywhere:~$

ポートフォワーディング

ubuntu
kubectl port-forward deploy/hello-eks-a 8000:80

この状態でもう一つターミナルを立ち上げて(コマンドプロンプトをもう一つ立ち上げてmultipass shell eks-anywhere)、アクセス

ubuntu@eks-anywhere:~$ curl localhost:8000
Handling connection for 8000
⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢

Thank you for using

███████╗██╗  ██╗███████╗
██╔════╝██║ ██╔╝██╔════╝
█████╗  █████╔╝ ███████╗
██╔══╝  ██╔═██╗ ╚════██║
███████╗██║  ██╗███████║
╚══════╝╚═╝  ╚═╝╚══════╝

 █████╗ ███╗   ██╗██╗   ██╗██╗    ██╗██╗  ██╗███████╗██████╗ ███████╗
██╔══██╗████╗  ██║╚██╗ ██╔╝██║    ██║██║  ██║██╔════╝██╔══██╗██╔════╝
███████║██╔██╗ ██║ ╚████╔╝ ██║ █╗ ██║███████║█████╗  ██████╔╝█████╗
██╔══██║██║╚██╗██║  ╚██╔╝  ██║███╗██║██╔══██║██╔══╝  ██╔══██╗██╔══╝
██║  ██║██║ ╚████║   ██║   ╚███╔███╔╝██║  ██║███████╗██║  ██║███████╗
╚═╝  ╚═╝╚═╝  ╚═══╝   ╚═╝    ╚══╝╚══╝ ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚══════╝

You have successfully deployed the hello-eks-a pod hello-eks-a-9644dd8dc-f2czp

For more information check out
https://anywhere.eks.amazonaws.com

⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢
ubuntu@eks-anywhere:~$

かっちょいい。

0
1
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
1