Sha256: 7132cd844ba264e98f6a6e2ed9d6fee0ecf8e0393f2d30e8498ecd050cedb8b9
Contents?: true
Size: 1 KB
Versions: 2
Compression:
Stored size: 1 KB
Contents
class Kubes::CLI class Logs < Base include Kubes::Util::Sh def run compile deployment = Kubes::Kubectl::Fetch::Deployment.new(@options) metadata = deployment.metadata name = metadata['name'] ns = metadata['namespace'] follow = " -f" if @options[:follow] container = container(deployment) c = " -c #{container}" if container sh("kubectl logs deployment/#{name}#{follow} -n #{ns}#{c}") end private def container(deployment) container = @options[:container] return container if container spec = deployment.spec containers = spec['template']['spec']['containers'] names = containers.map { |c| c['name'] } if containers.size > 1 logger.info <<~EOL INFO: More than one container found. Container names: #{names.join(', ')} Using #{names.first} Note: You can specify the container to use with --container or -c EOL names.first end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kubes-0.3.5 | lib/kubes/cli/logs.rb |
kubes-0.3.4 | lib/kubes/cli/logs.rb |