From d318db272a6bfe5765ce50021ed83dbdb67e8351 Mon Sep 17 00:00:00 2001 From: Andrey Pavlov Date: Fri, 9 Dec 2016 12:56:32 +0300 Subject: [PATCH] Adding antiAffinity field to DSL * global and local antiaffinity support added * dsl doc updated * dsl version bumped to 0.2.0 Change-Id: I832b00e75bc546f7de1446d660f178c58dc3b1b4 --- doc/source/dsl.rst | 5 +++++ fuel_ccp/__init__.py | 2 +- fuel_ccp/templates.py | 5 +++-- fuel_ccp/validation/service.py | 5 ++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/doc/source/dsl.rst b/doc/source/dsl.rst index 47d1f0be..3f0712e9 100644 --- a/doc/source/dsl.rst +++ b/doc/source/dsl.rst @@ -16,6 +16,7 @@ Application definition template - internal-port:external-port hostNetwork: true hostPID: true + antiAffinity: local containers: - name: container-name image: container-image @@ -102,6 +103,10 @@ service | | old Pods by new ones | | ["RollingUpdate",| | | | | | "Recreate"] | | +---------------+-----------------------------------------------+----------+------------------+---------------+ +| antiAffinity | Restrict scheduling of pods on the same host: | false | one of: | null | +| | local - within namespace | | [null, "global", | | +| | global - within k8s cluster | | "local"] | | ++---------------+-----------------------------------------------+----------+------------------+---------------+ .. _container: diff --git a/fuel_ccp/__init__.py b/fuel_ccp/__init__.py index 67d9b960..2e6f9873 100644 --- a/fuel_ccp/__init__.py +++ b/fuel_ccp/__init__.py @@ -17,4 +17,4 @@ import pbr.version version_info = pbr.version.VersionInfo("fuel_ccp") __version__ = version_info.version_string() -dsl_version = "0.1.0" +dsl_version = "0.2.0" diff --git a/fuel_ccp/templates.py b/fuel_ccp/templates.py index 8d5a25b4..a6322370 100644 --- a/fuel_ccp/templates.py +++ b/fuel_ccp/templates.py @@ -345,7 +345,7 @@ def serialize_affinity(service, topology): } } } - if service.get("hostNetwork"): + if service.get("hostNetwork") or service.get("antiAffinity") == 'global': policy["podAntiAffinity"] = { "requiredDuringSchedulingIgnoredDuringExecution": [{ "labelSelector": { @@ -357,7 +357,8 @@ def serialize_affinity(service, topology): "namespaces": [] }] } - elif service.get("kind") == "DaemonSet": + elif service.get("kind") == "DaemonSet" or service.get( + "antiAffinity") == 'local': policy["podAntiAffinity"] = { "requiredDuringSchedulingIgnoredDuringExecution": [{ "labelSelector": { diff --git a/fuel_ccp/validation/service.py b/fuel_ccp/validation/service.py index 2f087986..7900ec33 100644 --- a/fuel_ccp/validation/service.py +++ b/fuel_ccp/validation/service.py @@ -210,6 +210,9 @@ SERVICE_SCHEMA = { "strategy": { "enum": ["RollingUpdate", "Recreate"] }, + "antiAffinity": { + "enum": [None, "local", "global"] + }, "containers": { "type": "array", "minItems": 1, @@ -260,7 +263,7 @@ SERVICE_SCHEMA = { "valueFrom": {"type": "object"} } } - } + }, } } }