[AWS AppMesh/AWS Cloud Map] AWS 기초를 배우는 특별편입니다.
먼저
중도에서 좌절하다.
경과보고입니다.
개요
'AWS 기초를 배우는 스페셜 편'에서는'AWS 앱 메시와 AWS 클라우드 맵'행사에 참여한 소감 페이지다.
'AWS Evannest 시리즈 AWS를 배우는 기초'는
AWS Evannest 시리즈 AWS의 기본 학습
다음은 Conpanss 페이지에서 참조합니다.
Amazon Web Services(AWS)는 현재 200개가 넘는 서비스를 제공하고 있으며, 매일 서비스를 계속 확장하고 있다.
이 AWS Enterisits는 초심자, 중급자를 목표로 하는 강좌로 매주 하나씩 AWS 서비스로 그 기초를 설명한다.오후에 일하기 전에 함께 기술을 향상시킬까요?
주의점 등장자의 발표 내용은 아마존 인터넷 서비스 일본이 주최하는 것이 아니라 커뮤니티 행사의 일환으로 학습회를 개최하는 것이다.
매주 감사합니다!
AWS AppMesh 및 AWS Cloud Map
AWS AppMesh
AWS App Mesh란 무엇입니까?
AWS App Mesh에서는 서비스 간 통신을 모니터링, 관리 및 디버깅하는 작업이 간단해집니다.앱 메시는 마이크로서비스 용기와 함께 개발된 오픈소스의 서비스망상 에이전트인 엔보이를 사용한다.App Mesh는 AWS의 서비스와 통합하여 모니터링과 추적을 하고 일반적인 제3자 도구와 함께 사용할 수 있다.App Mesh는 Amazon ECS, Amazon EKS, AWS Fargate, AWS에서 실행되는 Kubernetes가 관리하는 마이크로 서비스 용기와 Amazon EC2에서 실행되는 서비스에 사용할 수 있다.
EC2에서도 움직이나요
AWS Cloud Map
이른바 AWS 클라우드 맵
AWS 클라우드 맵은 클라우드 리소스 검색 서비스입니다.Cloud Map은 응용 프로그램 리소스에 사용자 정의 이름을 추가하고 동적 변경 리소스의 위치를 자동으로 업데이트합니다.응용 프로그램은 항상 이 자원의 최신 위치를 감지하여 응용 프로그램의 가용성을 높인다.
현대 응용 프로그램은 일반적으로 API를 통해 접근할 수 있는 특정 기능을 수행할 수 있는 여러 서비스로 구성되어 있다.모든 서비스는 데이터베이스, 대기열, 대상 저장, 고객이 정의한 마이크로 서비스 등 다른 자원과 상호작용을 하지만 기능을 발휘하기 위해서는 모든 의존하는 인프라 자원을 찾아야 한다.
클라우드맵은 데이터베이스, 큐, 마이크로 서비스, 사용자 정의 이름을 가진 기타 클라우드 리소스 등 애플리케이션 리소스를 등록할 수 있다.그런 다음 Cloud Map은 계속해서 리소스 상태를 확인하고 해당 위치가 최신인지 확인합니다.그리고 응용 프로그램의 자원은 응용 프로그램 버전과 디자인 환경에 따라 등록표에 필요한 실제 자원의 위치를 조회할 수 있다.
밧줄을 풀고 갑시다.
거북전 선생의 수제 재료
그가 핸드볼을 할 때 무엇을 하는지 모르는 곳이 많으니 풀어라.
주로 명령 링크
1.
rm -vf ${HOME}/.aws/credentials
의도/의미Cloud9 기본 credentials를 삭제하여 EC2 역할을 활성화합니다.
2.
export ACCOUNT_ID=$(aws sts get-caller-identity --output text --query Account)
export AWS_REGION=$(curl -s 169.254.169.254/latest/dynamic/instance-identity/document | \
grep region | cut -d\" -f4)
echo "export ACCOUNT_ID=${ACCOUNT_ID}" >> ~/.bash_profile
echo "export AWS_REGION=${AWS_REGION}" >> ~/.bash_profile
aws configure set default.region ${AWS_REGION}
aws configure get default.region
의도/의미bash_프로필에 ACCOUNT을 넣습니다.ID、AWS_REGION 설정
aws configure에서default.region 설정
3.
aws sts get-caller-identity
의도/의미현재 사용 중인 Role이 AppMesh-Workshop-Admin인지 확인
4.
# create a folder for the scripts
mkdir ~/environment/scripts
# tools script
cat > ~/environment/scripts/install-tools <<-"EOF"
#!/bin/bash -ex
sudo yum install -y jq gettext bash-completion
sudo curl --silent --location "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/linux_64bit/session-manager-plugin.rpm" -o "session-manager-plugin.rpm"
sudo yum install -y session-manager-plugin.rpm
sudo curl --silent --location -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.16.8/bin/linux/amd64/kubectl
sudo chmod +x /usr/local/bin/kubectl
echo 'source <(kubectl completion bash)' >>~/.bashrc
source ~/.bashrc
curl --silent --location "https://github.com/weaveworks/eksctl/releases/download/latest_release/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp
sudo mv -v /tmp/eksctl /usr/local/bin
if ! [ -x "$(command -v jq)" ] || ! [ -x "$(command -v envsubst)" ] || ! [ -x "$(command -v kubectl)" ] || ! [ -x "$(command -v eksctl)" ] || ! [ -x "$(command -v ssm-cli)" ]; then
echo 'ERROR: tools not installed.' >&2
exit 1
fi
pip install awscli --upgrade --user
EOF
chmod +x ~/environment/scripts/install-tools
의도/의미/environment/script/install-tools에서script를 만들고 있습니다.script가 설치한 것은 다음과 같습니다
jq
JSON에서 추출, 통계, 성형 기능
gettext
응용 프로그램의 국제화 기능.예를 들어 일본에서 온 방문은'환영', 미국에서 온 방문은'웰컴'으로 나뉜다.
bash-completion
명령 옵션의 입력 완성 기능
session-manager-plugin
AWS 세션 관리자 플러그인
kubectl
Kubbernetes 클러스터를 제어하는 명령선 도구
eksctl
Amazon EKS 클러스터 및 노드를 제어하는 명령줄 도구
aws cli
클라우드 9는 원래 UPDATE가 있지만.
5.
~/environment/scripts/install-tools
의도/의미4에서 만든 스크립트 실행
6.
# clone the github repositories
cd ~/environment
git clone https://github.com/brentley/ecsdemo-frontend.git
git clone https://github.com/brentley/ecsdemo-nodejs.git
git clone https://github.com/brentley/ecsdemo-crystal.git
의도/의미github에서clone까지 필요한 재료
7.
cd ~/environment
curl -s https://raw.githubusercontent.com/brentley/appmeshworkshop/master/templates/appmesh-baseline.yml -o appmesh-baseline.yml
의도/의미응용 프로그램의 CloudFormation 템플릿 가져오기
천 줄이야...
8.
# Define environment variable
IAM_ROLE=$(curl -s 169.254.169.254/latest/meta-data/iam/info | \
jq -r '.InstanceProfileArn' | cut -d'/' -f2)
#Check if the template is already deployed. If not, deploy it
CFN_TEMPLATE=$(aws cloudformation list-stacks | jq -c '.StackSummaries[].StackName | select( . == "appmesh-workshop" )')
if [ -z "$CFN_TEMPLATE" ]
then
echo "Deploying Cloudformation Template"
aws cloudformation deploy \
--template-file appmesh-baseline.yml \
--stack-name appmesh-workshop \
--capabilities CAPABILITY_IAM \
--parameter-overrides Cloud9IAMRole=$IAM_ROLE
else
echo "Template already deployed. Go ahead to the next chapter."
fi
의도/의미curl -s 169.254.169.254/latest/meta-data/iam/info
실례 설정 파일 정보를 얻습니다.나 이거 몰라.
aws cloudformation list-stacks | jq -c '.StackSummaries[].StackName | select( . == "appmesh-workshop")'
appmesh-workshop이라는 Stack이 있는지 확인
Status의 DELETE-COMPLETE의 Stack을 획득할 수 있기 때문에 DELETECOMPLETE라면 실행 가능한가요?
aws cloudformation deploy
--template-file appmesh-baseline.yml
--stack-name appmesh-workshop
--capabilities CAPABILITY_IAM
--parameter-overrides Cloud9IAMRole=$IAM_ROLE
AWS CLI에서 clodformation deploy 실행
8 보충 appmesh-baseline.yml
https://raw.githubusercontent.com/brentley/appmeshworkshop/master/templates/appmesh-baseline.yml
의도/의미1000줄 정도입니다. 링크 대상을 참조하십시오.
ECR 제작
ECR 제작
ECS 클러스터 생성
ECS 작업 정의
LB 보안 그룹
LB와 함께 연관된 3개의 공용 서브넷
LB의 청중은 http
9.
# Retrieve private key
aws ssm get-parameter \
--name /appmeshworkshop/keypair/id_rsa \
--with-decryption | jq .Parameter.Value --raw-output > ~/.ssh/id_rsa
# Set appropriate permission on private key
chmod 600 ~/.ssh/id_rsa
# Store public key separately from private key
ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
의도/의미CloudFormation에서 만든 매개변수 스토어의 값을 디코딩한 후 ~/ssh 산하에서 기밀 키로 출력
개인 키로 공개 키를 만듭니다.ssh 아래로 출력
10.
# bootstrap script
cat > ~/environment/scripts/bootstrap <<-"EOF"
#!/bin/bash -ex
echo 'Fetching CloudFormation outputs'
~/environment/scripts/fetch-outputs
echo 'Building Docker Containers'
~/environment/scripts/build-containers
echo 'Creating the ECS Services'
~/environment/scripts/create-ecs-service
echo 'Creating the EKS Cluster'
~/environment/scripts/build-eks
EOF
# fetch-outputs script
cat > ~/environment/scripts/fetch-outputs <<-"EOF"
#!/bin/bash -ex
STACK_NAME=appmesh-workshop
aws cloudformation describe-stacks \
--stack-name "$STACK_NAME" | \
jq -r '[.Stacks[0].Outputs[] |
{key: .OutputKey, value: .OutputValue}] | from_entries' > cfn-output.json
EOF
# Create EKS configuration file
cat > ~/environment/scripts/eks-configuration <<-"EOF"
#!/bin/bash -ex
STACK_NAME=appmesh-workshop
PRIVSUB1_ID=$(jq < cfn-output.json -r '.PrivateSubnetOne')
PRIVSUB1_AZ=$(aws ec2 describe-subnets --subnet-ids $PRIVSUB1_ID | jq -r '.Subnets[].AvailabilityZone')
PRIVSUB2_ID=$(jq < cfn-output.json -r '.PrivateSubnetTwo')
PRIVSUB2_AZ=$(aws ec2 describe-subnets --subnet-ids $PRIVSUB2_ID | jq -r '.Subnets[].AvailabilityZone')
PRIVSUB3_ID=$(jq < cfn-output.json -r '.PrivateSubnetThree')
PRIVSUB3_AZ=$(aws ec2 describe-subnets --subnet-ids $PRIVSUB3_ID | jq -r '.Subnets[].AvailabilityZone')
AWS_REGION=$(curl -s 169.254.169.254/latest/dynamic/instance-identity/document | grep region | cut -d\" -f4)
cat > /tmp/eks-configuration.yml <<-EKS_CONF
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: $STACK_NAME
region: $AWS_REGION
vpc:
subnets:
private:
$PRIVSUB1_AZ: { id: $PRIVSUB1_ID }
$PRIVSUB2_AZ: { id: $PRIVSUB2_ID }
$PRIVSUB3_AZ: { id: $PRIVSUB3_ID }
nodeGroups:
- name: appmesh-workshop-ng
labels: { role: workers }
instanceType: m5.large
desiredCapacity: 3
ssh:
allow: false
privateNetworking: true
iam:
withAddonPolicies:
imageBuilder: true
albIngress: true
autoScaler: true
appMesh: true
xRay: true
cloudWatch: true
externalDNS: true
EKS_CONF
EOF
# Create the EKS building script
cat > ~/environment/scripts/build-eks <<-"EOF"
#!/bin/bash -ex
EKS_CLUSTER_NAME=$(jq < cfn-output.json -r '.EKSClusterName')
if [ -z "$EKS_CLUSTER_NAME" ] || [ "$EKS_CLUSTER_NAME" == null ]
then
if ! aws sts get-caller-identity --query Arn | \
grep -q 'assumed-role/AppMesh-Workshop-Admin/i-'
then
echo "Your role is not set correctly for this instance"
exit 1
fi
sh -c ~/environment/scripts/eks-configuration
eksctl create cluster -f /tmp/eks-configuration.yml
else
NODES_IAM_ROLE=$(jq < cfn-output.json -r '.NodeInstanceRole')
aws eks --region $AWS_REGION update-kubeconfig --name $EKS_CLUSTER_NAME
cat > /tmp/aws-auth-cm.yml <<-EKS_AUTH
apiVersion: v1
kind: ConfigMap
metadata:
name: aws-auth
namespace: kube-system
data:
mapRoles: |
- rolearn: $NODES_IAM_ROLE
username: system:node:{{EC2PrivateDNSName}}
groups:
- system:bootstrappers
- system:nodes
EKS_AUTH
kubectl apply -f /tmp/aws-auth-cm.yml
fi
EOF
# build-containers script
cat > ~/environment/scripts/build-containers <<-"EOF"
#!/bin/bash -ex
CRYSTAL_ECR_REPO=$(jq < cfn-output.json -r '.CrystalEcrRepo')
NODEJS_ECR_REPO=$(jq < cfn-output.json -r '.NodeJSEcrRepo')
$(aws ecr get-login --no-include-email)
docker build -t crystal-service ecsdemo-crystal
docker tag crystal-service:latest $CRYSTAL_ECR_REPO:vanilla
docker push $CRYSTAL_ECR_REPO:vanilla
docker build -t nodejs-service ecsdemo-nodejs
docker tag nodejs-service:latest $NODEJS_ECR_REPO:latest
docker push $NODEJS_ECR_REPO:latest
EOF
# create-ecs-service script
cat > ~/environment/scripts/create-ecs-service <<-"EOF"
#!/bin/bash -ex
CLUSTER=$(jq < cfn-output.json -r '.EcsClusterName')
TASK_DEF=$(jq < cfn-output.json -r '.CrystalTaskDefinition')
TARGET_GROUP=$(jq < cfn-output.json -r '.CrystalTargetGroupArn')
SUBNET_ONE=$(jq < cfn-output.json -r '.PrivateSubnetOne')
SUBNET_TWO=$(jq < cfn-output.json -r '.PrivateSubnetTwo')
SUBNET_THREE=$(jq < cfn-output.json -r '.PrivateSubnetThree')
SECURITY_GROUP=$(jq < cfn-output.json -r '.ContainerSecurityGroup')
aws ecs create-service \
--cluster $CLUSTER \
--service-name crystal-service-lb \
--task-definition $TASK_DEF \
--load-balancer targetGroupArn=$TARGET_GROUP,containerName=crystal-service,containerPort=3000 \
--desired-count 3 \
--launch-type FARGATE \
--network-configuration \
"awsvpcConfiguration={
subnets=[$SUBNET_ONE,$SUBNET_TWO,$SUBNET_THREE],
securityGroups=[$SECURITY_GROUP],
assignPublicIp=DISABLED}"
EOF
chmod +x ~/environment/scripts/*
의도/의미/environment/script/bootstrap에서script를 만들었습니다.설정 내용은 다음과 같다.
bootstrap
간단한 시작 셸은'fetch-outputs','build-containers','create-ecs-s 서비스','build-eks'를 순서대로 시작합니다.
fetch-outputs
CloudFormation Outpus의 정보 cfn-outputjson으로 내보내기
build-eks
eks 프로필 만들기
build-containers
create-ecs-service
11.
~/environment/scripts/bootstrap
의도/의미10에서 만든bootstrap 실행하기
ERROR
Error: timed out (after 25m0s) waiting for at least 3 nodes to join the cluster and become ready in "appmesh-workshop-ng"
그래서인지 이후에도 오류가 발생해 지난주 토요일과 함께 두 번째로 중단됐다.계좌를 바꾸시겠습니까?
Reference
이 문제에 관하여([AWS AppMesh/AWS Cloud Map] AWS 기초를 배우는 특별편입니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/shigeru_oda/articles/9a11e90846dba265bf3a텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)