def start_runner_process(): ''' Start anarchy-runner process for running in all-in-one pod. ''' operator_logger.info('Starting all-in-one runner') default_runner = AnarchyRunner.get('default') if not default_runner: default_runner = AnarchyRunner.register(AnarchyRunner.default_runner_definition(runtime)) env = os.environ.copy() env['ANARCHY_COMPONENT'] = 'runner' env['ANARCHY_URL'] = 'http://{}:5000'.format(runtime.anarchy_service_name) env['RUNNER_NAME'] = 'default' env['RUNNER_TOKEN'] = default_runner.runner_token subprocess.Popen(['/opt/app-root/src/.s2i/bin/run'], env=env)
def init_default_runner(): """ Create default AnarchyRunner if it does not exist. """ try: runner = runtime.custom_objects_api.get_namespaced_custom_object( runtime.operator_domain, 'v1', runtime.operator_namespace, 'anarchyrunners', 'default' ) except kubernetes.client.rest.ApiException as e: if e.status == 404: runner = runtime.custom_objects_api.create_namespaced_custom_object( runtime.operator_domain, 'v1', runtime.operator_namespace, 'anarchyrunners', AnarchyRunner.default_runner_definition(runtime) ) else: raise