일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
- minikube 설치 및 실행
- ADC 사용자 인증
- GCP 모니터링
- gke 클러스터 액세스 설정
- prometheus.yml 파일 설정
- kubectl 설치
- stackdriver exporter 설치
- 리소스삭제
- Prometheus 서버 설치
- 스위치 4대 기능
- 애플리케이션 기본 사용자 인증 정보
- github 사용법
- aws-nuke
- GCP VM
- vs code로 ssh 접속
- prometheus 서버 서비스등록
- compose.yml로 stackdriver-export 서비스 설정
- git
- permission denied 에러 발생
- github
- prometheus 연동
- 정적 웹 사이트 호스팅
- 방화벽 오픈
- 서비스 계정 키 설정
- dockerfile로 stackdriver-export이미지 생성
- prometheus dockerfile
- Prometheus 서버 설정
- stackdriver exporter
- 포트 9255 설정
- 리소스전체삭제
- Today
- Total
My __ 노트
AWS CloudFormation을 사용한 인프라 배포 자동화 본문
▶ CloudFormation 템플릿 배포
step 1) VPC 네트워킹 계층을 만드는 yml 파일 작성 <aws 템플릿 참고>
링크 : docs.aws.amazon.com/ko_kr/AWSCloudFormation/latest/UserGuide/template-guide.html
Resources:
# VPC with Internet Gateway
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 192.168.0.0/16
EnableDnsSupport: true
EnableDnsHostnames: true
Tags:
- Key: Name
Value: bluevpc
IGW:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: blueigw
VPCtoIGWConnection:
Type: AWS::EC2::VPCGatewayAttachment
DependsOn:
- IGW
- VPC
Properties:
InternetGatewayId: !Ref IGW
VpcId: !Ref VPC
# Public Route Table
PublicRouteTable:
Type: AWS::EC2::RouteTable
DependsOn: VPC
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: Public Route Table
PublicRoute:
Type: AWS::EC2::Route
DependsOn:
- PublicRouteTable
- IGW
Properties:
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref IGW
RouteTableId: !Ref PublicRouteTable
# Public Subnet
PublicSubnet:
Type: AWS::EC2::Subnet
DependsOn: VPC
Properties:
VpcId: !Ref VPC
MapPublicIpOnLaunch: true
CidrBlock: 192.168.0.0/24
AvailabilityZone: !Select
- 0
- !GetAZs
Ref: AWS::Region
Tags:
- Key: Name
Value: Public_subnet
PublicRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
DependsOn:
- PublicRouteTable
- PublicSubnet
Properties:
RouteTableId: !Ref PublicRouteTable
SubnetId: !Ref PublicSubnet
# App Security Group
AppSecurityGroup:
Type: AWS::EC2::SecurityGroup
DependsOn: VPC
Properties:
GroupName: Server_SG
GroupDescription: Enable access to Server
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 22
ToPort: 22
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 443
ToPort: 443
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: web_SG
step 2) CloudFormation 스택 생성
스택 생성 -> 준비된 템플릿 -> 템플릿 파일 업로드
-> 스택 이름 생성(나중에 다른 스택이 참조 할 수 있다) -> 태그 구성 -> 스택 생성
step 3) 스택 이벤트에서 CloudFormation에서 실행되는 활동들을 확인 할 수 있다.
확인 :
VPC, 서브넷 .. 전부 제대로 설치 된것을 확인 할 수 있다.
▶ 기존 CloudFormatiom 스택 참조 & 활용
step 1) 웹 서버를 생성하는 인스턴스 yml파일 작성
- Parameters에 NetworkStackName을 꼭 지정해 주어야 blue-network 템플릿의 스택값을 지금 생성하고 있는 템플릿이 참조할 수 있다.
Parameters:
NetworkStackName:
Type: String
Default: blue-network
AmazonLinuxAMIID:
Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
Default: /aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2
Resources:
WebServerSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Enable access to http
VpcId:
Fn::ImportValue:
!Sub ${NetworkStackName}-VPCID
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value:
Instance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: !Ref AmazonLinuxAMIID
SubnetId:
Fn::ImportValue:
!Sub ${NetworkStackName}-SubnetID
SecurityGroupIds:
- !Ref WebServerSecurityGroup
Tags:
- Key: Name
Value: web server
step 2) CloudFormation 스택 생성
스택 생성 -> 준비된 템플릿 -> 템플릿 파일 업로드
스택 이름 생성 -> 파라미터 (NetworkStackName이 참조할 스택이름을 표기하고 있다)
step 3) 스택 이벤트에서 CloudFormation에서 실행되는 활동들을 확인 할 수 있다.
확인 :
▶ 스택 업데이트
step 1) 기존 네트워크 템플릿에 보안 그룹 하나만 추가해본다.
step 2) 업데이트할 스택 선택 -> 업데이트 -> 현재 템플릿 교체 -> 템플릿 파일 업로드 -> 스택 업데이트 -> 확인해봄
전부 설치되면 UPDATE_COMPLETE라고 뜬다.
업데이트 전:
업데이트 후:
▶ CloudFormation Designer
AWS CloudFormation Designer은 AWS CloudFormation 템플릿을 작성, 확인, 수정하기 위한 그래픽 도구이다. Designer를 사용하면 드래그 앤 드롭 인터페이스를 사용하여 템플릿 리소스를 다이어그램으로 표시한 후 통합된 JSON및 YAML 편집기를 사용하여 해당 세부 정보를 편집할 수 있다.
step 1) Designer -> 템플릿 열기 -> 로컬 파일 -> 탬플릿 선택
아래와 같이 표시 된다.
▶ 스택 삭제 & 삭제 정책
스택 삭제시 Deletion Police(삭제 정택)을 사용하면 스택이 삭제될 때 생성되었던 리소스를 보존하거나 백업할 수 잇는 리소스에 대해서도 지정할 수 있습니다.
step 1) 웹 서버 설정 탬플릿에 아래 행을 추가 한 후 다시 업데이트 한다.
DiskVolume:
Type: AWS::EC2::Volume
Properties:
Size: 100
AvailabilityZone: ap-northeast-1a
DeletionPolicy: Snapshot
step 2) 웹 서버 스택을 삭제 해 본다.
step 3) 웹 서버 스택이 삭제 되자 웹 서버도 함께 삭제 되는 것을 확인 할 수 있다.
step 4) EC2의 스냅샷에 가보면 DeletionPolicy에 의해 생성된 스냅샷을 확인 할 수 있다.
'클라우드 > AWS(클라우드)' 카테고리의 다른 글
AWS PHD 알람 설정 (1) - 콘솔에서 SNS와 Chatbot을 이용하여 알람 전송 (0) | 2023.10.05 |
---|---|
AWS 클라우드 VPC 리소스들에 대한 개념 (4) | 2020.12.09 |
웹 애플리케이션 배포 - Part 2 (EC2, RDS 연동) (0) | 2020.11.27 |
웹 애플리케이션 배포 - Part 1 (VPC, EC2, RDS 생성) (0) | 2020.11.26 |
정적 웹 사이트 호스팅 ( Amazon S3 ) 구현 (0) | 2020.11.25 |