Class: ManageIQ::Floe::Workflow::Runner::Kubernetes
- Inherits:
-
ManageIQ::Floe::Workflow::Runner
- Object
- ManageIQ::Floe::Workflow::Runner
- ManageIQ::Floe::Workflow::Runner::Kubernetes
- Defined in:
- lib/manageiq/floe/workflow/runner/kubernetes.rb
Instance Attribute Summary collapse
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Instance Method Summary collapse
-
#initialize ⇒ Kubernetes
constructor
A new instance of Kubernetes.
- #run!(resource, env = {}, secrets = {}) ⇒ Object
Methods inherited from ManageIQ::Floe::Workflow::Runner
Methods included from Logging
Constructor Details
#initialize ⇒ Kubernetes
Returns a new instance of Kubernetes.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/manageiq/floe/workflow/runner/kubernetes.rb', line 8 def initialize(*) require "awesome_spawn" require "securerandom" require "base64" require "yaml" @namespace = ENV.fetch("DOCKER_RUNNER_NAMESPACE", "default") super end |
Instance Attribute Details
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
6 7 8 |
# File 'lib/manageiq/floe/workflow/runner/kubernetes.rb', line 6 def namespace @namespace end |
Instance Method Details
#run!(resource, env = {}, secrets = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/manageiq/floe/workflow/runner/kubernetes.rb', line 19 def run!(resource, env = {}, secrets = {}) raise ArgumentError, "Invalid resource" unless resource&.start_with?("docker://") image = resource.sub("docker://", "") name = pod_name(image) secret = create_secret!(secrets) unless secrets&.empty? overrides = pod_spec(image, env, secret) result = kubectl_run!(image, name, overrides) # Kubectl prints that the pod was deleted, strip this from the output output = result.output.gsub(/pod \"#{name}\" deleted/, "") [result.exit_status, output] ensure delete_secret!(secret) if secret end |