Skip to content

Commit

Permalink
Merge pull request #37 from Mashape/fix/serf
Browse files Browse the repository at this point in the history
add SERF UDP port to security group
  • Loading branch information
shashiranjan84 authored Aug 14, 2017
2 parents 732d080 + 392df1d commit 7bbb9a3
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 64 deletions.
67 changes: 39 additions & 28 deletions templates/kong-elb-cassandra-new-vpc-optional-hvm.template
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@
}
}
},

"KongLoadBalancerExistingVPC": {
"Condition" : "ExistingVpcResources",
"Type": "AWS::ElasticLoadBalancing::LoadBalancer",
Expand Down Expand Up @@ -521,33 +520,33 @@
"cassandra_hosts=$(echo $cassandra_hosts | awk -F\"}\" '{print $1}')\n",
"IFS=', ' read -a host_array <<< \"$cassandra_hosts\"\n",
"for i in \"${host_array[@]}\"\n",
"do\n",
" hostName=$(echo $i | awk -F\":\" '{print $1}')\n",
" KONG_CASSANDRA_CONTACT_POINTS+=\"$hostName,\" \n",
"done;\n",
"KONG_CASSANDRA_CONTACT_POINTS=${KONG_CASSANDRA_CONTACT_POINTS:0:${#KONG_CASSANDRA_CONTACT_POINTS}-1}\n",
"echo \"$KONG_CASSANDRA_CONTACT_POINTS\"\n",
"export KONG_DATABASE=cassandra\n",
"export KONG_CASSANDRA_CONTACT_POINTS\n",
"export KONG_SERF_PATH=\/usr\/local\/bin\/serf\n",
"sleep `echo $(( RANDOM % ( 200 - 100 + 1 ) + 50))`\n",
"COUNTER=0\n",
"while [ $COUNTER -lt 4 ]; do\n",
" /usr/local/bin/kong health\n",
" if [[ $? -ne 0 ]]; then\n",
" echo \"trying to start kong..\"\n",
" su -s \/bin\/sh -c \"\/usr\/local\/bin\/kong start\" ec2-user\n",
" let COUNTER=COUNTER+1\n",
" sleep `echo $(( RANDOM % ( 120 - 30 + 1 ) + 30 ))`\n",
" else\n",
" /opt/aws/bin/cfn-signal -e 0 --stack ", { "Ref": "AWS::StackName" }, " --resource KongScalingGroup "," --region ", { "Ref" : "AWS::Region" }, " --reason \"Kong setup completed\" \n",
" break \n",
" fi\n",
"done\n",
"if ! /usr/local/bin/kong health; then\n",
" echo \"failed to start kong, exiting...\" \n",
" /opt/aws/bin/cfn-signal -e 1 --stack ", { "Ref": "AWS::StackName" }, " --resource KongScalingGroup "," --region ", { "Ref" : "AWS::Region" }, " --reason \"Failed to start Kong\" \n",
"fi\n"
"do\n",
" hostName=$(echo $i | awk -F\":\" '{print $1}')\n",
" KONG_CASSANDRA_CONTACT_POINTS+=\"$hostName,\" \n",
"done;\n",
"KONG_CASSANDRA_CONTACT_POINTS=${KONG_CASSANDRA_CONTACT_POINTS:0:${#KONG_CASSANDRA_CONTACT_POINTS}-1}\n",
"echo \"$KONG_CASSANDRA_CONTACT_POINTS\"\n",
"export KONG_DATABASE=cassandra\n",
"export KONG_CASSANDRA_CONTACT_POINTS\n",
"export KONG_SERF_PATH=\/usr\/local\/bin\/serf\n",
"sleep `echo $(( RANDOM % ( 200 - 100 + 1 ) + 50))`\n",
"COUNTER=0\n",
"while [ $COUNTER -lt 4 ]; do\n",
" /usr/local/bin/kong health\n",
" if [[ $? -ne 0 ]]; then\n",
" echo \"trying to start kong..\"\n",
" su -s \/bin\/sh -c \"\/usr\/local\/bin\/kong start\" ec2-user\n",
" let COUNTER=COUNTER+1\n",
" sleep `echo $(( RANDOM % ( 120 - 30 + 1 ) + 30 ))`\n",
" else\n",
" /opt/aws/bin/cfn-signal -e 0 --stack ", { "Ref": "AWS::StackName" }, " --resource KongScalingGroup "," --region ", { "Ref" : "AWS::Region" }, " --reason \"Kong setup completed\" \n",
" break \n",
" fi\n",
"done\n",
"if ! /usr/local/bin/kong health; then\n",
" echo \"failed to start kong, exiting...\" \n",
" /opt/aws/bin/cfn-signal -e 1 --stack ", { "Ref": "AWS::StackName" }, " --resource KongScalingGroup "," --region ", { "Ref" : "AWS::Region" }, " --reason \"Failed to start Kong\" \n",
"fi\n"
]
]
}
Expand All @@ -568,6 +567,18 @@
]
}
},
"IngressUDP7946": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId" : {
"Fn::GetAtt" : [ "KongSecurityGroup", "GroupId" ]
},
"IpProtocol": "udp", "FromPort": "7946", "ToPort": "7946",
"SourceSecurityGroupId": {
"Fn::GetAtt" : [ "KongSecurityGroup", "GroupId" ]
}
}
},
"Ingress7946": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
Expand Down
64 changes: 38 additions & 26 deletions templates/kong-elb-cassandra-new-vpc-optional-pv.template
Original file line number Diff line number Diff line change
Expand Up @@ -510,32 +510,32 @@
"cassandra_hosts=$(echo $cassandra_hosts | awk -F\"}\" '{print $1}')\n",
"IFS=', ' read -a host_array <<< \"$cassandra_hosts\"\n",
"for i in \"${host_array[@]}\"\n",
"do\n",
" hostName=$(echo $i | awk -F\":\" '{print $1}')\n",
" KONG_CASSANDRA_CONTACT_POINTS+=\"$hostName,\" \n",
"done;\n",
"KONG_CASSANDRA_CONTACT_POINTS=${KONG_CASSANDRA_CONTACT_POINTS:0:${#KONG_CASSANDRA_CONTACT_POINTS}-1}\n",
"export KONG_DATABASE=cassandra\n",
"export KONG_CASSANDRA_CONTACT_POINTS\n",
"export KONG_SERF_PATH=\/usr\/local\/bin\/serf\n",
"sleep `echo $(( RANDOM % ( 200 - 100 + 1 ) + 50 ))`\n",
"COUNTER=0\n",
"while [ $COUNTER -lt 4 ]; do\n",
" /usr/local/bin/kong health\n",
" if [[ $? -ne 0 ]]; then\n",
" echo \"trying to start kong..\"\n",
" su -s \/bin\/sh -c \"\/usr\/local\/bin\/kong start\" ec2-user\n",
" let COUNTER=COUNTER+1\n",
" sleep `echo $(( RANDOM % ( 120 - 30 + 1 ) + 30 ))`\n",
" else\n",
" /opt/aws/bin/cfn-signal -e 0 --stack ", { "Ref": "AWS::StackName" }, " --resource KongScalingGroup "," --region ", { "Ref" : "AWS::Region" }, " --reason \"Kong setup completed\" \n",
" break \n",
" fi\n",
"done\n",
"if ! /usr/local/bin/kong health; then\n",
" echo \"failed to start kong, exiting...\" \n",
" /opt/aws/bin/cfn-signal -e 1 --stack ", { "Ref": "AWS::StackName" }, " --resource KongScalingGroup "," --region ", { "Ref" : "AWS::Region" }, " --reason \"Failed to start Kong\" \n",
"fi\n"
"do\n",
" hostName=$(echo $i | awk -F\":\" '{print $1}')\n",
" KONG_CASSANDRA_CONTACT_POINTS+=\"$hostName,\" \n",
"done;\n",
"KONG_CASSANDRA_CONTACT_POINTS=${KONG_CASSANDRA_CONTACT_POINTS:0:${#KONG_CASSANDRA_CONTACT_POINTS}-1}\n",
"export KONG_DATABASE=cassandra\n",
"export KONG_CASSANDRA_CONTACT_POINTS\n",
"export KONG_SERF_PATH=\/usr\/local\/bin\/serf\n",
"sleep `echo $(( RANDOM % ( 200 - 100 + 1 ) + 50 ))`\n",
"COUNTER=0\n",
"while [ $COUNTER -lt 4 ]; do\n",
" /usr/local/bin/kong health\n",
" if [[ $? -ne 0 ]]; then\n",
" echo \"trying to start kong..\"\n",
" su -s \/bin\/sh -c \"\/usr\/local\/bin\/kong start\" ec2-user\n",
" let COUNTER=COUNTER+1\n",
" sleep `echo $(( RANDOM % ( 120 - 30 + 1 ) + 30 ))`\n",
" else\n",
" /opt/aws/bin/cfn-signal -e 0 --stack ", { "Ref": "AWS::StackName" }, " --resource KongScalingGroup "," --region ", { "Ref" : "AWS::Region" }, " --reason \"Kong setup completed\" \n",
" break \n",
" fi\n",
"done\n",
"if ! /usr/local/bin/kong health; then\n",
" echo \"failed to start kong, exiting...\" \n",
" /opt/aws/bin/cfn-signal -e 1 --stack ", { "Ref": "AWS::StackName" }, " --resource KongScalingGroup "," --region ", { "Ref" : "AWS::Region" }, " --reason \"Failed to start Kong\" \n",
"fi\n"
]
]
}
Expand All @@ -556,6 +556,18 @@
]
}
},
"IngressUDP7946": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId" : {
"Fn::GetAtt" : [ "KongSecurityGroup", "GroupId" ]
},
"IpProtocol": "udp", "FromPort": "7946", "ToPort": "7946",
"SourceSecurityGroupId": {
"Fn::GetAtt" : [ "KongSecurityGroup", "GroupId" ]
}
}
},
"Ingress7946": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
Expand Down
12 changes: 12 additions & 0 deletions templates/kong-elb-cassandra-user-vpc-optional-hvm.template
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,18 @@
]
}
},
"IngressUDP7946": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId" : {
"Fn::GetAtt" : [ "KongSecurityGroup", "GroupId" ]
},
"IpProtocol": "udp", "FromPort": "7946", "ToPort": "7946",
"SourceSecurityGroupId": {
"Fn::GetAtt" : [ "KongSecurityGroup", "GroupId" ]
}
}
},
"Ingress7946": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
Expand Down
29 changes: 20 additions & 9 deletions templates/kong-elb-cassandra-user-vpc-optional-pv.template
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@
]
}
},

"KongScalingGroup": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"CreationPolicy": {
Expand Down Expand Up @@ -411,14 +410,14 @@
"yum install -y kong.rpm --nogpgcheck\n",
"CASSANDRA_HOSTS=(\"", { "Fn::Join": [ "\" \"", { "Ref": "CassandraSeedNodes" } ] }, "\")\n",
"for i in \"${CASSANDRA_HOSTS[@]}\"\n",
"do\n",
" KONG_CASSANDRA_CONTACT_POINTS+=\"$i,\" \n",
"done;\n",
"KONG_CASSANDRA_CONTACT_POINTS=${KONG_CASSANDRA_CONTACT_POINTS:0:${#KONG_CASSANDRA_CONTACT_POINTS}-1}\n",
"export KONG_DATABASE=cassandra\n",
"export KONG_CASSANDRA_CONTACT_POINTS\n",
"export KONG_CASSANDRA_PORT=", {"Ref": "CassandraPort"}, "\n",
"export KONG_SERF_PATH=\/usr\/local\/bin\/serf\n",
"do\n",
" KONG_CASSANDRA_CONTACT_POINTS+=\"$i,\" \n",
"done;\n",
"KONG_CASSANDRA_CONTACT_POINTS=${KONG_CASSANDRA_CONTACT_POINTS:0:${#KONG_CASSANDRA_CONTACT_POINTS}-1}\n",
"export KONG_DATABASE=cassandra\n",
"export KONG_CASSANDRA_CONTACT_POINTS\n",
"export KONG_CASSANDRA_PORT=", {"Ref": "CassandraPort"}, "\n",
"export KONG_SERF_PATH=\/usr\/local\/bin\/serf\n",
"sleep `echo $(( RANDOM % ( 200 - 100 + 1 ) + 50 ))`\n",
"COUNTER=0\n",
"while [ $COUNTER -lt 4 ]; do\n",
Expand Down Expand Up @@ -457,6 +456,18 @@
]
}
},
"IngressUDP7946": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId" : {
"Fn::GetAtt" : [ "KongSecurityGroup", "GroupId" ]
},
"IpProtocol": "udp", "FromPort": "7946", "ToPort": "7946",
"SourceSecurityGroupId": {
"Fn::GetAtt" : [ "KongSecurityGroup", "GroupId" ]
}
}
},
"Ingress7946": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
Expand Down
14 changes: 13 additions & 1 deletion templates/kong-elb-postgres-optional-vpc-new-hvm.template
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@
"fi\n",
"yum install -y epel-release\n",
"yum install -y kong.rpm --nogpgcheck\n",
"export KONG_DATABASE=postgres\n",
"export KONG_DATABASE=postgres\n",
"export KONG_PG_HOST=", { "Fn::If" : [ "CreateRDS", { "Fn::GetAtt" : [ "PostgresDB", "Endpoint.Address" ] }, {"Ref" : "DBHost"}] }, "\n",
"export KONG_PG_PORT=", { "Fn::If" : [ "CreateRDS", { "Fn::GetAtt" : [ "PostgresDB", "Endpoint.Port" ] }, {"Ref" : "DBPort"}] }, "\n",
"export KONG_PG_USER=", { "Ref" : "DBUsername" }, "\n",
Expand Down Expand Up @@ -501,6 +501,18 @@
}
}
},
"IngressUDP7946": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId" : {
"Fn::GetAtt" : [ "KongSecurityGroup", "GroupId" ]
},
"IpProtocol": "udp", "FromPort": "7946", "ToPort": "7946",
"SourceSecurityGroupId": {
"Fn::GetAtt" : [ "KongSecurityGroup", "GroupId" ]
}
}
},
"DBSubnetGroup" : {
"Type" : "AWS::RDS::DBSubnetGroup",
"Condition" : "CreateRDS",
Expand Down
12 changes: 12 additions & 0 deletions templates/kong-elb-postgres-optional-vpc-optional-hvm.template
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,18 @@
}
}
},
"IngressUDP7946": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId" : {
"Fn::GetAtt" : [ "KongSecurityGroup", "GroupId" ]
},
"IpProtocol": "udp", "FromPort": "7946", "ToPort": "7946",
"SourceSecurityGroupId": {
"Fn::GetAtt" : [ "KongSecurityGroup", "GroupId" ]
}
}
},
"DBSubnetGroup" : {
"Type" : "AWS::RDS::DBSubnetGroup",
"Condition" : "CreateRDS",
Expand Down
12 changes: 12 additions & 0 deletions templates/kong-elb-postgres-optional-vpc-optional-pv.template
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,18 @@
}
}
},
"IngressUDP7946": {
"Type": "AWS::EC2::SecurityGroupIngress",
"Properties": {
"GroupId" : {
"Fn::GetAtt" : [ "KongSecurityGroup", "GroupId" ]
},
"IpProtocol": "udp", "FromPort": "7946", "ToPort": "7946",
"SourceSecurityGroupId": {
"Fn::GetAtt" : [ "KongSecurityGroup", "GroupId" ]
}
}
},
"DBSubnetGroup" : {
"Type" : "AWS::RDS::DBSubnetGroup",
"Condition" : "CreateRDS",
Expand Down

0 comments on commit 7bbb9a3

Please sign in to comment.