Add backup for mysqlCluster
Change-Id: Ia7b7fb413566632a6b443df2f136ec5017d3247f
This commit is contained in:
parent
6c1fcf1f9e
commit
7894eeb964
@ -29,3 +29,6 @@ configMap:
|
||||
mysql:
|
||||
size: 10Gi
|
||||
chronyd: {}
|
||||
backup:
|
||||
secretName: aws-backup
|
||||
url: s3://backups/
|
||||
|
@ -15,3 +15,6 @@ data:
|
||||
glance:
|
||||
dataDir: /opt/stack/data/glance
|
||||
chronyd: {}
|
||||
backup:
|
||||
secretName: aws-backup
|
||||
url: s3://backups/
|
@ -58,18 +58,23 @@ def deploy(name, namespace, new, **_):
|
||||
config = utils.to_dict(new['data']['operator-config.yaml'])
|
||||
|
||||
if "keystone" in config:
|
||||
keystone.create_or_resume("keystone", config["keystone"])
|
||||
spec = set_service_config(config, "keystone")
|
||||
keystone.create_or_resume("keystone", spec)
|
||||
if "horizon" in config:
|
||||
horizon.create_secret("horizon")
|
||||
horizon.create_or_resume("horizon", config["horizon"])
|
||||
spec = set_service_config(config, "horizon")
|
||||
horizon.create_or_resume("horizon", spec)
|
||||
if "heat" in config:
|
||||
heat.create_or_resume("heat", config["heat"])
|
||||
spec = set_service_config(config, "heat")
|
||||
heat.create_or_resume("heat", spec)
|
||||
if "glance" in config:
|
||||
glance.create_or_resume("glance", config["glance"])
|
||||
spec = set_service_config(config, "glance")
|
||||
glance.create_or_resume("glance", spec)
|
||||
if "magnum" in config:
|
||||
magnum.create_or_resume("magnum", config["magnum"])
|
||||
spec = set_service_config(config, "magnum")
|
||||
magnum.create_or_resume("magnum", spec)
|
||||
if "ceilometer" in config:
|
||||
ceilometer.create_or_resume(config["ceilometer"])
|
||||
spec = config["ceilometer"]
|
||||
ceilometer.create_or_resume(spec)
|
||||
|
||||
if "chronyd" in config:
|
||||
spec = config["chronyd"]
|
||||
@ -82,3 +87,23 @@ def deploy(name, namespace, new, **_):
|
||||
else:
|
||||
spec = {}
|
||||
libvirtd_exporter.create_or_resume(spec)
|
||||
|
||||
|
||||
def set_service_config(all_config, service_name):
|
||||
"""Retrieve the config for each openstack service
|
||||
|
||||
The config for each service is comprised of service-level
|
||||
config and operator-level config"""
|
||||
|
||||
# Set the service level config
|
||||
spec = all_config[service_name]
|
||||
|
||||
# Inject the operator level config to service level
|
||||
# Backup config for mysql
|
||||
all_config["backup"]["schedule"] = utils.get_backup_schedule(service_name)
|
||||
if "mysql" in spec:
|
||||
spec["mysql"].update(all_config["backup"])
|
||||
else:
|
||||
spec["mysql"] = all_config["backup"]
|
||||
|
||||
return spec
|
||||
|
@ -22,6 +22,10 @@ metadata:
|
||||
{{ labels(name) | indent(4) }}
|
||||
spec:
|
||||
replicas: 2
|
||||
backupSchedule: {{ spec.schedule }}
|
||||
backupScheduleJobsHistoryLimit: 6
|
||||
backupSecretName: {{ spec.secretName }}
|
||||
backupURL: {{ spec.url }}
|
||||
secretName: {{ name }}-mysql
|
||||
{% if "mysqlConf" in spec %}
|
||||
mysqlConf:
|
||||
|
@ -35,6 +35,19 @@ import openstack
|
||||
from openstack_operator import objects
|
||||
|
||||
|
||||
BACKUP_SCHEDULE = {
|
||||
'magnum': '0 0 * * * *',
|
||||
'barbican': '0 5 * * * *',
|
||||
'cinder': '0 10 * * * *',
|
||||
'glance': '0 15 * * * *',
|
||||
'heat': '0 20 * * * *',
|
||||
'neutron': '0 25 * * * *',
|
||||
'octavia': '0 30 * * * *',
|
||||
'nova': '0 35 * * * *',
|
||||
'keystone': '0 40 * * * *',
|
||||
'zuul': '0 58 * * * *'
|
||||
}
|
||||
|
||||
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
VERSION = version.VersionInfo('openstack_operator').version_string()
|
||||
@ -261,3 +274,14 @@ def get_configmap(namespace, name):
|
||||
return None
|
||||
|
||||
return config.obj["data"]
|
||||
|
||||
|
||||
def get_backup_schedule(name):
|
||||
"""Retrieve backup schedule for openstack services
|
||||
|
||||
This function retrieves a backup schedule for the specified openstack
|
||||
service and the schedule is a cronjob format"""
|
||||
|
||||
if name not in BACKUP_SCHEDULE:
|
||||
return "0 0 * * * *"
|
||||
return BACKUP_SCHEDULE[name]
|
||||
|
Loading…
Reference in New Issue
Block a user