diff --git a/fuel_ccp/deploy.py b/fuel_ccp/deploy.py index b4b6e773..1040eba1 100644 --- a/fuel_ccp/deploy.py +++ b/fuel_ccp/deploy.py @@ -101,6 +101,7 @@ def parse_role(component, topology, configmaps): affinity = templates.serialize_affinity(service, topology) replicas = CONF.replicas.get(service_name) + strategy = {'type': service.get('strategy', 'RollingUpdate')} if service.get("kind") == 'DaemonSet': LOG.warning("Deployment is being used instead of DaemonSet to support " "updates") @@ -112,10 +113,11 @@ def parse_role(component, topology, configmaps): raise RuntimeError("Replicas couldn't be specified for services " "implemented using Kubernetes DaemonSet") replicas = len(set(topology[service_name])) + if strategy['type'] == 'RollingUpdate': + strategy['rollingUpdate'] = {'maxSurge': 0, 'maxUnavailable': 1} else: replicas = replicas or 1 - strategy = service.get('strategy', 'RollingUpdate') obj = templates.serialize_deployment(service_name, cont_spec, affinity, replicas, component_name, strategy) yield [obj] diff --git a/fuel_ccp/templates.py b/fuel_ccp/templates.py index d6b30442..24052e55 100644 --- a/fuel_ccp/templates.py +++ b/fuel_ccp/templates.py @@ -290,6 +290,12 @@ def serialize_job(name, spec, component_name, app_name): def serialize_deployment(name, spec, affinity, replicas, component_name, strategy): + if strategy['type'] == 'RollingUpdate': + strategy.setdefault("rollingUpdate", { + "maxSurge": 1, + "maxUnavailable": 0 + }) + deployment = { "apiVersion": "extensions/v1beta1", "kind": "Deployment", @@ -298,9 +304,7 @@ def serialize_deployment(name, spec, affinity, replicas, component_name, }, "spec": { "replicas": replicas, - "strategy": { - "type": strategy - }, + "strategy": strategy, "template": { "metadata": { "annotations": affinity, @@ -315,13 +319,6 @@ def serialize_deployment(name, spec, affinity, replicas, component_name, } } - if strategy == 'RollingUpdate': - deployment['spec']['strategy'].update({ - "rollingUpdate": { - "maxSurge": 1, - "maxUnavailable": 0 - } - }) return deployment