mirror of
https://github.com/docker/compose.git
synced 2025-07-20 20:24:30 +02:00
Register services with a known port with SRV record
see https://github.com/docker/docker_aws/issues/15#issuecomment-634357859 Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
3283bceac6
commit
a798c95963
@ -131,18 +131,31 @@ func (c client) Convert(project *compose.Project) (*cloudformation.Template, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
serviceRegistration := fmt.Sprintf("%sServiceDiscoveryEntry", service.Name)
|
serviceRegistration := fmt.Sprintf("%sServiceDiscoveryEntry", service.Name)
|
||||||
|
records := []cloudmap.Service_DnsRecord{
|
||||||
|
{
|
||||||
|
TTL: 60,
|
||||||
|
Type: cloudmapapi.RecordTypeA,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
serviceRegistry := ecs.Service_ServiceRegistry{
|
||||||
|
RegistryArn: cloudformation.GetAtt(serviceRegistration, "Arn"),
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(service.Ports) > 0 {
|
||||||
|
records = append(records, cloudmap.Service_DnsRecord{
|
||||||
|
TTL: 60,
|
||||||
|
Type: cloudmapapi.RecordTypeSrv,
|
||||||
|
})
|
||||||
|
serviceRegistry.Port = int(service.Ports[0].Target)
|
||||||
|
}
|
||||||
|
|
||||||
template.Resources[serviceRegistration] = &cloudmap.Service{
|
template.Resources[serviceRegistration] = &cloudmap.Service{
|
||||||
Description: fmt.Sprintf("%q service discovery entry in Cloud Map", service.Name),
|
Description: fmt.Sprintf("%q service discovery entry in Cloud Map", service.Name),
|
||||||
HealthCheckConfig: healthCheck,
|
HealthCheckConfig: healthCheck,
|
||||||
Name: service.Name,
|
Name: service.Name,
|
||||||
NamespaceId: cloudformation.Ref("CloudMap"),
|
NamespaceId: cloudformation.Ref("CloudMap"),
|
||||||
DnsConfig: &cloudmap.Service_DnsConfig{
|
DnsConfig: &cloudmap.Service_DnsConfig{
|
||||||
DnsRecords: []cloudmap.Service_DnsRecord{
|
DnsRecords: records,
|
||||||
{
|
|
||||||
TTL: 300,
|
|
||||||
Type: cloudmapapi.RecordTypeA,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
RoutingPolicy: cloudmapapi.RoutingPolicyMultivalue,
|
RoutingPolicy: cloudmapapi.RoutingPolicyMultivalue,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -169,12 +182,8 @@ func (c client) Convert(project *compose.Project) (*cloudformation.Template, err
|
|||||||
},
|
},
|
||||||
SchedulingStrategy: ecsapi.SchedulingStrategyReplica,
|
SchedulingStrategy: ecsapi.SchedulingStrategyReplica,
|
||||||
ServiceName: service.Name,
|
ServiceName: service.Name,
|
||||||
ServiceRegistries: []ecs.Service_ServiceRegistry{
|
ServiceRegistries: []ecs.Service_ServiceRegistry{serviceRegistry},
|
||||||
{
|
TaskDefinition: cloudformation.Ref(taskDefinition),
|
||||||
RegistryArn: cloudformation.GetAtt(serviceRegistration, "Arn"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
TaskDefinition: cloudformation.Ref(taskDefinition),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return template, nil
|
return template, nil
|
||||||
|
@ -135,7 +135,7 @@
|
|||||||
"DnsConfig": {
|
"DnsConfig": {
|
||||||
"DnsRecords": [
|
"DnsRecords": [
|
||||||
{
|
{
|
||||||
"TTL": 300,
|
"TTL": 60,
|
||||||
"Type": "A"
|
"Type": "A"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -135,7 +135,7 @@
|
|||||||
"DnsConfig": {
|
"DnsConfig": {
|
||||||
"DnsRecords": [
|
"DnsRecords": [
|
||||||
{
|
{
|
||||||
"TTL": 300,
|
"TTL": 60,
|
||||||
"Type": "A"
|
"Type": "A"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user