Add Kubernetes configuration provider which writes config to a secret
Fixes #145
This commit is contained in:
parent
88a04441de
commit
fd3a21fba9
10 changed files with 179 additions and 44 deletions
|
@ -4,14 +4,15 @@ from health.services import check_all_services
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def get_healthchecker(app):
|
||||
def get_healthchecker(app, config_provider):
|
||||
""" Returns a HealthCheck instance for the given app. """
|
||||
return HealthCheck.get_checker(app)
|
||||
return HealthCheck.get_checker(app, config_provider)
|
||||
|
||||
|
||||
class HealthCheck(object):
|
||||
def __init__(self, app):
|
||||
def __init__(self, app, config_provider):
|
||||
self.app = app
|
||||
self.config_provider = config_provider
|
||||
|
||||
def check_instance(self):
|
||||
"""
|
||||
|
@ -52,20 +53,21 @@ class HealthCheck(object):
|
|||
data = {
|
||||
'services': service_statuses,
|
||||
'notes': notes,
|
||||
'is_testing': self.app.config['TESTING']
|
||||
'is_testing': self.app.config['TESTING'],
|
||||
'config_provider': self.config_provider.provider_id
|
||||
}
|
||||
|
||||
return (data, 200 if is_healthy else 503)
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_checker(cls, app):
|
||||
def get_checker(cls, app, config_provider):
|
||||
name = app.config['HEALTH_CHECKER'][0]
|
||||
parameters = app.config['HEALTH_CHECKER'][1] or {}
|
||||
|
||||
for subc in cls.__subclasses__():
|
||||
if subc.check_name() == name:
|
||||
return subc(app, **parameters)
|
||||
return subc(app, config_provider, **parameters)
|
||||
|
||||
raise Exception('Unknown health check with name %s' % name)
|
||||
|
||||
|
@ -77,8 +79,8 @@ class LocalHealthCheck(HealthCheck):
|
|||
|
||||
|
||||
class ProductionHealthCheck(HealthCheck):
|
||||
def __init__(self, app, access_key, secret_key, db_instance='quay'):
|
||||
super(ProductionHealthCheck, self).__init__(app)
|
||||
def __init__(self, app, config_provider, access_key, secret_key, db_instance='quay'):
|
||||
super(ProductionHealthCheck, self).__init__(app, config_provider)
|
||||
self.access_key = access_key
|
||||
self.secret_key = secret_key
|
||||
self.db_instance = db_instance
|
||||
|
|
Reference in a new issue