Adding antiAffinity field to DSL

* global and local antiaffinity support added
* dsl doc updated
* dsl version bumped to 0.2.0

Change-Id: I832b00e75bc546f7de1446d660f178c58dc3b1b4
This commit is contained in:
Andrey Pavlov 2016-12-09 12:56:32 +03:00
parent 631bf4dc62
commit d318db272a
4 changed files with 13 additions and 4 deletions

View File

@ -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:

View File

@ -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"

View File

@ -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": {

View File

@ -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"}
}
}
}
},
}
}
}