Added feature for placement key in v3
it will map `engine.labels.operatingsystem` to `beta.kubernetes.io/os` and `node.hostname` to `kubernetes.io/hostname` and all other constraints will not be supported.
This commit is contained in:
@@ -103,6 +103,7 @@ type ServiceConfig struct {
|
||||
GroupAdd []int64 `compose:"group_add"`
|
||||
Volumes []Volumes `compose:""`
|
||||
HealthChecks HealthCheck `compose:""`
|
||||
Placement map[string]string `compose:""`
|
||||
}
|
||||
|
||||
// HealthCheck the healthcheck configuration for a service
|
||||
|
||||
@@ -294,6 +294,20 @@ func dockerComposeToKomposeMapping(composeObject *types.Config) (kobject.Kompose
|
||||
serviceConfig.Replicas = int(*composeServiceConfig.Deploy.Replicas)
|
||||
}
|
||||
|
||||
// placement:
|
||||
placement := make(map[string]string)
|
||||
for _, j := range composeServiceConfig.Deploy.Placement.Constraints {
|
||||
p := strings.Split(j, " == ")
|
||||
if p[0] == "node.hostname" {
|
||||
placement["kubernetes.io/hostname"] = p[1]
|
||||
} else if p[0] == "engine.labels.operatingsystem" {
|
||||
placement["beta.kubernetes.io/os"] = p[1]
|
||||
} else {
|
||||
log.Warn(p[0], " constraints in placement is not supported, only 'node.hostname' and 'engine.labels.operatingsystem' is only supported as a constraint ")
|
||||
}
|
||||
}
|
||||
serviceConfig.Placement = placement
|
||||
|
||||
// TODO: Build is not yet supported, see:
|
||||
// https://github.com/docker/cli/blob/master/cli/compose/types/types.go#L9
|
||||
// We will have to *manually* add this / parse.
|
||||
|
||||
@@ -380,7 +380,7 @@ func (k *Kubernetes) UpdateKubernetesObjects(name string, service kobject.Servic
|
||||
template.Spec.Containers[0].Stdin = service.Stdin
|
||||
template.Spec.Containers[0].TTY = service.Tty
|
||||
template.Spec.Volumes = volumes
|
||||
|
||||
template.Spec.NodeSelector = service.Placement
|
||||
// Configure the HealthCheck
|
||||
// We check to see if it's blank
|
||||
if !reflect.DeepEqual(service.HealthChecks, kobject.HealthCheck{}) {
|
||||
|
||||
Reference in New Issue
Block a user