Skip to content

Commit a0bad1b

Browse files
Nicola Kabarkencochrane
authored andcommitted
Add DTR to DDC Install - fixes docker-archive#332 (docker-archive#392)
* fixes docker-archive#332 Signed-off-by: Nicola Kabar <[email protected]> * adding DTR to DDC fixes docker-archive#332 Signed-off-by: Nicola Kabar <[email protected]>
1 parent 4ddedb3 commit a0bad1b

File tree

3 files changed

+257
-88
lines changed

3 files changed

+257
-88
lines changed

aws/cloudformation/docker_for_aws_ddc.json

Lines changed: 132 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"InstanceType" : {
1414
"Type" : "String",
15-
"Description" : "EC2 HVM instance type (t2.micro, m3.medium, etc).",
15+
"Description" : "EC2 HVM instance type (t2.medium, m3.medium, etc).",
1616
"AllowedValues" : [
1717
"t2.micro","t2.small","t2.medium","t2.large","m4.large","m4.xlarge","m4.2xlarge","m4.4xlarge","m4.10xlarge","m3.medium",
1818
"m3.large","m3.xlarge","m3.2xlarge","c4.large","c4.xlarge","c4.2xlarge","c4.4xlarge","c4.8xlarge","c3.large","c3.xlarge",
@@ -23,9 +23,9 @@
2323
},
2424
"ManagerInstanceType" : {
2525
"Type" : "String",
26-
"Description" : "EC2 HVM instance type (t2.medium, m3.medium, etc).",
26+
"Description" : "EC2 HVM instance type (m3.medium, m4.large etc).",
2727
"AllowedValues" : [
28-
"t2.medium","t2.large","m4.large","m4.xlarge","m4.2xlarge","m4.4xlarge","m4.10xlarge","m3.medium",
28+
"m4.large","m4.xlarge","m4.2xlarge","m4.4xlarge","m4.10xlarge","m3.medium",
2929
"m3.large","m3.xlarge","m3.2xlarge","c4.large","c4.xlarge","c4.2xlarge","c4.4xlarge","c4.8xlarge","c3.large","c3.xlarge",
3030
"c3.2xlarge","c3.4xlarge","c3.8xlarge","r3.large","r3.xlarge","r3.2xlarge","r3.4xlarge","r3.8xlarge","i2.xlarge",
3131
"i2.2xlarge","i2.4xlarge","i2.8xlarge" ],
@@ -59,6 +59,10 @@
5959
"MinLength": "8",
6060
"MaxLength": "40",
6161
"ConstraintDescription": "must be at least 8 characters"
62+
},
63+
"License": {
64+
"Type": "String",
65+
"Description": "Docker Datacenter License in JSON format or URL to download it. Get Trial License here https://store.docker.com/bundles/docker-datacenter "
6266
}
6367
},
6468
"Metadata" : {
@@ -73,8 +77,8 @@
7377
"Parameters" : [ "ManagerInstanceType", "InstanceType", "KeyName" ]
7478
},
7579
{
76-
"Label" : { "default":"Optional Features" },
77-
"Parameters" : [ "DDCUsernameSet", "DDCPasswordSet"]
80+
"Label" : { "default":"DDC Properties" },
81+
"Parameters" : [ "DDCUsernameSet", "DDCPasswordSet","License"]
7882
}
7983
],
8084
"ParameterLabels" : {
@@ -84,7 +88,8 @@
8488
"ManagerInstanceType" : { "default" : "Swarm manager instance type?" },
8589
"KeyName" : { "default" : "Which SSH key to use?" },
8690
"DDCUsernameSet" : { "default" : "Enter the Username you want to use with Docker Datacenter" },
87-
"DDCPasswordSet" : { "default" : "Enter your Docker Datacenter password" }
91+
"DDCPasswordSet" : { "default" : "Enter your Docker Datacenter password" },
92+
"License" : { "default" : "Enter your Docker Datacenter License" }
8893
}
8994
}
9095
},
@@ -496,12 +501,12 @@
496501
}
497502
},
498503
"ManagerAsg" : {
499-
"DependsOn" : ["SwarmDynDBTable", "PubSubnetAz1", "PubSubnetAz2", "SSHLoadBalancer", "ExternalLoadBalancer"],
504+
"DependsOn" : ["SwarmDynDBTable", "PubSubnetAz1", "PubSubnetAz2", "UCPLoadBalancer","DTRLoadBalancer" ,"ExternalLoadBalancer"],
500505
"Type" : "AWS::AutoScaling::AutoScalingGroup",
501506
"Properties" : {
502507
"VPCZoneIdentifier" : [ { "Fn::Join" : [",", [ { "Ref" : "PubSubnetAz1" }, { "Ref" : "PubSubnetAz2" } ] ] } ],
503-
"LaunchConfigurationName" : { "Ref" : "ManagerLaunchConfigBeta3" },
504-
"LoadBalancerNames" : [ { "Ref" : "SSHLoadBalancer" }, { "Ref" : "ExternalLoadBalancer" } ],
508+
"LaunchConfigurationName" : { "Ref" : "ManagerLaunchConfig" },
509+
"LoadBalancerNames" : [ { "Ref" : "DTRLoadBalancer" }, { "Ref" : "ExternalLoadBalancer" },{ "Ref" : "UCPLoadBalancer" } ],
505510
"MinSize" : "0",
506511
"MaxSize" : "5",
507512
"DesiredCapacity" : { "Ref" : "ManagerSize" },
@@ -540,7 +545,7 @@
540545
}
541546
},
542547

543-
"ManagerLaunchConfigBeta3": {
548+
"ManagerLaunchConfig": {
544549
"DependsOn": "ExternalLoadBalancer",
545550
"Type": "AWS::AutoScaling::LaunchConfiguration",
546551
"Properties": {
@@ -624,16 +629,21 @@
624629
"-v /var/lib/docker/swarm:/var/lib/docker/swarm ",
625630
"docker4x/l4controller-aws:$DOCKER_FOR_IAAS_VERSION run --log=4 --all=true\n",
626631

627-
"docker run --log-driver=json-file --name=ddc-init-aws --restart=no --rm ",
632+
"docker run --log-driver=json-file --name=ddc-init-aws --restart=no --rm",
628633
"-e NODE_TYPE='manager' ",
629634
"-e STACK_NAME='",{ "Ref" : "AWS::StackName" }, "' ",
630635
"-e REGION='",{ "Ref" : "AWS::Region" }, "' ",
631636
"-e UCP_ADMIN_USER='",{ "Ref" : "DDCUsernameSet" }, "' ",
632637
"-e UCP_ADMIN_PASSWORD='",{ "Ref" : "DDCPasswordSet" }, "' ",
633-
"-e ELB_NAME='SSHLoadBalancer' ",
638+
"-e NODE_NAME=$HOSTNAME ",
639+
"-e S3_BUCKET_NAME='",{ "Ref": "DDCBucket" }, "' ",
640+
"-e LICENSE='",{ "Ref": "License" }, "' ",
641+
"-e UCP_ELB_HOSTNAME='",{"Fn::GetAtt": ["UCPLoadBalancer","DNSName"]}, "' ",
642+
"-e DTR_ELB_HOSTNAME='",{"Fn::GetAtt": ["DTRLoadBalancer","DNSName"]}, "' ",
634643
"-e INSTALL_DDC='yes' ",
635644
"-v /var/run/docker.sock:/var/run/docker.sock ",
636645
"-v /usr/bin/docker:/usr/bin/docker ",
646+
"-v /tmp/docker:/tmp/docker ",
637647
"docker4x/ddc-init-aws:$DOCKER_FOR_IAAS_VERSION\n"
638648

639649
]
@@ -647,7 +657,7 @@
647657
"Type" : "AWS::AutoScaling::AutoScalingGroup",
648658
"Properties" : {
649659
"VPCZoneIdentifier" : [ { "Fn::Join" : [",", [ { "Ref" : "PubSubnetAz1" }, { "Ref" : "PubSubnetAz2" } ] ] } ],
650-
"LaunchConfigurationName" : { "Ref" : "NodeLaunchConfigBeta3" },
660+
"LaunchConfigurationName" : { "Ref" : "NodeLaunchConfig" },
651661
"LoadBalancerNames" : [ { "Ref" : "ExternalLoadBalancer" } ],
652662
"MinSize" : "0",
653663
"MaxSize" : "1000",
@@ -686,7 +696,7 @@
686696
}
687697
}
688698
},
689-
"NodeLaunchConfigBeta3": {
699+
"NodeLaunchConfig": {
690700
"DependsOn": "ManagerAsg",
691701
"Type": "AWS::AutoScaling::LaunchConfiguration",
692702
"Properties": {
@@ -753,11 +763,11 @@
753763
"-e REGION='",{ "Ref" : "AWS::Region" }, "' ",
754764
"-e UCP_ADMIN_USER='",{ "Ref" : "DDCUsernameSet" }, "' ",
755765
"-e UCP_ADMIN_PASSWORD='",{ "Ref" : "DDCPasswordSet" }, "' ",
756-
"-e ELB_NAME='SSHLoadBalancer' ",
757766
"-e INSTALL_DDC='yes' ",
758767
"-v /var/run/docker.sock:/var/run/docker.sock ",
759768
"-v /usr/bin/docker:/usr/bin/docker ",
760769
"docker4x/ddc-init-aws:$DOCKER_FOR_IAAS_VERSION\n"
770+
761771
]
762772
]
763773
}
@@ -813,20 +823,69 @@
813823
]
814824
}
815825
},
816-
"SSHLoadBalancerSG": {
826+
"UCPLoadBalancerSG": {
827+
"DependsOn": "Vpc",
828+
"Type": "AWS::EC2::SecurityGroup",
829+
"Properties": {
830+
"VpcId": {
831+
"Ref": "Vpc"
832+
},
833+
"GroupDescription": "UCP Load Balancer SecurityGroup",
834+
"SecurityGroupIngress": [
835+
{"IpProtocol": "tcp","FromPort": "443","ToPort": "443","CidrIp": "0.0.0.0/0"}
836+
]
837+
}
838+
},
839+
"UCPLoadBalancer" : {
840+
"DependsOn" : ["AttachGateway", "PubSubnetAz1", "PubSubnetAz2"],
841+
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
842+
"Properties" : {
843+
"ConnectionSettings" : {
844+
"IdleTimeout" : "1800"
845+
},
846+
"Subnets" : [
847+
{"Ref" : "PubSubnetAz1" },
848+
{"Ref" : "PubSubnetAz2" }
849+
],
850+
"LoadBalancerName" : { "Fn::Join": [ "-", [ { "Ref": "AWS::StackName"}, "ELB-UCP" ] ] },
851+
"CrossZone" : "true",
852+
"HealthCheck" : {
853+
"HealthyThreshold" : "2",
854+
"Interval" : "10",
855+
"Target" : "TCP:443",
856+
"Timeout" : "2",
857+
"UnhealthyThreshold" : "4"
858+
},
859+
"Listeners" : [
860+
{
861+
"LoadBalancerPort" : "443",
862+
"InstancePort" : "443",
863+
"Protocol" : "TCP"
864+
}
865+
],
866+
"SecurityGroups" : [ { "Ref" : "UCPLoadBalancerSG" } ],
867+
"Tags": [
868+
{
869+
"Key" : "Name",
870+
"Value" : { "Fn::Join": [ "-", [ { "Ref": "AWS::StackName"}, "ELB-UCP" ] ] }
871+
}
872+
]
873+
}
874+
},
875+
"DTRLoadBalancerSG": {
817876
"DependsOn": "Vpc",
818877
"Type": "AWS::EC2::SecurityGroup",
819878
"Properties": {
820879
"VpcId": {
821880
"Ref": "Vpc"
822881
},
823-
"GroupDescription": "SSH Load Balancer SecurityGroup",
882+
"GroupDescription": "DTR Load Balancer SecurityGroup",
824883
"SecurityGroupIngress": [
825-
{"IpProtocol": "-1","FromPort": "22","ToPort": "22","CidrIp": "0.0.0.0/0"}
884+
{"IpProtocol": "tcp","FromPort": "443","ToPort": "443","CidrIp": "0.0.0.0/0"}
826885
]
827886
}
828887
},
829-
"SSHLoadBalancer" : {
888+
"DTRLoadBalancer" : {
830889
"DependsOn" : ["AttachGateway", "PubSubnetAz1", "PubSubnetAz2"],
831890
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
832891
"Properties" : {
@@ -837,31 +896,35 @@
837896
{"Ref" : "PubSubnetAz1" },
838897
{"Ref" : "PubSubnetAz2" }
839898
],
840-
"LoadBalancerName" : { "Fn::Join": [ "-", [ { "Ref": "AWS::StackName"}, "ELB-SSH" ] ] },
899+
"LoadBalancerName" : { "Fn::Join": [ "-", [ { "Ref": "AWS::StackName"}, "ELB-DTR" ] ] },
841900
"CrossZone" : "true",
842901
"HealthCheck" : {
843902
"HealthyThreshold" : "2",
844903
"Interval" : "10",
845-
"Target" : "TCP:22",
904+
"Target": "HTTPS:8443/health",
846905
"Timeout" : "2",
847906
"UnhealthyThreshold" : "4"
848907
},
849908
"Listeners" : [
850909
{
851-
"LoadBalancerPort" : "22",
852-
"InstancePort" : "22",
910+
"LoadBalancerPort" : "443",
911+
"InstancePort" : "8443",
853912
"Protocol" : "TCP"
854913
}
855914
],
856-
"SecurityGroups" : [ { "Ref" : "SSHLoadBalancerSG" } ],
915+
"SecurityGroups" : [ { "Ref" : "DTRLoadBalancerSG" } ],
857916
"Tags": [
858917
{
859918
"Key" : "Name",
860-
"Value" : { "Fn::Join": [ "-", [ { "Ref": "AWS::StackName"}, "ELB-SSH" ] ] }
919+
"Value" : { "Fn::Join": [ "-", [ { "Ref": "AWS::StackName"}, "ELB-DTR" ] ] }
861920
}
862921
]
863922
}
864923
},
924+
"DDCBucket": {
925+
"Type": "AWS::S3::Bucket",
926+
"DeletionPolicy": "Retain"
927+
},
865928
"ProxyRole": {
866929
"Type": "AWS::IAM::Role",
867930
"Properties": {
@@ -892,13 +955,47 @@
892955
"cloudformation:DescribeStackResources"
893956
],
894957
"Resource": "*"
895-
}]
958+
}
959+
]
896960
},
897961
"Roles": [ {
898962
"Ref": "ProxyRole"
899963
} ]
900964
}
901965
},
966+
"S3Policies": {
967+
"DependsOn": "ProxyRole",
968+
"Type": "AWS::IAM::Policy",
969+
"Properties": {
970+
"PolicyName": "S3-DDC-Policy",
971+
"PolicyDocument": {
972+
"Version" : "2012-10-17",
973+
"Statement": [{
974+
"Effect": "Allow",
975+
"Action": [
976+
"s3:ListBucket",
977+
"s3:GetBucketLocation",
978+
"s3:ListBucketMultipartUploads"
979+
],
980+
"Resource": { "Fn::Join": ["", ["arn:aws:s3:::", { "Ref": "DDCBucket" }] ] }
981+
},
982+
{
983+
"Effect": "Allow",
984+
"Action": [
985+
"s3:PutObject",
986+
"s3:GetObject",
987+
"s3:DeleteObject",
988+
"s3:ListMultipartUploadParts",
989+
"s3:AbortMultipartUpload"
990+
],
991+
"Resource": { "Fn::Join": ["", ["arn:aws:s3:::", { "Ref": "DDCBucket" }, "/*"] ] }
992+
} ]
993+
},
994+
"Roles": [ {
995+
"Ref": "ProxyRole"
996+
} ]
997+
}
998+
},
902999
"DynDBPolicies": {
9031000
"DependsOn": ["SwarmDynDBTable", "ProxyRole"],
9041001
"Type": "AWS::IAM::Policy",
@@ -1029,22 +1126,22 @@
10291126
}
10301127
},
10311128
"Outputs": {
1032-
"DefaultDNSTarget" : {
1033-
"Description" : "Use this name to update your DNS records",
1129+
"UCPLoginURL" : {
1130+
"Description" : "Docker Datacenter Login URL",
10341131
"Value" : {
1035-
"Fn::GetAtt" : [ "ExternalLoadBalancer", "DNSName" ]
1132+
"Fn::Join": [ "", ["https://", {"Fn::GetAtt" : [ "UCPLoadBalancer", "DNSName"] } ] ]
10361133
}
10371134
},
1038-
"SSH" : {
1039-
"Description" : "Use this command to login to your Docker console.",
1135+
"DTRLoginURL" : {
1136+
"Description" : "Docker Datacenter Login URL",
10401137
"Value" : {
1041-
"Fn::Join": [ "", ["ssh docker@", {"Fn::GetAtt" : [ "SSHLoadBalancer", "DNSName"] } ] ]
1138+
"Fn::Join": [ "", ["https://", {"Fn::GetAtt" : [ "DTRLoadBalancer", "DNSName"] } ] ]
10421139
}
10431140
},
1044-
"DDCLoginURL" : {
1045-
"Description" : "Docker Datacenter Login URL",
1141+
"DefaultDNSTarget" : {
1142+
"Description" : "Default DNS name for applications deployed on the cluster",
10461143
"Value" : {
1047-
"Fn::Join": [ "", ["https://", {"Fn::GetAtt" : [ "SSHLoadBalancer", "DNSName"] } ] ]
1144+
"Fn::GetAtt" : [ "ExternalLoadBalancer", "DNSName" ]
10481145
}
10491146
},
10501147
"DDCUsername" : {

aws/dockerfiles/Dockerfile.ddc-init

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM alpine:3.3
22

33
MAINTAINER Ken Cochrane <[email protected]>
44

5-
RUN apk add --update bash ca-certificates jq groff less python py-pip py-setuptools \
5+
RUN apk add --update bash ca-certificates jq groff less python py-pip py-setuptools curl \
66
&& pip install awscli \
77
&& pip install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz \
88
&& apk --purge -v del py-pip \

0 commit comments

Comments
 (0)