過去にQiitaに投稿した内容のアーカイブです。
テスト環境
| 項目 | 内容 | 
|---|---|
| ホスト環境 | Windows 11 | 
| 仮想化環境 | Multipass | 
仮想環境の作成
| 項目 | 値 | 
|---|---|
| CPU | 2コア | 
| メモリ | 8GB | 
| ストレージ | 20GB | 
multipass launch -n eks-anywhere2 -c 2 -m 8G -d 20G
multipass shell eks-anywhere
環境構築
Dockerのインストール
curl -fsSL https://get.docker.com -o get-docker.sh && \
sh ./get-docker.sh && \
sudo usermod -aG docker $USER
一度ログアウトして再ログイン
exit
multipass shell eks-anywhere
kubectlのインストール
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ツールのインストール
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/
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/
インストール確認
eksctl anywhere version
EKSクラスターの作成
configファイルの生成
CLUSTER_NAME=dev-cluster
eksctl anywhere generate clusterconfig $CLUSTER_NAME \
   --provider docker > $CLUSTER_NAME.yaml
クラスターの作成
eksctl anywhere create cluster -f $CLUSTER_NAME.yaml
できた。超簡単。
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:~$
テストアプリケーションのデプロイ
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:~$
ポートフォワーディング
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:~$
かっちょいい。