
ELK๋ก ํด๋ฌ์คํฐ ๊ตฌ์ฑํ๊ธฐ
๐ก EKS ๊ตฌ์ฑ์ ์ํด ํ์ํ ๋ด์ฉ
- ํด๋ฌ์คํฐ ์ด๋ฆ
- ๋ฒ์
- eksClusterRole
- VPC/subnet
- ๋ณด์๊ทธ๋ฃน
๐ก CloudFormation
๊ตฌ์ฑ๋ค์ ํ๋์ฉ ์ ํํ์ฌ ์ค์นํ๋ ๋ฐฉ๋ฒ์ ์๊ฐ, ์ฌ์ฌ์ฉ์ฑ ๋ฉด์์ ๋ถํธํจ์ด ๋ง๋ค.
์ด๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด์๋ "์ ์ธ์ ์ธ์ด"๋ฅผ ์ฌ์ฉํ์ฌ IaC ๋๊ตฌ๋ฅผ ํตํด ๊ตฌ์ฑํ๋ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ค.
๐ก eksctl
eks ๊ตฌ์ฑ์ ๊ฐ๋จํ ํ ์ ์๋ ๋๊ตฌ
eksctl์ ์ด์ฉํ์ฌ eks ๊ตฌ์ฑ์ ์งํํ๊ฒ ๋๋ฉด cloudformation์ด ์๋์ผ๋ก ์์ฑ๋๋ค. ๊ฐ ์๋น์ค์ ์ฐ๊ฒฐํ์ฌ ํ์ํ ์์์ ์์ฑํ๊ณ ์๋ก ์ฐ๊ฒฐํ๋ค.
โ ์ญํ ์์ฑ
• IAM > ์ญํ > ์ญํ ์์ฑ



โ ์ก์ธ์ค ํค ๋ง๋ค๊ธฐ
• ์ค๋ฅธ์ชฝ ์ ๋๋ค์ ํด๋ฆญ ํ ๋ณด์ ์๊ฒฉ ์ฆ๋ช

• ์ก์ธ์ค ํค ๋ง๋ค๊ธฐ

• ๋ฏธ๋ฆฌ ๋น๋ฐ ์์ธ์ค ํค ์ ์ฅํด๋๊ธฐ

โ awscli ์ค์น
apt install -y awscli
โ aws ์ค์
aws configure
AWS Access Key ID [None]: AKIAXYKJQRWGXHIQGBNA
AWS Secret Access Key [None]: ๋น๋ฐ ์์ธ์ค ํค
Default region name [None]: ap-northeast-1
Default output format [None]: ๊ทธ๋ฅ ์ํฐ
โ vpc ์ ๋ณด ํ์ธ
aws ec2 describe-vpcs

โ subnet ์ ๋ณด ํ์ธ
aws ec2 describe-subnets


โ eksctl ์ค์น
curl --silent --location \\
"<https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$>(uname -s)_amd64.tar.gz" | tar xz -C /tmp
mv /tmp/eksctl /usr/local/bin
โ eksctl ๋ช ๋ น์ด ์ฌ์ฉ ๊ฐ๋ฅ
eksctl

โ eksctl์ ํตํ ํด๋ฌ์คํฐ ๊ตฌ์ถ
eksctl create cluster --vpc-public-subnets subnet-0fa78ede6bad79a9e,subnet-0b6558aa5bb7cb2d7,subnet-00bdc4c78386849b6 --name eks-work-cluster1 --region ap-northeast-1 --version 1.23 --nodegroup-name eks-work-nodegroup --node-type t2.small --nodes 2 --nodes-min 2 --nodes-max 4
โ๏ธ์ฟ ๋ฒ๋คํฐ์ค ๋ฒ์ ์๋ฌ๋ฐ ๋
2024-02-21 11:49:05 [โ] getting Kubernetes version on EKS cluster: error running `kubectl version`: exit status 1 (check 'kubectl --kubeconfig=/etc/kubernetes/admin.conf version')
apt autoremove kubectl
curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.23.17/2024-01-04/bin/linux/amd64/kubectl
chmod +x ./kubectl
mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$HOME/bin:$PATH
echo 'export PATH=$HOME/bin:$PATH' >> ~/.bashrc
kubectl version --client
aws eks update-kubeconfig --region ap-northeast-1 --name eks-work-cluster1
โ CloudFormation

โ ec2 ์ธ์คํด์ค

โ node ํ์ธ
kubectl get node
kubectl get no -o wide

โ ๋์ปค ์ฌ์ค์น
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL <https://download.docker.com/linux/ubuntu/gpg> -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \\
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] <https://download.docker.com/linux/ubuntu> \\
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \\
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
โ ํด๋ฌ์คํฐ

โ ํด๋ฌ์คํฐ์ ํ๋ ํ์ธ

โ ns, pod ํ์ธ
kubectl get ns
kubectl get pod -n kube-system


โ pod ์์ฑ
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
containers:
- name: nginx-ctn
image: nginx
ports:
- containerPort: 80
nginx_pod.yaml
k apply -f nginx_pod.yaml

โ ์ธ๋ถ์ ํฌํธ ์์ ์คํ
kubectl port-forward nginx-pod 8888:80

โ ํ์ธ

'Linux > Kubernetes' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| [AWS] k8s์์ LoadBalancer ๊ตฌ์ฑํ๊ธฐ (classic, nlb) (0) | 2024.02.21 |
|---|---|
| [AWS] Amazon ECR - ํ๋ผ์ด๋น ๋ฆฌํฌ์งํ ๋ฆฌ ์์ฑํ๊ธฐ (0) | 2024.02.21 |
| [Kubernetes] ์ฟ ๋ฒ๋คํฐ์ค ํ๊ฒฝ์์ Canary Update ์ค์ต (0) | 2024.02.20 |