kubes 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 717e82d009d9109cbd891aa3881a0ab645fca4388a0268b979bd80b6c65b4b5a
4
- data.tar.gz: bf0fa4160bcc4592e8ec04e4aa408f36797c0486fe2265ee9aee2406b152502a
3
+ metadata.gz: acd8b3dbc7ee3cbefbfe9f649c00ec37c7eaefb3ea281f056b3cf720e85f68cf
4
+ data.tar.gz: 1f9c1ba6f9a6626343239ac267a8f8ccd3c385a09f49f48e471821db084a5ade
5
5
  SHA512:
6
- metadata.gz: 459680ca83a280070c044ada5ff57a12c960e92d6c5d4a4c27f1fed9aca27047e6eb31fef3d24697be9f5f30cb745fac450062d7e0d5cdafbb37997c41f7b91f
7
- data.tar.gz: 8530622fe5dd61e41c20213b11b296964c14dd5ef7a7510a5df5e6bbe51d4dc3be6dae763bac4faa3784fea1530f4680d2fb24806ed8fc08e283595b315be553
6
+ metadata.gz: 9b5bc20d0bd43ee19f204a4dc692b9e4c71c69a3b490575eb397583187ff2e4a401456a943ceae2c3523a8ba42f2f9456809ed538b65dd0d319c0d48fa4318db
7
+ data.tar.gz: 1a3b59c9a047f75acbf79be98a104c3109f6da3a6c57bed29511fe77ba537e2ceb044f3fcae800e29bbdaed171ae8653c0c0554c2b90039135d1bc93f021d94e
@@ -3,6 +3,9 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [0.3.3]
7
+ - #22 logs -c option. fix kubes logs for pods with multiple containers
8
+
6
9
  ## [0.3.2]
7
10
  - #21 add namespace to logs command
8
11
 
@@ -9,7 +9,7 @@ meta_author: Tung Nguyen
9
9
 
10
10
  # Google webmaster tools
11
11
  google_verify:
12
- google_analytics: "TODO: google_analytics"
12
+ google_analytics: "UA-98684555-14"
13
13
 
14
14
  # https://ssl.bing.com/webmaster/configure/verify/ownership Option 2 content= goes here
15
15
  bing_verify:
@@ -20,6 +20,8 @@ kubes compile
20
20
  kubes deploy
21
21
  kubes apply
22
22
  kubes get
23
+ kubes exec
24
+ kubes logs
23
25
  kubes delete -y
24
26
  {% endhighlight %}
25
27
  </div>
@@ -12,6 +12,9 @@ module Kubes
12
12
  name_option = Proc.new {
13
13
  option :name, aliases: %w[n], desc: "deployment name to use. IE: demo-web"
14
14
  }
15
+ container_option = Proc.new {
16
+ option :container, aliases: %w[c], desc: "Container name. If omitted, the first container in the pod will be chosen"
17
+ }
15
18
 
16
19
  desc "docker SUBCOMMAND", "Docker subcommands"
17
20
  long_desc Help.text(:docker)
@@ -67,7 +70,7 @@ module Kubes
67
70
  long_desc Help.text(:exec)
68
71
  compile_option.call
69
72
  name_option.call
70
- option :container, aliases: %w[c], desc: "Container name. If omitted, the first container in the pod will be chosen"
73
+ container_option.call
71
74
  def exec(*cmd)
72
75
  Exec.new(options.merge(cmd: cmd)).run
73
76
  end
@@ -86,6 +89,7 @@ module Kubes
86
89
  long_desc Help.text(:logs)
87
90
  compile_option.call
88
91
  name_option.call
92
+ container_option.call
89
93
  option :follow, aliases: %w[f], type: :boolean, default: true, desc: "Follow logs"
90
94
  def logs(*cmd)
91
95
  Logs.new(options.merge(cmd: cmd)).run
@@ -4,12 +4,34 @@ class Kubes::CLI
4
4
 
5
5
  def run
6
6
  compile
7
- metadata = Kubes::Kubectl::Fetch::Deployment.new(@options).metadata
7
+ deployment = Kubes::Kubectl::Fetch::Deployment.new(@options)
8
+ metadata = deployment.metadata
8
9
  name = metadata['name']
9
10
  ns = metadata['namespace']
10
11
 
11
12
  follow = " -f" if @options[:follow]
12
- sh("kubectl logs deployment/#{name}#{follow} -n #{ns}")
13
+ c = container(deployment)
14
+ sh("kubectl logs deployment/#{name}#{follow} -n #{ns} -c #{c}")
15
+ end
16
+
17
+ private
18
+ def container(deployment)
19
+ container = @options[:container]
20
+ return container if container
21
+
22
+ spec = deployment.spec
23
+ containers = spec['template']['spec']['containers']
24
+ names = containers.map { |c| c['name'] }
25
+ if containers.size > 1
26
+ logger.info <<~EOL
27
+ INFO: More than one container found.
28
+ Container names: #{names.join(', ')}
29
+ Using #{names.first}
30
+ Note: You can specify the container to use with --container or -c
31
+ EOL
32
+
33
+ names.first
34
+ end
13
35
  end
14
36
  end
15
37
  end
@@ -1,6 +1,16 @@
1
1
  module Kubes::Kubectl::Fetch
2
2
  class Deployment < Base
3
+ extend Memoist
4
+
3
5
  def metadata
6
+ deployment['metadata']
7
+ end
8
+
9
+ def spec
10
+ deployment['spec']
11
+ end
12
+
13
+ def deployment
4
14
  items = fetch_items
5
15
  # Not checking if deployment exists because kubes will error on `kubes get` from missing deployments already
6
16
  deployments = items.select { |i| i['kind'] == "Deployment" }
@@ -20,8 +30,9 @@ module Kubes::Kubectl::Fetch
20
30
  logger.error "ERROR: No deployment found".color(:red)
21
31
  exit 1
22
32
  end
23
- deployment['metadata']
33
+ deployment
24
34
  end
35
+ memoize :deployment
25
36
 
26
37
  def find_deployment(deployments)
27
38
  if @options[:name]
@@ -1,3 +1,3 @@
1
1
  module Kubes
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kubes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-07 00:00:00.000000000 Z
11
+ date: 2020-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport