sensu-plugins-kubernetes 1.0.0 → 1.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
  SHA1:
3
- metadata.gz: da62b54a627d8cb692fc340e5e004d31f4c836cf
4
- data.tar.gz: ffa06f5b83a3e6539a9934929354dc2658873ae3
3
+ metadata.gz: 36157c792a8bec58626218b903748035f536c988
4
+ data.tar.gz: 5b423f2c185b3f00527889355469884182d866f1
5
5
  SHA512:
6
- metadata.gz: d1652721603c4ca51d28f1fdb4248b189c0535722902f8355480cfd1f91f2d7e6761a31c278e5d39db1fff78b42e9ccd183eeb164744d371331bb1fb59df825d
7
- data.tar.gz: 26b2e69ce1a96ccff4f9bb053e65476d7fe1984e48e83d79b53022d83679c7af14a36ead9aec3194311420f891dc0b35c3880ead9c7ad95a1d35e7cb7548869a
6
+ metadata.gz: c350b9c7ab40bfa371b2df8ddacdb56207203e2294252b9c7f34a4e92f7845082bbeab91dcaf9debb794c7b67e1342d5e6f39c8652432eabd7c3a737d7c56af7
7
+ data.tar.gz: e025312b7dbcaaf10c85c48ddb5c1d0964ee6a4ce5c5510a5563ad327268c7cdf0affe3f6a91ec4e330b11c0533df8da2b66c9eafe19848b165778845b82a42f
@@ -5,6 +5,11 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [1.1.0] - 2017-08-11
9
+ ### Added
10
+ - Ruby 2.4.1 testing (@thomasriley)
11
+ - Add option to use kubeconfig file for auth and TLS (@jaxxstorm)
12
+
8
13
  ## [1.0.0] - 2017-03-21
9
14
  ### Added
10
15
  - Add `metrics-pods.rb` that will output the number of running pods per service (@mickfeech)
@@ -49,7 +54,8 @@ pending pods, the restart count portion has been split into it's own check, `che
49
54
  ### Added
50
55
  - initial release
51
56
 
52
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/1.0.0...HEAD
57
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/1.1.0...HEAD
58
+ [1.1.0]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/1.0.0...1.1.0
53
59
  [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/0.1.2...1.0.0
54
60
  [0.1.2]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/0.1.1...0.1.2
55
61
  [0.1.1]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/0.1.0...0.1.1
data/README.md CHANGED
@@ -35,6 +35,7 @@ Usage: check-kube-nodes-ready.rb (options)
35
35
  --token-file TOKEN-FILE File containing bearer token for authorization
36
36
  -u, --user USER User with access to API
37
37
  -v, --api-version VERSION API version
38
+ --kube-config KUBECONFIG Path to a kube config file
38
39
  ```
39
40
 
40
41
  **check-kube-apiserver-available.rb**
@@ -49,6 +50,7 @@ Usage: check-kube-apiserver-available.rb (options)
49
50
  -t, --token TOKEN Bearer token for authorization
50
51
  --token-file TOKEN-FILE File containing bearer token for authorization
51
52
  -u, --user USER User with access to API
53
+ --kube-config KUBECONFIG Path to a kube config file
52
54
  ```
53
55
 
54
56
  **check-kube-pods-pending.rb**
@@ -70,6 +72,7 @@ Usage: check-kube-pods-pending.rb (options)
70
72
  -f, --filter FILTER Selector filter for pods to be checked
71
73
  -p, --pods PODS List of pods to check
72
74
  -r, --restart COUNT Threshold for number of restarts allowed
75
+ --kube-config KUBECONFIG Path to a kube config file
73
76
  ```
74
77
 
75
78
  **check-kube-service-available.rb**
@@ -87,6 +90,7 @@ Usage: check-kube-service-available.rb (options)
87
90
  -v, --api-version VERSION API version
88
91
  -p, --pending SECONDS Time (in seconds) a pod may be pending for and be valid
89
92
  -l, --list SERVICES List of services to check (required)
93
+ --kube-config KUBECONFIG Path to a kube config file
90
94
  ```
91
95
 
92
96
  **check-kube-pods-runtime.rb**
@@ -106,6 +110,7 @@ Usage: check-kube-pods-runtime.rb (options)
106
110
  -f, --filter FILTER Selector filter for pods to be checked
107
111
  -p, --pods PODS List of pods to check
108
112
  -w, --warn TIMEOUT Threshold for pods to be in the pending state
113
+ --kube-config KUBECONFIG Path to a kube config file
109
114
  ```
110
115
 
111
116
  **check-kube-pods-running.rb**
@@ -125,6 +130,7 @@ Usage: ./check-kube-pods-running.rb (options)
125
130
  --exclude-namespace
126
131
  -f, --filter FILTER Selector filter for pods to be checked
127
132
  -p, --pods PODS List of pods to check
133
+ --kube-config KUBECONFIG Path to a kube config file
128
134
  ```
129
135
 
130
136
  **check-kube-pods-restarting.rb**
@@ -146,6 +152,7 @@ Usage: ./check-kube-pods-restarting.rb (options)
146
152
  -f, --filter FILTER Selector filter for pods to be checked
147
153
  -p, --pods PODS List of pods to check
148
154
  -r, --restart COUNT Threshold for number of restarts allowed
155
+ --kube-config KUBECONFIG Path to a kube config file
149
156
  ```
150
157
 
151
158
  **handler-kube-pod.rb**
@@ -186,6 +193,7 @@ Usage: metrics-pods.rb (options)
186
193
  --token-file TOKEN-FILE File containing bearer token for authorization
187
194
  -u, --user USER User with access to API
188
195
  -v, --api-version VERSION API version
196
+ --kube-config KUBECONFIG Path to a kube config file
189
197
  ```
190
198
 
191
199
  `api_server` and `api_version` can still be used for backwards compatibility,
@@ -209,6 +217,7 @@ Of the Kubernetes connection options:
209
217
  --password PASSWORD If user is passed, also pass a password
210
218
  --token TOKEN Bearer token for authorization
211
219
  --token-file TOKEN-FILE File containing bearer token for authorization
220
+ --kube-config KUBECONFIG Path to a kube config file
212
221
  ```
213
222
  Only the API server option is required, however it does default to the `KUBERNETES_MASTER` environment variable, or you can use the in-cluster option. The other options are to be used as needed.
214
223
 
@@ -227,3 +236,5 @@ Only one of the authentication methods (user, token, or token file) can be used.
227
236
  For example, using a username and a token, or a token and a token file, will produce an error.
228
237
 
229
238
  If the 'user' authentication method is used, a password must also be provided.
239
+
240
+ The kubeconfig options enable the usage of a kubeconfig file, which is a yaml file which defines the authentication and TLS config. More information about kubeconfig files can be found in the [Kubernetes Docs](https://kubernetes.io/docs/tasks/access-application-cluster/authenticate-across-clusters-kubeconfig/)
@@ -66,6 +66,11 @@ module Sensu
66
66
  long: '--token-file TOKEN-FILE',
67
67
  default: nil
68
68
 
69
+ option :kube_config,
70
+ description: 'Path to a kube config file',
71
+ long: '--kube-config KUBECONFIG',
72
+ default: nil
73
+
69
74
  attr_reader :client
70
75
 
71
76
  # Initializes the Sensu check by creating a Kubernetes client
@@ -84,7 +89,8 @@ module Sensu
84
89
  username: config[:api_user],
85
90
  password: config[:api_password],
86
91
  token: config[:api_token],
87
- token_file: config[:api_token_file]
92
+ token_file: config[:api_token_file],
93
+ kube_config: config[:kube_config]
88
94
  )
89
95
  rescue ArgumentError => e
90
96
  critical e.message
@@ -38,6 +38,8 @@ module Sensu
38
38
  # The bearer token for Kubernetes authorization
39
39
  # @option options [String] :token_file
40
40
  # A file containing the bearer token for Kubernetes authorization
41
+ # @option options [String] :kube_config
42
+ # A file containing kubeconfig yaml configuration
41
43
  #
42
44
  # @raise [ArgumentError] If an invalid option, or combination of options, is given.
43
45
  # @raise [Errono::*] If there is a problem reading the client certificate or private key file.
@@ -46,18 +48,32 @@ module Sensu
46
48
  def kubeclient(options = {})
47
49
  raise(ArgumentError, 'options must be a hash') unless options.is_a?(Hash)
48
50
 
49
- api_server = options[:server]
50
- api_version = options[:version]
51
-
52
- ssl_options = {
53
- ca_file: options[:ca_file]
54
- }
55
- auth_options = {
56
- username: options[:username],
57
- password: options[:password],
58
- bearer_token: options[:token],
59
- bearer_token_file: options[:token_file]
60
- }
51
+ if options[:kube_config]
52
+ begin
53
+ config = Kubeclient::Config.read(options[:kube_config])
54
+
55
+ api_server = config.context.api_endpoint
56
+ api_version = config.context.api_version
57
+
58
+ ssl_options = config.context.ssl_options
59
+ auth_options = config.context.auth_options
60
+ rescue => e
61
+ raise e, "Unable to read kubeconfig: #{e}", e.backtrace
62
+ end
63
+ else
64
+ api_server = options[:server]
65
+ api_version = options[:version]
66
+
67
+ ssl_options = {
68
+ ca_file: options[:ca_file]
69
+ }
70
+ auth_options = {
71
+ username: options[:username],
72
+ password: options[:password],
73
+ bearer_token: options[:token],
74
+ bearer_token_file: options[:token_file]
75
+ }
76
+ end
61
77
 
62
78
  if [:client_cert_file, :client_key_file].count { |k| options[k] } == 1
63
79
  raise ArgumentError, 'SSL requires both client cert and client key'
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsKubernetes
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 0
4
+ MINOR = 1
5
5
  PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
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: 1.0.0
4
+ version: 1.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: 2017-03-21 00:00:00.000000000 Z
11
+ date: 2017-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin