Sha256: 72027eb9b5c924cb139978265c6fa549ce2090502327fb85b3fc6550f2dec762

Contents?: true

Size: 744 Bytes

Versions: 5

Compression:

Stored size: 744 Bytes

Contents

module K8sKit
  class Pod
    attr_reader :context, :name

    def initialize(context, name)
      @context = context
      @name = name
    end

    def logs(container: nil, stream: false)
      command = "logs #{name}"
      command += " -c #{container}" if container
      command += " -f" if stream

      context.run(command, silent: false)
    end

    def wait_until_ready(timeout: '5m')
      context.run("wait pod/#{name} --for=condition=Ready --timeout=#{timeout}")
    end

    def exit_code(container:)
      json_path = "{ .status.containerStatuses[?(@.name == '#{container}')].state.terminated.exitCode }"
      context.run("get pod #{name} -o jsonpath=\"#{json_path}\"").to_i
    rescue StandardError
      nil
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
k8s_kit-0.0.5 lib/k8s_kit/pod.rb
k8s_kit-0.0.4 lib/k8s_kit/pod.rb
k8s_kit-0.0.3 lib/k8s_kit/pod.rb
k8s_kit-0.0.2 lib/k8s_kit/pod.rb
k8s_kit-0.0.1 lib/k8s_kit/pod.rb