Deploy based on ConfigMap instead of startup
Change-Id: Ia9e63f36c6eeb7c20928ca47389587c1b1930048
This commit is contained in:
parent
e65d3c5c70
commit
1d9a059c42
@ -32,26 +32,26 @@ from openstack_operator import utils
|
|||||||
OPERATOR_CONFIGMAP = "operator-config"
|
OPERATOR_CONFIGMAP = "operator-config"
|
||||||
|
|
||||||
|
|
||||||
def _create_namespace():
|
def operator_configmap(namespace, name, **_):
|
||||||
"""Create a namespace for the operator
|
"""Filter on the operator's ConfigMap."""
|
||||||
|
|
||||||
All resources which are managed by the operator would
|
return namespace == os.getenv('OPERATOR_NAMESPACE', 'default') \
|
||||||
be deployed on this namespace"""
|
and name == OPERATOR_CONFIGMAP
|
||||||
|
|
||||||
utils.create_or_update('operator/namespace.yml.j2')
|
|
||||||
|
|
||||||
|
|
||||||
@kopf.on.startup()
|
@kopf.on.resume('', 'v1', 'configmaps', when=operator_configmap)
|
||||||
async def startup_fn(logger, **kwargs):
|
@kopf.on.create('', 'v1', 'configmaps', when=operator_configmap)
|
||||||
"""Create several deployments at the startup of the operator
|
@kopf.on.update('', 'v1', 'configmaps', when=operator_configmap)
|
||||||
|
def deploy(name, namespace, new, **_):
|
||||||
|
"""Update the startup deployments when the operator configmap is changed
|
||||||
|
|
||||||
keystone, heat, and horizon
|
keystone, heat, and horizon
|
||||||
"""
|
"""
|
||||||
|
|
||||||
namespace = os.getenv('OPERATOR_NAMESPACE', 'default')
|
utils.create_or_update('operator/namespace.yml.j2')
|
||||||
config = utils.get_configmap(namespace, OPERATOR_CONFIGMAP)
|
|
||||||
config = utils.to_dict(config["operator-config.yaml"])
|
config = utils.to_dict(new['data']['operator-config.yaml'])
|
||||||
_create_namespace()
|
|
||||||
if "keystone" in config:
|
if "keystone" in config:
|
||||||
keystone.create_or_resume("keystone", config["keystone"])
|
keystone.create_or_resume("keystone", config["keystone"])
|
||||||
if "horizon" in config:
|
if "horizon" in config:
|
||||||
@ -61,16 +61,3 @@ async def startup_fn(logger, **kwargs):
|
|||||||
heat.create_or_resume("heat", config["heat"])
|
heat.create_or_resume("heat", config["heat"])
|
||||||
if "chronyd" in config:
|
if "chronyd" in config:
|
||||||
chronyd.create_or_resume(config["chronyd"])
|
chronyd.create_or_resume(config["chronyd"])
|
||||||
|
|
||||||
|
|
||||||
@kopf.on.update('', 'v1', 'configmaps')
|
|
||||||
def update(name, namespace, new, **_):
|
|
||||||
"""Update the startup deployments when the operator configmap is changed
|
|
||||||
|
|
||||||
keystone, heat, and horizon
|
|
||||||
"""
|
|
||||||
if namespace == os.getenv('OPERATOR_NAMESPACE') \
|
|
||||||
and name == OPERATOR_CONFIGMAP:
|
|
||||||
config = utils.to_dict(new["data"]["operator-config.yaml"])
|
|
||||||
if "horizon" in config:
|
|
||||||
horizon.update("horizon", config["horizon"])
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user