Fix missing fields in chart generate

Signed-off-by: aiordache <anca.iordache@docker.com>
This commit is contained in:
aiordache 2020-04-01 09:40:37 +02:00
parent d1e40e9c36
commit 4ffc393909
1 changed files with 15 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import (
func MapToKubernetesObjects(model *compose.Project) (map[string]runtime.Object, error) {
objects := map[string]runtime.Object{}
for _, service := range model.Services {
objects[fmt.Sprintf("%s-service.yaml", service.Name)] = mapToService(model, service)
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{
TypeMeta: meta.TypeMeta{
Kind: "Service",
APIVersion: "v1",
},
ObjectMeta: meta.ObjectMeta{
Name: service.Name,
},
@ -92,13 +97,22 @@ func mapToDeployment(service types.ServiceConfig, model *compose.Project) (*apps
if err != nil {
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{
TypeMeta: meta.TypeMeta{
Kind: "Deployment",
APIVersion: "apps/v1",
},
ObjectMeta: meta.ObjectMeta{
Name: service.Name,
Labels: labels,
},
Spec: apps.DeploymentSpec{
Selector: selector,
Replicas: toReplicas(service.Deploy),
Strategy: toDeploymentStrategy(service.Deploy),
Template: podTemplate,