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 +4 -4
- data/CHANGELOG.md +3 -0
- data/docs/_config.yml +1 -1
- data/docs/_includes/commands.html +2 -0
- data/lib/kubes/cli.rb +5 -1
- data/lib/kubes/cli/logs.rb +24 -2
- data/lib/kubes/kubectl/fetch/deployment.rb +12 -1
- data/lib/kubes/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acd8b3dbc7ee3cbefbfe9f649c00ec37c7eaefb3ea281f056b3cf720e85f68cf
|
4
|
+
data.tar.gz: 1f9c1ba6f9a6626343239ac267a8f8ccd3c385a09f49f48e471821db084a5ade
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b5bc20d0bd43ee19f204a4dc692b9e4c71c69a3b490575eb397583187ff2e4a401456a943ceae2c3523a8ba42f2f9456809ed538b65dd0d319c0d48fa4318db
|
7
|
+
data.tar.gz: 1a3b59c9a047f75acbf79be98a104c3109f6da3a6c57bed29511fe77ba537e2ceb044f3fcae800e29bbdaed171ae8653c0c0554c2b90039135d1bc93f021d94e
|
data/CHANGELOG.md
CHANGED
@@ -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
|
|
data/docs/_config.yml
CHANGED
@@ -9,7 +9,7 @@ meta_author: Tung Nguyen
|
|
9
9
|
|
10
10
|
# Google webmaster tools
|
11
11
|
google_verify:
|
12
|
-
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:
|
data/lib/kubes/cli.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/kubes/cli/logs.rb
CHANGED
@@ -4,12 +4,34 @@ class Kubes::CLI
|
|
4
4
|
|
5
5
|
def run
|
6
6
|
compile
|
7
|
-
|
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
|
-
|
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
|
33
|
+
deployment
|
24
34
|
end
|
35
|
+
memoize :deployment
|
25
36
|
|
26
37
|
def find_deployment(deployments)
|
27
38
|
if @options[:name]
|
data/lib/kubes/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2020-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|