forked from LaconicNetwork/kompose
Add deploy: mode: global support
Adds support for deploy: mode.
For example:
```yaml
version: "3"
services:
foo:
deploy:
resources:
mode: global
replicas: 6
image: redis
```
Will only generate replicas: 1 in Kubernetes pods as "global" limits
replicas to only one.
This commit is contained in:
@@ -490,12 +490,19 @@ func (k *Kubernetes) ConfigEnvs(name string, service kobject.ServiceConfig) []ap
|
||||
func (k *Kubernetes) CreateKubernetesObjects(name string, service kobject.ServiceConfig, opt kobject.ConvertOptions) []runtime.Object {
|
||||
var objects []runtime.Object
|
||||
var replica int
|
||||
|
||||
if opt.IsReplicaSetFlag || service.Replicas == 0 {
|
||||
replica = opt.Replicas
|
||||
} else {
|
||||
replica = service.Replicas
|
||||
}
|
||||
|
||||
// Check to see if Docker Compose v3 Deploy.Mode has been set to "global"
|
||||
if service.DeployMode == "global" {
|
||||
log.Warning("Global mode not yet supported, containers will only be replicated once throughout the cluster. DaemonSet support will be added in the future.")
|
||||
replica = 1
|
||||
}
|
||||
|
||||
if opt.CreateD {
|
||||
objects = append(objects, k.InitD(name, service, replica))
|
||||
}
|
||||
|
||||
@@ -272,6 +272,7 @@ func (o *OpenShift) Transform(komposeObject kobject.KomposeObject, opt kobject.C
|
||||
for _, name := range sortedKeys {
|
||||
service := komposeObject.ServiceConfigs[name]
|
||||
var objects []runtime.Object
|
||||
|
||||
//replicas
|
||||
var replica int
|
||||
if opt.IsReplicaSetFlag || service.Replicas == 0 {
|
||||
@@ -279,6 +280,12 @@ func (o *OpenShift) Transform(komposeObject kobject.KomposeObject, opt kobject.C
|
||||
} else {
|
||||
replica = service.Replicas
|
||||
}
|
||||
|
||||
// If Deploy.Mode = Global has been set, make replica = 1 when generating DeploymentConfig
|
||||
if service.DeployMode == "global" {
|
||||
replica = 1
|
||||
}
|
||||
|
||||
// Must build the images before conversion (got to add service.Image in case 'image' key isn't provided
|
||||
// Check to see if there is an InputFile (required!) before we build the container
|
||||
// Check that there's actually a Build key
|
||||
|
||||
Reference in New Issue
Block a user