140 lines
4.8 KiB
YAML
140 lines
4.8 KiB
YAML
Resources:
|
|
HardK8sMaster0:
|
|
Type: AWS::EC2::Instance
|
|
Properties:
|
|
InstanceType: t3.micro
|
|
SubnetId: !ImportValue hard-k8s-subnet
|
|
SecurityGroupIds:
|
|
- !ImportValue hard-k8s-sg
|
|
ImageId:
|
|
Fn::FindInMap: [UbuntuAMIs, !Ref "AWS::Region", "id"]
|
|
KeyName: !Ref ParamKeyName
|
|
PrivateIpAddress: 10.240.0.10
|
|
# SourceDestCheck: false
|
|
UserData:
|
|
Fn::Base64: |-
|
|
#cloud-config
|
|
fqdn: master-0.k8shardway.local
|
|
hostname: master-0
|
|
runcmd:
|
|
- echo "preserve_hostname: true" >> /etc/cloud/cloud.cfg
|
|
write_files:
|
|
- path: /etc/hosts
|
|
permissions: '0644'
|
|
content: |
|
|
127.0.0.1 localhost localhost.localdomain
|
|
# Kubernetes the Hard Way - hostnames
|
|
10.240.0.10 master-0
|
|
10.240.0.11 master-1
|
|
10.240.0.12 master-2
|
|
10.240.0.20 worker-0
|
|
10.240.0.21 worker-1
|
|
10.240.0.22 worker-2
|
|
Tags: [ { "Key": "Name", "Value": "master-0" } ]
|
|
|
|
HardK8sMaster1:
|
|
Type: AWS::EC2::Instance
|
|
Properties:
|
|
InstanceType: t3.micro
|
|
SubnetId: !ImportValue hard-k8s-subnet
|
|
SecurityGroupIds:
|
|
- !ImportValue hard-k8s-sg
|
|
ImageId:
|
|
Fn::FindInMap: [UbuntuAMIs, !Ref "AWS::Region", "id"]
|
|
KeyName: !Ref ParamKeyName
|
|
PrivateIpAddress: 10.240.0.11
|
|
# SourceDestCheck: false
|
|
UserData:
|
|
Fn::Base64: |-
|
|
#cloud-config
|
|
fqdn: master-1.k8shardway.local
|
|
hostname: master-1
|
|
runcmd:
|
|
- echo "preserve_hostname: true" >> /etc/cloud/cloud.cfg
|
|
write_files:
|
|
- path: /etc/hosts
|
|
permissions: '0644'
|
|
content: |
|
|
127.0.0.1 localhost localhost.localdomain
|
|
# Kubernetes the Hard Way - hostnames
|
|
10.240.0.10 master-0
|
|
10.240.0.11 master-1
|
|
10.240.0.12 master-2
|
|
10.240.0.20 worker-0
|
|
10.240.0.21 worker-1
|
|
10.240.0.22 worker-2
|
|
Tags: [ { "Key": "Name", "Value": "master-1" } ]
|
|
|
|
HardK8sMaster2:
|
|
Type: AWS::EC2::Instance
|
|
Properties:
|
|
InstanceType: t3.micro
|
|
SubnetId: !ImportValue hard-k8s-subnet
|
|
SecurityGroupIds:
|
|
- !ImportValue hard-k8s-sg
|
|
ImageId:
|
|
Fn::FindInMap: [UbuntuAMIs, !Ref "AWS::Region", "id"]
|
|
KeyName: !Ref ParamKeyName
|
|
PrivateIpAddress: 10.240.0.12
|
|
# SourceDestCheck: false
|
|
UserData:
|
|
Fn::Base64: |-
|
|
#cloud-config
|
|
fqdn: master-2.k8shardway.local
|
|
hostname: master-2
|
|
runcmd:
|
|
- echo "preserve_hostname: true" >> /etc/cloud/cloud.cfg
|
|
write_files:
|
|
- path: /etc/hosts
|
|
permissions: '0644'
|
|
content: |
|
|
127.0.0.1 localhost localhost.localdomain
|
|
# Kubernetes the Hard Way - hostnames
|
|
10.240.0.10 master-0
|
|
10.240.0.11 master-1
|
|
10.240.0.12 master-2
|
|
10.240.0.20 worker-0
|
|
10.240.0.21 worker-1
|
|
10.240.0.22 worker-2
|
|
Tags: [ { "Key": "Name", "Value": "master-2" } ]
|
|
|
|
Parameters:
|
|
ParamKeyName:
|
|
Type: AWS::EC2::KeyPair::KeyName
|
|
Default: ec2-key
|
|
|
|
# $ aws ec2 describe-regions --query 'Regions[].RegionName' --output text \
|
|
# | tr "\t" "\n" | sort \
|
|
# | xargs -I _R_ aws --region _R_ ec2 describe-images \
|
|
# --filters Name=name,Values="ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20191002" \
|
|
# --query 'Images[0].ImageId' --output
|
|
Mappings:
|
|
UbuntuAMIs:
|
|
ap-northeast-1: { "id": "ami-0cd744adeca97abb1" }
|
|
ap-northeast-2: { "id": "ami-00379ec40a3e30f87" }
|
|
ap-northeast-3: { "id": "ami-0bd42271bb31d96d2" }
|
|
ap-south-1: { "id": "ami-0123b531fc646552f" }
|
|
ap-southeast-1: { "id": "ami-061eb2b23f9f8839c" }
|
|
ap-southeast-2: { "id": "ami-00a54827eb7ffcd3c" }
|
|
ca-central-1: { "id": "ami-0b683aae4ee93ef87" }
|
|
eu-central-1: { "id": "ami-0cc0a36f626a4fdf5" }
|
|
eu-north-1: { "id": "ami-1dab2163" }
|
|
eu-west-1: { "id": "ami-02df9ea15c1778c9c" }
|
|
eu-west-2: { "id": "ami-0be057a22c63962cb" }
|
|
eu-west-3: { "id": "ami-087855b6c8b59a9e4" }
|
|
sa-east-1: { "id": "ami-02c8813f1ea04d4ab" }
|
|
us-east-1: { "id": "ami-04b9e92b5572fa0d1" }
|
|
us-east-2: { "id": "ami-0d5d9d301c853a04a" }
|
|
us-west-1: { "id": "ami-0dd655843c87b6930" }
|
|
us-west-2: { "id": "ami-06d51e91cea0dac8d" }
|
|
|
|
Outputs:
|
|
Master0:
|
|
Value: !Ref HardK8sMaster0
|
|
Export: { Name: hard-k8s-master-0 }
|
|
Master1:
|
|
Value: !Ref HardK8sMaster1
|
|
Export: { Name: hard-k8s-master-1 }
|
|
Master2:
|
|
Value: !Ref HardK8sMaster2
|
|
Export: { Name: hard-k8s-master-2 } |