You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cf) 설치 대상 host에 Public-key 배포
ssh-copy-id root@10.0.2.10
2. Terrform 으로 host 셋팅
cd
git clone https://github.com/Finfra/sreMsa
cd ~/sreMsa/Lab1.Kubespray/Lab3.InstanceForKubernetes
terraform init
terraform apply --auto-approve
3. Hosts파일 셋팅
aws configure
# security setting
AWS Access Key ID [None]: xxxxxxxxxx
AWS Secret Access Key [None]: xxxxxxxxxxxxxxxxxxx
Default region name [None]: ap-northeast-2
Default output format [None]: text
cd ~/sreMsa/Lab1.Kubespray/Lab3.InstanceForKubernetes
# rm -rf ~/.ssh/known_hosts
bash doSetHosts.sh
3.5. 모든 호스트 repo update
필수 아님. repo상태 안좋을때만,
hosts=("vm01" "vm02" "vm03")
for host in "${hosts[@]}"; do
echo "Connecting to $host ..."
ssh "$host" << EOF
# apt update 및 repository 추가
sudo apt update
REPO_LINE="deb http://mirror.kakao.com/ubuntu/ noble main universe"
if ! grep -Fxq "\$REPO_LINE" /etc/apt/sources.list; then
echo "\$REPO_LINE" | sudo tee -a /etc/apt/sources.list
echo "Repository line added successfully."
else
echo "Repository line already exists."
fi
sudo apt-get update
EOF
if [ $? -eq 0 ]; then
echo "Script executed successfully on $host."
else
echo "Failed to execute script on $host."
fi
done
#cf : deb http://ftp.daum.net/ubuntu/ noble main universe
for i in $(seq 3); do ssh ubuntu@vm0$i sudo sh -c 'shutdown -h now'; done
Startup all Instance
ids=$(aws ec2 describe-instances --filters "Name=tag-value,Values=vm0*" --query "Reservations[].Instances[].InstanceId" --output text)
for i in $ids; do aws ec2 start-instances --instance-ids $i ;done