mirror of
https://github.com/docker/compose.git
synced 2025-07-23 05:34:36 +02:00
Register services within Cloud Map
close #35 Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
0eab586106
commit
09871400ef
@ -6,13 +6,13 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/awslabs/goformation/v4/cloudformation/logs"
|
|
||||||
|
|
||||||
ecsapi "github.com/aws/aws-sdk-go/service/ecs"
|
ecsapi "github.com/aws/aws-sdk-go/service/ecs"
|
||||||
|
cloudmapapi "github.com/aws/aws-sdk-go/service/servicediscovery"
|
||||||
"github.com/awslabs/goformation/v4/cloudformation"
|
"github.com/awslabs/goformation/v4/cloudformation"
|
||||||
"github.com/awslabs/goformation/v4/cloudformation/ec2"
|
"github.com/awslabs/goformation/v4/cloudformation/ec2"
|
||||||
"github.com/awslabs/goformation/v4/cloudformation/ecs"
|
"github.com/awslabs/goformation/v4/cloudformation/ecs"
|
||||||
"github.com/awslabs/goformation/v4/cloudformation/iam"
|
"github.com/awslabs/goformation/v4/cloudformation/iam"
|
||||||
|
"github.com/awslabs/goformation/v4/cloudformation/logs"
|
||||||
cloudmap "github.com/awslabs/goformation/v4/cloudformation/servicediscovery"
|
cloudmap "github.com/awslabs/goformation/v4/cloudformation/servicediscovery"
|
||||||
"github.com/docker/ecs-plugin/pkg/compose"
|
"github.com/docker/ecs-plugin/pkg/compose"
|
||||||
)
|
)
|
||||||
@ -82,6 +82,28 @@ func (c client) Convert(ctx context.Context, project *compose.Project) (*cloudfo
|
|||||||
taskDefinition := fmt.Sprintf("%sTaskDefinition", service.Name)
|
taskDefinition := fmt.Sprintf("%sTaskDefinition", service.Name)
|
||||||
template.Resources[taskDefinition] = definition
|
template.Resources[taskDefinition] = definition
|
||||||
|
|
||||||
|
var healthCheck *cloudmap.Service_HealthCheckConfig
|
||||||
|
if service.HealthCheck != nil && !service.HealthCheck.Disable {
|
||||||
|
// FIXME ECS only support HTTP(s) health checks, while Docker only support CMD
|
||||||
|
}
|
||||||
|
|
||||||
|
serviceRegistration := fmt.Sprintf("%sServiceDiscoveryEntry", service.Name)
|
||||||
|
template.Resources[serviceRegistration] = &cloudmap.Service{
|
||||||
|
Description: fmt.Sprintf("%q service discovery entry in Cloud Map", service.Name),
|
||||||
|
HealthCheckConfig: healthCheck,
|
||||||
|
Name: service.Name,
|
||||||
|
NamespaceId: cloudformation.Ref("CloudMap"),
|
||||||
|
DnsConfig: &cloudmap.Service_DnsConfig{
|
||||||
|
DnsRecords: []cloudmap.Service_DnsRecord{
|
||||||
|
{
|
||||||
|
TTL: 300,
|
||||||
|
Type: cloudmapapi.RecordTypeA,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
RoutingPolicy: cloudmapapi.RoutingPolicyMultivalue,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
template.Resources[fmt.Sprintf("%sService", service.Name)] = &ecs.Service{
|
template.Resources[fmt.Sprintf("%sService", service.Name)] = &ecs.Service{
|
||||||
Cluster: c.Cluster,
|
Cluster: c.Cluster,
|
||||||
DesiredCount: 1,
|
DesiredCount: 1,
|
||||||
@ -95,20 +117,12 @@ func (c client) Convert(ctx context.Context, project *compose.Project) (*cloudfo
|
|||||||
},
|
},
|
||||||
SchedulingStrategy: ecsapi.SchedulingStrategyReplica,
|
SchedulingStrategy: ecsapi.SchedulingStrategyReplica,
|
||||||
ServiceName: service.Name,
|
ServiceName: service.Name,
|
||||||
TaskDefinition: cloudformation.Ref(taskDefinition),
|
ServiceRegistries: []ecs.Service_ServiceRegistry{
|
||||||
}
|
{
|
||||||
|
RegistryArn: cloudformation.GetAtt(serviceRegistration, "Arn"),
|
||||||
var healthCheck *cloudmap.Service_HealthCheckConfig
|
},
|
||||||
if service.HealthCheck != nil && !service.HealthCheck.Disable {
|
},
|
||||||
// FIXME ECS only support HTTP(s) health checks, while Docker only support CMD
|
TaskDefinition: cloudformation.Ref(taskDefinition),
|
||||||
}
|
|
||||||
|
|
||||||
serviceRegistration := fmt.Sprintf("%sServiceRegistration", service.Name)
|
|
||||||
template.Resources[serviceRegistration] = &cloudmap.Service{
|
|
||||||
Description: fmt.Sprintf("%q registration in Service Map", service.Name),
|
|
||||||
HealthCheckConfig: healthCheck,
|
|
||||||
Name: serviceRegistration,
|
|
||||||
NamespaceId: cloudformation.Ref("CloudMap"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return template, nil
|
return template, nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user