class OodCore::Job::Adapters::Kubernetes::Resources::Container

Attributes

command[RW]
cpu_limit[RW]
cpu_request[RW]
env[RW]
image[RW]
image_pull_policy[RW]
image_pull_secret[RW]
labels[RW]
memory_limit[RW]
memory_request[RW]
name[RW]
port[RW]
restart_policy[RW]
startup_probe[RW]
supplemental_groups[RW]
working_dir[RW]

Public Class Methods

new( name, image, command: [], port: nil, env: {}, memory_limit: nil, memory_request: nil, cpu_limit: nil, cpu_request: nil, working_dir: "", restart_policy: "Never", image_pull_policy: nil, image_pull_secret: nil, supplemental_groups: [], startup_probe: {}, labels: {} ) click to toggle source
# File lib/ood_core/job/adapters/kubernetes/resources.rb, line 63
def initialize(
    name, image, command: [], port: nil, env: {},
    memory_limit: nil, memory_request: nil, cpu_limit: nil, cpu_request: nil,
    working_dir: "", restart_policy: "Never", image_pull_policy: nil, image_pull_secret: nil, supplemental_groups: [],
    startup_probe: {}, labels: {}
  )
  raise ArgumentError, "containers need valid names and images" unless name && image

  @name = name
  @image = image
  @command = command.nil? ? [] : command
  @port = port&.to_i
  @env = env.nil? ? {} : env
  @memory_limit = memory_limit.nil? ? "4Gi" : memory_limit
  @memory_request = memory_request.nil? ? "4Gi" : memory_request
  @cpu_limit = cpu_limit.nil? ? "1" : cpu_limit
  @cpu_request = cpu_request.nil? ? "1" : cpu_request
  @working_dir = working_dir.nil? ? "" : working_dir
  @restart_policy = restart_policy.nil? ? "Never" : restart_policy
  @image_pull_policy = image_pull_policy.nil? ? "IfNotPresent" : image_pull_policy
  @image_pull_secret = image_pull_secret
  @supplemental_groups = supplemental_groups.nil? ? [] : supplemental_groups
  @startup_probe = TCPProbe.new(@port, startup_probe)
  @labels = labels.nil? ? {} : labels
end

Public Instance Methods

==(other) click to toggle source
# File lib/ood_core/job/adapters/kubernetes/resources.rb, line 89
def ==(other)
  name == other.name &&
    image == other.image &&
    command == other.command &&
    port == other.port &&
    env == other.env &&
    memory_limit == other.memory_limit &&
    memory_request == other.memory_request &&
    cpu_limit == other.cpu_limit &&
    cpu_request == other.cpu_request &&
    working_dir == other.working_dir &&
    restart_policy == other.restart_policy &&
    image_pull_policy == other.image_pull_policy &&
    image_pull_secret == other.image_pull_secret &&
    supplemental_groups == other.supplemental_groups &&
    startup_probe.to_h == other.startup_probe.to_h &&
    labels.to_h == other.labels.to_h
end