mirror of https://github.com/docker/compose.git
Fix missing fields in chart generate
Signed-off-by: aiordache <anca.iordache@docker.com>
This commit is contained in:
parent
d1e40e9c36
commit
4ffc393909
|
@ -16,6 +16,7 @@ import (
|
||||||
|
|
||||||
func MapToKubernetesObjects(model *compose.Project) (map[string]runtime.Object, error) {
|
func MapToKubernetesObjects(model *compose.Project) (map[string]runtime.Object, error) {
|
||||||
objects := map[string]runtime.Object{}
|
objects := map[string]runtime.Object{}
|
||||||
|
|
||||||
for _, service := range model.Services {
|
for _, service := range model.Services {
|
||||||
objects[fmt.Sprintf("%s-service.yaml", service.Name)] = mapToService(model, service)
|
objects[fmt.Sprintf("%s-service.yaml", service.Name)] = mapToService(model, service)
|
||||||
if service.Deploy != nil && service.Deploy.Mode == "global" {
|
if service.Deploy != nil && service.Deploy.Mode == "global" {
|
||||||
|
@ -53,6 +54,10 @@ func mapToService(model *compose.Project, service types.ServiceConfig) *core.Ser
|
||||||
}
|
}
|
||||||
|
|
||||||
return &core.Service{
|
return &core.Service{
|
||||||
|
TypeMeta: meta.TypeMeta{
|
||||||
|
Kind: "Service",
|
||||||
|
APIVersion: "v1",
|
||||||
|
},
|
||||||
ObjectMeta: meta.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Name: service.Name,
|
Name: service.Name,
|
||||||
},
|
},
|
||||||
|
@ -92,13 +97,22 @@ func mapToDeployment(service types.ServiceConfig, model *compose.Project) (*apps
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
selector := new(meta.LabelSelector)
|
||||||
|
selector.MatchLabels = make(map[string]string)
|
||||||
|
for key, val := range labels {
|
||||||
|
selector.MatchLabels[key] = val
|
||||||
|
}
|
||||||
return &apps.Deployment{
|
return &apps.Deployment{
|
||||||
|
TypeMeta: meta.TypeMeta{
|
||||||
|
Kind: "Deployment",
|
||||||
|
APIVersion: "apps/v1",
|
||||||
|
},
|
||||||
ObjectMeta: meta.ObjectMeta{
|
ObjectMeta: meta.ObjectMeta{
|
||||||
Name: service.Name,
|
Name: service.Name,
|
||||||
Labels: labels,
|
Labels: labels,
|
||||||
},
|
},
|
||||||
Spec: apps.DeploymentSpec{
|
Spec: apps.DeploymentSpec{
|
||||||
|
Selector: selector,
|
||||||
Replicas: toReplicas(service.Deploy),
|
Replicas: toReplicas(service.Deploy),
|
||||||
Strategy: toDeploymentStrategy(service.Deploy),
|
Strategy: toDeploymentStrategy(service.Deploy),
|
||||||
Template: podTemplate,
|
Template: podTemplate,
|
||||||
|
|
Loading…
Reference in New Issue