Add configs map for nodes
Now node definition can contain configs map, which will add new configs especially for this node or override current globals for the node. Change-Id: I4de6a0fad94d5f83ca486c952d80d1c87c880c0e Related-bug: #1653077
This commit is contained in:
parent
cbfd8bf89b
commit
341d3582e0
|
@ -323,6 +323,16 @@ def _create_globals_configmap(config):
|
|||
return kubernetes.process_object(cm)
|
||||
|
||||
|
||||
def _create_nodes_configmap(nodes):
|
||||
nodes_config = config._yaml.AttrDict()
|
||||
for node in sorted(nodes):
|
||||
if 'configs' in nodes[node]:
|
||||
nodes_config[node] = nodes[node]['configs']
|
||||
data = {templates.NODES_CONFIG: nodes_config._json(sort_keys=True)}
|
||||
cm = templates.serialize_configmap(templates.NODES_CONFIG, data)
|
||||
return kubernetes.process_object(cm)
|
||||
|
||||
|
||||
def get_start_script():
|
||||
start_scr_path = os.path.join(CONF.repositories.path,
|
||||
CONF.repositories.entrypoint_repo_name,
|
||||
|
@ -586,6 +596,7 @@ def deploy_components(components_map, components):
|
|||
|
||||
_create_namespace(CONF.configs)
|
||||
_create_globals_configmap(CONF.configs)
|
||||
_create_nodes_configmap(CONF.nodes)
|
||||
start_script_cm = create_start_script_configmap()
|
||||
|
||||
# load exported j2 templates, which can be used across all repositories
|
||||
|
|
|
@ -7,6 +7,7 @@ from fuel_ccp.config import images
|
|||
CONF = config.CONF
|
||||
|
||||
GLOBAL_CONFIG = "globals"
|
||||
NODES_CONFIG = "nodes-config"
|
||||
SCRIPT_CONFIG = "start-script"
|
||||
FILES_CONFIG = "files"
|
||||
META_CONFIG = "meta"
|
||||
|
@ -76,6 +77,10 @@ def serialize_volume_mounts(container, for_job=None):
|
|||
{
|
||||
"name": FILES_CONFIG,
|
||||
"mountPath": "/etc/ccp/%s" % FILES_CONFIG
|
||||
},
|
||||
{
|
||||
"name": NODES_CONFIG,
|
||||
"mountPath": "/etc/ccp/%s" % NODES_CONFIG
|
||||
}
|
||||
]
|
||||
for v in itertools.chain(container.get("volumes", ()),
|
||||
|
@ -276,10 +281,18 @@ def serialize_volumes(service, for_job=None):
|
|||
"name": EXPORTS_CONFIG,
|
||||
"items": exports_items
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": NODES_CONFIG,
|
||||
"configMap": {
|
||||
"name": NODES_CONFIG,
|
||||
"items": [{"key": NODES_CONFIG,
|
||||
"path": "nodes-config.json"}]
|
||||
}
|
||||
}
|
||||
]
|
||||
volume_names = [GLOBAL_CONFIG, META_CONFIG, ROLE_CONFIG, SCRIPT_CONFIG,
|
||||
FILES_CONFIG, EXPORTS_CONFIG]
|
||||
FILES_CONFIG, EXPORTS_CONFIG, NODES_CONFIG]
|
||||
for cont in itertools.chain(service["containers"], [for_job]):
|
||||
for v in cont.get("volumes", ()):
|
||||
if v["name"] in volume_names:
|
||||
|
|
|
@ -44,7 +44,8 @@ class TestDeploy(base.TestCase):
|
|||
{'mountPath': '/opt/ccp_start_script/bin',
|
||||
'name': 'start-script'},
|
||||
{'mountPath': '/etc/ccp/exports', 'name': 'exports'},
|
||||
{'mountPath': '/etc/ccp/files', 'name': 'files'}
|
||||
{'mountPath': '/etc/ccp/files', 'name': 'files'},
|
||||
{'mountPath': '/etc/ccp/nodes-config', 'name': 'nodes-config'}
|
||||
],
|
||||
"readinessProbe": {
|
||||
"exec": {
|
||||
|
|
Loading…
Reference in New Issue