Class: KubernetesDeploy::RunnerTask
- Inherits:
-
Object
- Object
- KubernetesDeploy::RunnerTask
- Includes:
- KubeclientBuilder
- Defined in:
- lib/kubernetes-deploy/runner_task.rb
Defined Under Namespace
Classes: FatalTaskRunError, TaskTemplateMissingError
Instance Method Summary collapse
-
#initialize(namespace:, context:, logger:) ⇒ RunnerTask
constructor
A new instance of RunnerTask.
- #run(*args) ⇒ Object
- #run!(task_template:, entrypoint:, args:, env_vars: []) ⇒ Object
Constructor Details
#initialize(namespace:, context:, logger:) ⇒ RunnerTask
Returns a new instance of RunnerTask.
18 19 20 21 22 23 |
# File 'lib/kubernetes-deploy/runner_task.rb', line 18 def initialize(namespace:, context:, logger:) @logger = logger @namespace = namespace @kubeclient = build_v1_kubeclient(context) @context = context end |
Instance Method Details
#run(*args) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/kubernetes-deploy/runner_task.rb', line 25 def run(*args) run!(*args) true rescue FatalDeploymentError => error @logger.fatal "#{error.class}: #{error.}" false end |
#run!(task_template:, entrypoint:, args:, env_vars: []) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/kubernetes-deploy/runner_task.rb', line 33 def run!(task_template:, entrypoint:, args:, env_vars: []) @logger.reset @logger.phase_heading("Validating configuration") validate_configuration(task_template, args) @logger.phase_heading("Fetching task template") raw_template = get_template(task_template) @logger.phase_heading("Constructing final pod specification") rendered_template = build_pod_template(raw_template, entrypoint, args, env_vars) validate_pod_spec(rendered_template) @logger.phase_heading("Creating pod") @logger.info("Starting task runner pod: '#{rendered_template..name}'") @kubeclient.create_pod(rendered_template) end |