kdep 0.4.8 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kdep/commands/log.rb +19 -13
- data/lib/kdep/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 92fded408b48545949833a1473e7b905dc7ce0b8b7c58415ad77b532f0205227
|
|
4
|
+
data.tar.gz: 2af6988f918a2ba676a4a2d5780a950581f0e93596e772d4e04f3ca65b9fdba0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f1d30adf7eb1fe069115dc5cea6458f1e83ef4ef3025fb32912b9fee74f0b68582606fa71aa2e0b306e3ed80a5dda2dacec74760b3e9eb02884e794c18ec75c
|
|
7
|
+
data.tar.gz: d6b64df4bbe169c1f80c2169f6c3378d6ab62ce57096f6aa0d4f5cf8f3251f25cde1ffbfce1e490028a60bb9872f1848fc9bef016cc34aed23160e4e0144b99b
|
data/lib/kdep/commands/log.rb
CHANGED
|
@@ -3,11 +3,14 @@ require "optparse"
|
|
|
3
3
|
module Kdep
|
|
4
4
|
module Commands
|
|
5
5
|
class Log
|
|
6
|
+
# kubectl refuses to follow more than --max-log-requests streams (default 5)
|
|
7
|
+
MIN_LOG_REQUESTS = 5
|
|
8
|
+
|
|
6
9
|
def self.option_parser
|
|
7
10
|
OptionParser.new do |opts|
|
|
8
11
|
opts.banner = "Usage: kdep log [deploy]"
|
|
9
12
|
opts.separator ""
|
|
10
|
-
opts.separator "Streams pod
|
|
13
|
+
opts.separator "Streams logs from all running pods (prefixed by pod) with error highlighting."
|
|
11
14
|
opts.separator ""
|
|
12
15
|
opts.on("-f", "--[no-]follow", "Follow log output (default: true)")
|
|
13
16
|
opts.on("-c", "--container=NAME", "Container name for multi-container pods")
|
|
@@ -50,40 +53,43 @@ module Kdep
|
|
|
50
53
|
exit 1
|
|
51
54
|
end
|
|
52
55
|
|
|
53
|
-
#
|
|
56
|
+
# Count matching pods (fails fast when none is running)
|
|
54
57
|
namespace = config["namespace"]
|
|
55
58
|
app_name = config["name"]
|
|
56
|
-
|
|
59
|
+
pod_count = count_pods(namespace, app_name)
|
|
57
60
|
|
|
58
|
-
# Stream logs
|
|
59
|
-
stream_logs(
|
|
61
|
+
# Stream logs from every pod matching the app label
|
|
62
|
+
stream_logs(namespace, app_name, pod_count)
|
|
60
63
|
end
|
|
61
64
|
|
|
62
65
|
private
|
|
63
66
|
|
|
64
|
-
|
|
67
|
+
# kubectl logs -l streams every pod the selector matches, whatever its
|
|
68
|
+
# phase (Completed leftovers, Pending surge pods), so the stream limit
|
|
69
|
+
# must count all of them -- only the guard looks at Running.
|
|
70
|
+
def count_pods(namespace, app_name)
|
|
65
71
|
data = Kdep::Kubectl.run_json(
|
|
66
72
|
"get", "pods",
|
|
67
73
|
"-n", namespace,
|
|
68
|
-
"-l", "app=#{app_name}"
|
|
69
|
-
"--field-selector", "status.phase=Running"
|
|
74
|
+
"-l", "app=#{app_name}"
|
|
70
75
|
)
|
|
71
|
-
pods = data["items"]
|
|
76
|
+
pods = data["items"] || []
|
|
72
77
|
|
|
73
|
-
if pods.
|
|
78
|
+
if pods.none? { |pod| pod.dig("status", "phase") == "Running" }
|
|
74
79
|
@ui.error("No running pods found for #{app_name} in #{namespace}")
|
|
75
80
|
exit 1
|
|
76
81
|
end
|
|
77
82
|
|
|
78
|
-
pods
|
|
83
|
+
pods.length
|
|
79
84
|
end
|
|
80
85
|
|
|
81
|
-
def stream_logs(
|
|
86
|
+
def stream_logs(namespace, app_name, pod_count)
|
|
82
87
|
follow = @command_options.fetch(:follow, true)
|
|
83
88
|
tail = @command_options.fetch(:tail, 100)
|
|
84
89
|
container = @command_options[:container]
|
|
85
90
|
|
|
86
|
-
args = ["kubectl", "logs",
|
|
91
|
+
args = ["kubectl", "logs", "-n", namespace, "-l", "app=#{app_name}", "--prefix", "--ignore-errors"]
|
|
92
|
+
args << "--max-log-requests=#{[pod_count, MIN_LOG_REQUESTS].max}"
|
|
87
93
|
args << "-f" if follow
|
|
88
94
|
args << "--tail=#{tail}"
|
|
89
95
|
|
data/lib/kdep/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kdep
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Leadfy
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: envspec
|
|
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
189
189
|
- !ruby/object:Gem::Version
|
|
190
190
|
version: '0'
|
|
191
191
|
requirements: []
|
|
192
|
-
rubygems_version: 3.
|
|
192
|
+
rubygems_version: 3.5.19
|
|
193
193
|
signing_key:
|
|
194
194
|
specification_version: 4
|
|
195
195
|
summary: Kubernetes deployment CLI
|