-
Notifications
You must be signed in to change notification settings - Fork 1
/
k8s-bootstrap-instance.yaml
61 lines (57 loc) · 1.52 KB
/
k8s-bootstrap-instance.yaml
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
AWSTemplateFormatVersion: "2010-09-09"
Description: "Surf Advisor K8S controller"
Parameters:
AZ:
Type: String
Default: eu-central-1a
KopsRole:
Type: String
Default: "kops"
SourceCodeBucket:
Type: String
Default: repo.surf.advisor
Resources:
SurfDNS:
Type: AWS::Route53::RecordSetGroup
Properties:
HostedZoneName: thesurfadvisor.com.
RecordSets:
- Name: k8s.thesurfadvisor.com.
Type: A
TTL: '900'
ResourceRecords:
- !GetAtt KopsInstance.PublicIp
KopsInstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Path: "/"
Roles:
- Ref: KopsRole
KopsInstance:
Type: AWS::EC2::Instance
Properties:
AvailabilityZone:
Ref: AZ
KeyName: SurfK8SKey
ImageId: ami-07f1fbbff759e24dd
InstanceType: t2.micro
IamInstanceProfile:
Ref: KopsInstanceProfile
UserData:
Fn::Base64:
Fn::Join:
- ''
- - "#!/bin/bash\n"
- "set -x"
- "\n"
- "exec > >(tee /home/ec2-user/user-data.log|logger -t user-data ) 2>&1"
- "\n"
- "export REPO_BUCKET="
- Ref: SourceCodeBucket
- "\n"
- "aws s3 sync s3://${REPO_BUCKET} /home/ec2-user/config"
- "\n"
- "chmod +x /home/ec2-user/config/k8s-bootstrap-init.sh"
- "\n"
- "bash /home/ec2-user/config/k8s-bootstrap-init.sh"
- "\n"