Adding "strategy" field to service definition
RollingUpdate cannot be used for some services upgrade, so Recreate type was added. Change-Id: I39f1d801efeda9c073c895f8281a6ecc768f7bf7
This commit is contained in:
parent
06a012c593
commit
8aa4dec122
|
@ -78,26 +78,30 @@ Parameters description
|
||||||
service
|
service
|
||||||
-------
|
-------
|
||||||
|
|
||||||
+---------------+-----------------------------------------------+----------+------------------+------------+
|
+---------------+-----------------------------------------------+----------+------------------+---------------+
|
||||||
| Name | Description | Required | Schema | Default |
|
| Name | Description | Required | Schema | Default |
|
||||||
+===============+===============================================+==========+==================+============+
|
+===============+===============================================+==========+==================+===============+
|
||||||
| name | Name of the service. | true | string | |
|
| name | Name of the service. | true | string | |
|
||||||
+---------------+-----------------------------------------------+----------+------------------+------------+
|
+---------------+-----------------------------------------------+----------+------------------+---------------+
|
||||||
| kind | Kind of k8s object to use for containers | false | one of: | Deployment |
|
| kind | Kind of k8s object to use for containers | false | one of: | Deployment |
|
||||||
| | deployment | | ["Deployment", | |
|
| | deployment | | ["Deployment", | |
|
||||||
| | | | "DaemonSet"] | |
|
| | | | "DaemonSet"] | |
|
||||||
+---------------+-----------------------------------------------+----------+------------------+------------+
|
+---------------+-----------------------------------------------+----------+------------------+---------------+
|
||||||
| containers | List of containers under multi-container pod | true | container_ array | |
|
| containers | List of containers under multi-container pod | true | container_ array | |
|
||||||
+---------------+-----------------------------------------------+----------+------------------+------------+
|
+---------------+-----------------------------------------------+----------+------------------+---------------+
|
||||||
| ports | k8s Service will be created if specified | false | internal-port: | |
|
| ports | k8s Service will be created if specified | false | internal-port: | |
|
||||||
| | (with NodePort type for now) | | external-port | |
|
| | (with NodePort type for now) | | external-port | |
|
||||||
| | Only internal or both internal:external ports | | array | |
|
| | Only internal or both internal:external ports | | array | |
|
||||||
| | can be specified | | | |
|
| | can be specified | | | |
|
||||||
+---------------+-----------------------------------------------+----------+------------------+------------+
|
+---------------+-----------------------------------------------+----------+------------------+---------------+
|
||||||
| hostNetwork | Use the host’s network namespace | false | boolean | false |
|
| hostNetwork | Use the host’s network namespace | false | boolean | false |
|
||||||
+---------------+-----------------------------------------------+----------+------------------+------------+
|
+---------------+-----------------------------------------------+----------+------------------+---------------+
|
||||||
| hostPID | Use the host’s pid namespace | false | boolean | false |
|
| hostPID | Use the host’s pid namespace | false | boolean | false |
|
||||||
+---------------+-----------------------------------------------+----------+------------------+------------+
|
+---------------+-----------------------------------------------+----------+------------------+---------------+
|
||||||
|
| strategy | The strategy that should be used to replace | false | one of: | RollingUpdate |
|
||||||
|
| | old Pods by new ones | | ["RollingUpdate",| |
|
||||||
|
| | | | "Recreate"] | |
|
||||||
|
+---------------+-----------------------------------------------+----------+------------------+---------------+
|
||||||
|
|
||||||
.. _container:
|
.. _container:
|
||||||
|
|
||||||
|
|
|
@ -112,8 +112,9 @@ def parse_role(component, topology, configmaps):
|
||||||
else:
|
else:
|
||||||
replicas = replicas or 1
|
replicas = replicas or 1
|
||||||
|
|
||||||
obj = templates.serialize_deployment(service_name, cont_spec,
|
strategy = service.get('strategy', 'RollingUpdate')
|
||||||
affinity, replicas, component_name)
|
obj = templates.serialize_deployment(service_name, cont_spec, affinity,
|
||||||
|
replicas, component_name, strategy)
|
||||||
kubernetes.process_object(obj)
|
kubernetes.process_object(obj)
|
||||||
|
|
||||||
_process_ports(service)
|
_process_ports(service)
|
||||||
|
|
|
@ -288,8 +288,9 @@ def serialize_job(name, spec, component_name, app_name):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def serialize_deployment(name, spec, affinity, replicas, component_name):
|
def serialize_deployment(name, spec, affinity, replicas, component_name,
|
||||||
return {
|
strategy):
|
||||||
|
deployment = {
|
||||||
"apiVersion": "extensions/v1beta1",
|
"apiVersion": "extensions/v1beta1",
|
||||||
"kind": "Deployment",
|
"kind": "Deployment",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
@ -298,10 +299,7 @@ def serialize_deployment(name, spec, affinity, replicas, component_name):
|
||||||
"spec": {
|
"spec": {
|
||||||
"replicas": replicas,
|
"replicas": replicas,
|
||||||
"strategy": {
|
"strategy": {
|
||||||
"rollingUpdate": {
|
"type": strategy
|
||||||
"maxSurge": 1,
|
|
||||||
"maxUnavailable": 0
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"template": {
|
"template": {
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
@ -317,6 +315,15 @@ def serialize_deployment(name, spec, affinity, replicas, component_name):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strategy == 'RollingUpdate':
|
||||||
|
deployment['spec']['strategy'].update({
|
||||||
|
"rollingUpdate": {
|
||||||
|
"maxSurge": 1,
|
||||||
|
"maxUnavailable": 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return deployment
|
||||||
|
|
||||||
|
|
||||||
def serialize_affinity(service, topology):
|
def serialize_affinity(service, topology):
|
||||||
policy = {
|
policy = {
|
||||||
|
|
|
@ -191,6 +191,9 @@ SERVICE_SCHEMA = {
|
||||||
"hostPID": {
|
"hostPID": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"strategy": {
|
||||||
|
"enum": ["RollingUpdate", "Recreate"]
|
||||||
|
},
|
||||||
"containers": {
|
"containers": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"minItems": 1,
|
"minItems": 1,
|
||||||
|
|
Loading…
Reference in New Issue