Created
November 5, 2014 18:52
-
-
Save dysinger/1f69b82687f70d0f080a to your computer and use it in GitHub Desktop.
coreos-with-flannel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AWSTemplateFormatVersion": "2010-09-09", | |
"Description": "CoreOS on EC2: http://coreos.com/docs/running-coreos/cloud-providers/ec2/", | |
"Mappings": { | |
"RegionMap": { | |
"ap-northeast-1": { | |
"AMI": "ami-f9b08ff8" | |
}, | |
"ap-southeast-1": { | |
"AMI": "ami-c24f6c90" | |
}, | |
"ap-southeast-2": { | |
"AMI": "ami-09117e33" | |
}, | |
"eu-central-1": { | |
"AMI": "ami-56ccfa4b" | |
}, | |
"eu-west-1": { | |
"AMI": "ami-a47fd5d3" | |
}, | |
"sa-east-1": { | |
"AMI": "ami-1104b30c" | |
}, | |
"us-east-1": { | |
"AMI": "ami-66e6680e" | |
}, | |
"us-west-1": { | |
"AMI": "ami-bbfcebfe" | |
}, | |
"us-west-2": { | |
"AMI": "ami-ff8dc5cf" | |
} | |
} | |
}, | |
"Parameters": { | |
"AdvertisedIPAddress": { | |
"AllowedValues": [ | |
"private", | |
"public" | |
], | |
"Default": "private", | |
"Description": "Use 'private' if your etcd cluster is within one region or 'public' if it spans regions or cloud providers.", | |
"Type": "String" | |
}, | |
"AllowSSHFrom": { | |
"Default": "0.0.0.0/0", | |
"Description": "The net block (CIDR) that SSH is available to.", | |
"Type": "String" | |
}, | |
"ClusterSize": { | |
"Default": "3", | |
"Description": "Number of nodes in cluster (3-12).", | |
"MaxValue": "64", | |
"MinValue": "3", | |
"Type": "Number" | |
}, | |
"DiscoveryURL": { | |
"Description": "An unique etcd cluster discovery URL. Grab a new token from https://discovery.etcd.io/new", | |
"Type": "String" | |
}, | |
"InstanceType": { | |
"AllowedValues": [ | |
"m3.medium", | |
"m3.large", | |
"m3.xlarge", | |
"m3.2xlarge", | |
"c3.large", | |
"c3.xlarge", | |
"c3.2xlarge", | |
"c3.4xlarge", | |
"c3.8xlarge", | |
"cc2.8xlarge", | |
"cr1.8xlarge", | |
"hi1.4xlarge", | |
"hs1.8xlarge", | |
"i2.xlarge", | |
"i2.2xlarge", | |
"i2.4xlarge", | |
"i2.8xlarge", | |
"r3.large", | |
"r3.xlarge", | |
"r3.2xlarge", | |
"r3.4xlarge", | |
"r3.8xlarge", | |
"t2.micro", | |
"t2.small", | |
"t2.medium" | |
], | |
"ConstraintDescription": "Must be a valid EC2 HVM instance type.", | |
"Default": "m3.medium", | |
"Description": "EC2 HVM instance type (m3.medium, etc).", | |
"Type": "String" | |
}, | |
"KeyPair": { | |
"Description": "The name of an EC2 Key Pair to allow SSH access to the instance.", | |
"Type": "String" | |
} | |
}, | |
"Resources": { | |
"CoreOSInternalIngressTCP": { | |
"Properties": { | |
"FromPort": "0", | |
"GroupName": { | |
"Ref": "CoreOSSecurityGroup" | |
}, | |
"IpProtocol": "tcp", | |
"SourceSecurityGroupId": { | |
"Fn::GetAtt": [ | |
"CoreOSSecurityGroup", | |
"GroupId" | |
] | |
}, | |
"ToPort": "65535" | |
}, | |
"Type": "AWS::EC2::SecurityGroupIngress" | |
}, | |
"CoreOSInternalIngressUDP": { | |
"Properties": { | |
"FromPort": "0", | |
"GroupName": { | |
"Ref": "CoreOSSecurityGroup" | |
}, | |
"IpProtocol": "udp", | |
"SourceSecurityGroupId": { | |
"Fn::GetAtt": [ | |
"CoreOSSecurityGroup", | |
"GroupId" | |
] | |
}, | |
"ToPort": "65535" | |
}, | |
"Type": "AWS::EC2::SecurityGroupIngress" | |
}, | |
"CoreOSSecurityGroup": { | |
"Properties": { | |
"GroupDescription": "CoreOS SecurityGroup", | |
"SecurityGroupIngress": [ | |
{ | |
"CidrIp": { | |
"Ref": "AllowSSHFrom" | |
}, | |
"FromPort": "22", | |
"IpProtocol": "tcp", | |
"ToPort": "22" | |
} | |
] | |
}, | |
"Type": "AWS::EC2::SecurityGroup" | |
}, | |
"CoreOSServerAutoScale": { | |
"Properties": { | |
"AvailabilityZones": { | |
"Fn::GetAZs": "" | |
}, | |
"DesiredCapacity": { | |
"Ref": "ClusterSize" | |
}, | |
"LaunchConfigurationName": { | |
"Ref": "CoreOSServerLaunchConfig" | |
}, | |
"MaxSize": "64", | |
"MinSize": "3", | |
"Tags": [ | |
{ | |
"Key": "Name", | |
"PropagateAtLaunch": true, | |
"Value": { | |
"Ref": "AWS::StackName" | |
} | |
} | |
] | |
}, | |
"Type": "AWS::AutoScaling::AutoScalingGroup" | |
}, | |
"CoreOSServerLaunchConfig": { | |
"Properties": { | |
"ImageId": { | |
"Fn::FindInMap": [ | |
"RegionMap", | |
{ | |
"Ref": "AWS::Region" | |
}, | |
"AMI" | |
] | |
}, | |
"InstanceType": { | |
"Ref": "InstanceType" | |
}, | |
"KeyName": { | |
"Ref": "KeyPair" | |
}, | |
"SecurityGroups": [ | |
{ | |
"Ref": "CoreOSSecurityGroup" | |
} | |
], | |
"UserData": { | |
"Fn::Base64": { | |
"Fn::Join": [ | |
"", | |
[ | |
"#cloud-config\n\n", | |
"coreos:\n", | |
" etcd:\n", | |
" discovery: ", | |
{ | |
"Ref": "DiscoveryURL" | |
}, | |
"\n", | |
" addr: $", | |
{ | |
"Ref": "AdvertisedIPAddress" | |
}, | |
"_ipv4:4001\n", | |
" peer-addr: $", | |
{ | |
"Ref": "AdvertisedIPAddress" | |
}, | |
"_ipv4:7001\n", | |
" units:\n", | |
" - name: media-ephemeral-format.service\n", | |
" command: start\n", | |
" content: |\n", | |
" [Unit]\n", | |
" Description=Ephemeral Format\n", | |
" [Service]\n", | |
" ExecStart=/usr/sbin/mkfs.btrfs -f /dev/xvdb\n", | |
" RemainAfterExit=yes\n", | |
" Type=oneshot\n", | |
" - name: media-ephemeral.mount\n", | |
" command: start\n", | |
" content: |\n", | |
" [Unit]\n", | |
" Description=Ephemeral Mount\n", | |
" After=media-ephemeral-format.service\n", | |
" Requires=media-ephemeral-format.service\n", | |
" [Mount]\n", | |
" What=/dev/xvdb\n", | |
" Where=/media/ephemeral\n", | |
" Type=btrfs\n", | |
" - name: jq-install.service\n", | |
" command: start\n", | |
" content: |\n", | |
" [Unit]\n", | |
" Description=JQ Install\n", | |
" After=network.target\n", | |
" [Service]\n", | |
" ExecStart=/bin/mkdir -p /opt/bin\n", | |
" ExecStart=/usr/bin/wget -O/opt/bin/jq https://stedolan.github.io/jq/download/linux64/jq\n", | |
" ExecStart=/usr/bin/chmod 755 /opt/bin/jq\n", | |
" RemainAfterExit=yes\n", | |
" Type=oneshot\n", | |
" - name: etcd.service\n", | |
" command: start\n", | |
" content: |\n", | |
" [Unit]\n", | |
" Description=etcd\n", | |
" [Service]\n", | |
" User=etcd\n", | |
" PermissionsStartOnly=true\n", | |
" Environment=ETCD_DATA_DIR=/var/lib/etcd ETCD_NAME=default\n", | |
" ExecStart=/usr/bin/etcd\n", | |
" Restart=always\n", | |
" RestartSec=10s\n", | |
" - name: flannel-install.service\n", | |
" command: start\n", | |
" content: |\n", | |
" [Unit]\n", | |
" Description=Flannel Install\n", | |
" After=network.target\n", | |
" [Service]\n", | |
" ExecStart=/bin/mkdir -p /opt/bin\n", | |
" ExecStart=/usr/bin/wget -O/opt/bin/flanneld https://s3.amazonaws.com/knewton-public-src/flanneld\n", | |
" ExecStart=/usr/bin/chmod 755 /opt/bin/flanneld\n", | |
" RemainAfterExit=yes\n", | |
" Type=oneshot\n", | |
" - name: flannel.service\n", | |
" command: start\n", | |
" content: |\n", | |
" [Unit]\n", | |
" Description=Flannel Service\n", | |
" After=etcd.service flannel-install.service\n", | |
" Requires=etcd.service flannel-install.service\n", | |
" [Service]\n", | |
" ExecStartPre=/bin/bash -c \"until /usr/bin/etcdctl set /coreos.com/network/config '{\\\"Network\\\":\\\"10.0.0.0/16\\\"}' ; do /usr/bin/sleep 1 ; done\"\n", | |
" ExecStart=/opt/bin/flanneld\n", | |
" ExecStartPost=/bin/bash -c \"until [ -e /run/flannel/subnet.env ]; do /usr/bin/sleep 1 ; done\"\n", | |
" [Install]\n", | |
" WantedBy=multi-user.target\n", | |
" - name: docker.service\n", | |
" command: start\n", | |
" content: |\n", | |
" [Unit]\n", | |
" Description=Docker with Flannel\n", | |
" Documentation=https://coreos.com/docs/\n", | |
" After=media-ephemeral.mount flannel.service\n", | |
" Requires=media-ephemeral.mount flannel.service docker.socket\n", | |
" [Service]\n", | |
" Environment=\"TMPDIR=/var/tmp/\"\n", | |
" EnvironmentFile=/run/flannel/subnet.env\n", | |
" ExecStartPre=/bin/mount --make-rprivate /\n", | |
" LimitNOFILE=1048576\n", | |
" LimitNPROC=1048576\n", | |
" ExecStart=/usr/bin/docker --daemon --graph=/media/ephemeral --storage-driver=btrfs --host=fd:// --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU}\n", | |
" [Install]\n", | |
" WantedBy=multi-user.target\n", | |
" - name: fleet.service\n", | |
" command: start\n" | |
] | |
] | |
} | |
} | |
}, | |
"Type": "AWS::AutoScaling::LaunchConfiguration" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment