sensu-plugins-kubernetes 3.0.1 → 3.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1b3b5137ced0c6f5389c7758feb32414c642e6892f097d72e504d50c3239e24
4
- data.tar.gz: 18be79eb55bc1f39e24701dc515289c600e375e640bfa410efb01204307bd98b
3
+ metadata.gz: 45a45dc3c0d473178c20e48f82d9963c11f44d6cedd3bfe5ee7485834042ed95
4
+ data.tar.gz: 24b10e2d96052d3519623e615b3e256232fa49b9a9f09f1a137901407d7b2c10
5
5
  SHA512:
6
- metadata.gz: 14cda7064913e1b125fecc685c38f8632c4d40d9af234002ca5fffb63e5c1bbc28016d0fa3df2f3d37b08c5b4ebe964696b99e7c7d180fb6541d62e29ccea96c
7
- data.tar.gz: c00a75f45747398767f47cc810c85d6f22832ba49c2c5cfe97542add001f0e10749ecc236e5feb73749b199e82a3bb357bfec0dd5d9022893ae96f6b2696b074
6
+ metadata.gz: b91a158f2ca9de86fe65a2d2b063f2fac90711b83dad7557d2e04f5310f3c765a2aecafe5518324026ec7e32b89e206fbeba62150eed8c861a72a31c94b0a6a8
7
+ data.tar.gz: c75419669faf06fd1e852f6580165aa75d009651257ef6dfe14da67026e9f333146ac1ee7fa54035a6aedb93aa387e49a5e1a4d2b53e15fdefbe17d85532861e
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ This CHANGELOG follows the format listed [here ](https://github.com/sensu-plugin
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [3.1.0] - 2018-10-29
9
+ ### Added
10
+ - `check-kube-nodes-ready.rb`, `check-kube-pods-pending.rb`, `check-kube-pods-restarting.rb`, `check-kube-pods-running.rb`: added options `--included-nodes` and `--excluded-nodes` which support a comma separated list so you can filter nodes (@ttarczynski)
11
+
8
12
  ### Fixed
9
13
  - check-kube-pods-running.rb no longer throws an exception when there are no 3 conditions in the status information. Issue #39 (@AgarFu)
10
14
 
@@ -68,7 +72,8 @@ pending pods, the restart count portion has been split into it's own check, `che
68
72
  ### Added
69
73
  - initial release
70
74
 
71
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/3.0.1...HEAD
75
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/3.1.0...HEAD
76
+ [3.1.0]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/3.0.1...3.1.0
72
77
  [3.0.1]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/3.0.0...3.0.0.1
73
78
  [3.0.0]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/2.0.0...3.0.0
74
79
  [2.0.0]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/1.1.0...2.0.0
data/README.md CHANGED
@@ -36,6 +36,10 @@ Usage: check-kube-nodes-ready.rb (options)
36
36
  -u, --user USER User with access to API
37
37
  -v, --api-version VERSION API version
38
38
  --kube-config KUBECONFIG Path to a kube config file
39
+ --exclude-nodes Exclude the specified nodes (comma separated list)
40
+ Exclude wins when a node is in both include and exclude lists
41
+ --include-nodes Include the specified nodes (comma separated list), an
42
+ empty list includes all nodes
39
43
  ```
40
44
 
41
45
  **check-kube-apiserver-available.rb**
@@ -70,6 +74,10 @@ Usage: check-kube-pods-pending.rb (options)
70
74
  --exclude-namespace
71
75
  -i NAMESPACES, Include the specified list of namespaces, an
72
76
  --include-namespace empty list includes all namespaces
77
+ --exclude-nodes Exclude the specified nodes (comma separated list)
78
+ Exclude wins when a node is in both include and exclude lists
79
+ --include-nodes Include the specified nodes (comma separated list), an
80
+ empty list includes all nodes
73
81
  -t, --timeout TIMEOUT Threshold for pods to be in the pending state
74
82
  -f, --filter FILTER Selector filter for pods to be checked
75
83
  -p, --pods PODS List of pods to check
@@ -132,6 +140,10 @@ Usage: ./check-kube-pods-running.rb (options)
132
140
  --exclude-namespace
133
141
  -i NAMESPACES, Include the specified list of namespaces, an
134
142
  --include-namespace empty list includes all namespaces
143
+ --exclude-nodes Exclude the specified nodes (comma separated list)
144
+ Exclude wins when a node is in both include and exclude lists
145
+ --include-nodes Include the specified nodes (comma separated list), an
146
+ empty list includes all nodes
135
147
  -f, --filter FILTER Selector filter for pods to be checked
136
148
  -p, --pods PODS List of pods to check
137
149
  --kube-config KUBECONFIG Path to a kube config file
@@ -155,6 +167,10 @@ Usage: ./check-kube-pods-restarting.rb (options)
155
167
  --exclude-namespace
156
168
  -i NAMESPACES, Include the specified list of namespaces, an
157
169
  --include-namespace empty list includes all namespaces
170
+ --exclude-nodes Exclude the specified nodes (comma separated list)
171
+ Exclude wins when a node is in both include and exclude lists
172
+ --include-nodes Include the specified nodes (comma separated list), an
173
+ empty list includes all nodes
158
174
  -f, --filter FILTER Selector filter for pods to be checked
159
175
  -p, --pods PODS List of pods to check
160
176
  -r, --restart COUNT Threshold for number of restarts allowed
@@ -26,6 +26,10 @@
26
26
  # -p, --password PASSWORD If user is passed, also pass a password
27
27
  # -t, --token TOKEN Bearer token for authorization
28
28
  # --token-file TOKEN-FILE File containing bearer token for authorization
29
+ # --exclude-nodes Exclude the specified nodes (comma separated list)
30
+ # Exclude wins when a node is in both include and exclude lists
31
+ # --include-nodes Include the specified nodes (comma separated list), an
32
+ # empty list includes all nodes
29
33
  #
30
34
  # LICENSE:
31
35
  # Kel Cecil <kelcecil@praisechaos.com>
@@ -34,9 +38,23 @@
34
38
  #
35
39
 
36
40
  require 'sensu-plugins-kubernetes/cli'
41
+ require 'sensu-plugins-kubernetes/exclude'
37
42
 
38
43
  class AllNodesAreReady < Sensu::Plugins::Kubernetes::CLI
39
44
  @options = Sensu::Plugins::Kubernetes::CLI.options.dup
45
+ include Sensu::Plugins::Kubernetes::Exclude
46
+
47
+ option :exclude_nodes,
48
+ description: 'Exclude the specified nodes (comma separated list)',
49
+ long: '--exclude-nodes NODES',
50
+ proc: proc { |a| a.split(',') },
51
+ default: ''
52
+
53
+ option :include_nodes,
54
+ description: 'Include the specified nodes (comma separated list)',
55
+ long: '--include-nodes NODES',
56
+ proc: proc { |a| a.split(',') },
57
+ default: ''
40
58
 
41
59
  def run
42
60
  failed_nodes = []
@@ -45,6 +63,7 @@ class AllNodesAreReady < Sensu::Plugins::Kubernetes::CLI
45
63
  if item.nil?
46
64
  warning "#{node.name} does not have a status"
47
65
  elsif item.status != 'True'
66
+ next if should_exclude_node(node.metadata.name)
48
67
  failed_nodes << node.metadata.name unless node.spec.unschedulable
49
68
  end
50
69
  end
@@ -30,6 +30,10 @@
30
30
  # --exclude-namespace
31
31
  # -i NAMESPACES, Include the specified list of namespaces, an
32
32
  # --include-namespace empty list includes all namespaces
33
+ # --exclude-nodes Exclude the specified nodes (comma separated list)
34
+ # Exclude wins when a node is in both include and exclude lists
35
+ # --include-nodes Include the specified nodes (comma separated list), an
36
+ # empty list includes all nodes
33
37
  # -t, --timeout TIMEOUT Threshold for pods to be in the pending state
34
38
  # -f, --filter FILTER Selector filter for pods to be checked
35
39
  # -p, --pods PODS Optional list of pods to check.
@@ -46,9 +50,11 @@
46
50
  #
47
51
 
48
52
  require 'sensu-plugins-kubernetes/cli'
53
+ require 'sensu-plugins-kubernetes/exclude'
49
54
 
50
55
  class AllPodsAreReady < Sensu::Plugins::Kubernetes::CLI
51
56
  @options = Sensu::Plugins::Kubernetes::CLI.options.dup
57
+ include Sensu::Plugins::Kubernetes::Exclude
52
58
 
53
59
  option :pod_list,
54
60
  description: 'List of pods to check',
@@ -82,6 +88,18 @@ class AllPodsAreReady < Sensu::Plugins::Kubernetes::CLI
82
88
  proc: proc { |a| a.split(',') },
83
89
  default: ''
84
90
 
91
+ option :exclude_nodes,
92
+ description: 'Exclude the specified nodes (comma separated list)',
93
+ long: '--exclude-nodes NODES',
94
+ proc: proc { |a| a.split(',') },
95
+ default: ''
96
+
97
+ option :include_nodes,
98
+ description: 'Include the specified nodes (comma separated list)',
99
+ long: '--include-nodes NODES',
100
+ proc: proc { |a| a.split(',') },
101
+ default: ''
102
+
85
103
  def run
86
104
  pods_list = []
87
105
  failed_pods = []
@@ -99,6 +117,7 @@ class AllPodsAreReady < Sensu::Plugins::Kubernetes::CLI
99
117
  pods.each do |pod|
100
118
  next if pod.nil?
101
119
  next if should_exclude_namespace(pod.metadata.namespace)
120
+ next if should_exclude_node(pod.spec.nodeName)
102
121
  next unless pods_list.include?(pod.metadata.name) || pods_list.include?('all')
103
122
  # Check for pending state
104
123
  next unless pod.status.phase == 'Pending'
@@ -30,6 +30,10 @@
30
30
  # --exclude-namespace
31
31
  # -i NAMESPACES, Include the specified list of namespaces, an
32
32
  # --include-namespace empty list includes all namespaces
33
+ # --exclude-nodes Exclude the specified nodes (comma separated list)
34
+ # Exclude wins when a node is in both include and exclude lists
35
+ # --include-nodes Include the specified nodes (comma separated list), an
36
+ # empty list includes all nodes
33
37
  # -f, --filter FILTER Selector filter for pods to be checked
34
38
  # -p, --pods PODS List of pods to check
35
39
  # -r, --restart COUNT Threshold for number of restarts allowed
@@ -45,9 +49,11 @@
45
49
  #
46
50
 
47
51
  require 'sensu-plugins-kubernetes/cli'
52
+ require 'sensu-plugins-kubernetes/exclude'
48
53
 
49
54
  class PodsRestarting < Sensu::Plugins::Kubernetes::CLI
50
55
  @options = Sensu::Plugins::Kubernetes::CLI.options.dup
56
+ include Sensu::Plugins::Kubernetes::Exclude
51
57
 
52
58
  option :pod_list,
53
59
  description: 'List of pods to check',
@@ -81,6 +87,18 @@ class PodsRestarting < Sensu::Plugins::Kubernetes::CLI
81
87
  proc: proc { |a| a.split(',') },
82
88
  default: ''
83
89
 
90
+ option :exclude_nodes,
91
+ description: 'Exclude the specified nodes (comma separated list)',
92
+ long: '--exclude-nodes NODES',
93
+ proc: proc { |a| a.split(',') },
94
+ default: ''
95
+
96
+ option :include_nodes,
97
+ description: 'Include the specified nodes (comma separated list)',
98
+ long: '--include-nodes NODES',
99
+ proc: proc { |a| a.split(',') },
100
+ default: ''
101
+
84
102
  def run
85
103
  pods_list = []
86
104
  restarted_pods = []
@@ -98,6 +116,7 @@ class PodsRestarting < Sensu::Plugins::Kubernetes::CLI
98
116
  pods.each do |pod|
99
117
  next if pod.nil?
100
118
  next if should_exclude_namespace(pod.metadata.namespace)
119
+ next if should_exclude_node(pod.spec.nodeName)
101
120
  next unless pods_list.include?(pod.metadata.name) || pods_list.include?('all')
102
121
  # Check restarts
103
122
  next if pod.status.containerStatuses.nil?
@@ -30,6 +30,10 @@
30
30
  # --exclude-namespace
31
31
  # -i NAMESPACES, Include the specified list of namespaces, an
32
32
  # --include-namespace empty list includes all namespaces
33
+ # --exclude-nodes Exclude the specified nodes (comma separated list)
34
+ # Exclude wins when a node is in both include and exclude lists
35
+ # --include-nodes Include the specified nodes (comma separated list), an
36
+ # empty list includes all nodes
33
37
  # -f, --filter FILTER Selector filter for pods to be checked
34
38
  # -p, --pods PODS List of pods to check
35
39
  # NOTES:
@@ -43,9 +47,11 @@
43
47
  #
44
48
 
45
49
  require 'sensu-plugins-kubernetes/cli'
50
+ require 'sensu-plugins-kubernetes/exclude'
46
51
 
47
52
  class AllPodsAreRunning < Sensu::Plugins::Kubernetes::CLI
48
53
  @options = Sensu::Plugins::Kubernetes::CLI.options.dup
54
+ include Sensu::Plugins::Kubernetes::Exclude
49
55
 
50
56
  option :pod_list,
51
57
  description: 'List of pods to check',
@@ -72,6 +78,18 @@ class AllPodsAreRunning < Sensu::Plugins::Kubernetes::CLI
72
78
  proc: proc { |a| a.split(',') },
73
79
  default: ''
74
80
 
81
+ option :exclude_nodes,
82
+ description: 'Exclude the specified nodes (comma separated list)',
83
+ long: '--exclude-nodes NODES',
84
+ proc: proc { |a| a.split(',') },
85
+ default: ''
86
+
87
+ option :include_nodes,
88
+ description: 'Include the specified nodes (comma separated list)',
89
+ long: '--include-nodes NODES',
90
+ proc: proc { |a| a.split(',') },
91
+ default: ''
92
+
75
93
  def run
76
94
  pods_list = []
77
95
  failed_pods = []
@@ -89,6 +107,7 @@ class AllPodsAreRunning < Sensu::Plugins::Kubernetes::CLI
89
107
  pods.each do |pod|
90
108
  next if pod.nil?
91
109
  next if should_exclude_namespace(pod.metadata.namespace)
110
+ next if should_exclude_node(pod.spec.nodeName)
92
111
  next unless pods_list.include?(pod.metadata.name) || pods_list.include?('all')
93
112
  next unless pod.status.phase != 'Succeeded' && !pod.status.conditions.nil?
94
113
  failed_pods << pod.metadata.name unless ready? pod
@@ -0,0 +1,33 @@
1
+ module Sensu
2
+ module Plugins
3
+ # Namespace for the Kubernetes sensu-plugin.
4
+ module Kubernetes
5
+ # A mixin module that provides filtering functions.
6
+ module Exclude
7
+ # Filters the list of pods or nodes based on include/exclude options.
8
+ #
9
+ # @option options [String] :exclude_nodes
10
+ # Exclude the specified nodes (comma separated list)
11
+ # Exclude wins when a node is in both include and exclude lists
12
+ # @option options [String] :include-nodes
13
+ # Include the specified nodes (comma separated list), an
14
+ # empty list includes all nodes
15
+ def node_included?(node_name)
16
+ if config[:include_nodes].empty?
17
+ true
18
+ else
19
+ config[:include_nodes].include?(node_name)
20
+ end
21
+ end
22
+
23
+ def node_excluded?(node_name)
24
+ config[:exclude_nodes].include?(node_name)
25
+ end
26
+
27
+ def should_exclude_node(node_name)
28
+ node_excluded?(node_name) || !node_included?(node_name)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsKubernetes
2
2
  module Version
3
3
  MAJOR = 3
4
- MINOR = 0
5
- PATCH = 1
4
+ MINOR = 1
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-kubernetes
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-03 00:00:00.000000000 Z
11
+ date: 2018-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -181,15 +181,15 @@ dependencies:
181
181
  description: Provides monitoring for Kubernetes via Sensu
182
182
  email: "<sensu-users@googlegroups.com>"
183
183
  executables:
184
- - check-kube-apiserver-available.rb
185
- - check-kube-nodes-ready.rb
186
- - check-kube-pods-pending.rb
187
- - check-kube-pods-restarting.rb
188
- - check-kube-pods-running.rb
189
- - check-kube-pods-runtime.rb
190
184
  - check-kube-service-available.rb
185
+ - check-kube-pods-running.rb
191
186
  - handler-kube-pod.rb
187
+ - check-kube-pods-runtime.rb
192
188
  - metrics-pods.rb
189
+ - check-kube-pods-pending.rb
190
+ - check-kube-nodes-ready.rb
191
+ - check-kube-pods-restarting.rb
192
+ - check-kube-apiserver-available.rb
193
193
  extensions: []
194
194
  extra_rdoc_files: []
195
195
  files:
@@ -208,6 +208,7 @@ files:
208
208
  - lib/sensu-plugins-kubernetes.rb
209
209
  - lib/sensu-plugins-kubernetes/cli.rb
210
210
  - lib/sensu-plugins-kubernetes/client.rb
211
+ - lib/sensu-plugins-kubernetes/exclude.rb
211
212
  - lib/sensu-plugins-kubernetes/version.rb
212
213
  homepage: https://github.com/sensu-plugins/sensu-plugins-kubernetes
213
214
  licenses:
@@ -235,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
236
  version: '0'
236
237
  requirements: []
237
238
  rubyforge_project:
238
- rubygems_version: 2.7.6
239
+ rubygems_version: 2.7.7
239
240
  signing_key:
240
241
  specification_version: 4
241
242
  summary: Sensu plugins for kubernetes