Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .bonsai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
description: "#{repo}"
builds:
- platform: "alpine"
arch: "amd64"
asset_filename: "#{repo}_#{version}_alpine_linux_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'amd64'"
- "entity.system.platform == 'alpine'"
- "entity.system.platform_version.split('.')[0] == '3'"
- platform: "alpine3.8"
arch: "amd64"
asset_filename: "#{repo}_#{version}_alpine3.8_linux_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'amd64'"
- "entity.system.platform == 'alpine'"
- platform: "centos6"
arch: "amd64"
asset_filename: "#{repo}_#{version}_centos6_linux_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'amd64'"
- "entity.system.platform_family == 'rhel'"
- "entity.system.platform_version.split('.')[0] == '6'"
- platform: "centos7"
arch: "amd64"
asset_filename: "#{repo}_#{version}_centos7_linux_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'amd64'"
- "entity.system.platform_family == 'rhel'"
- "entity.system.platform_version.split('.')[0] == '7'"
- platform: "debian"
arch: "amd64"
asset_filename: "#{repo}_#{version}_debian_linux_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'amd64'"
- "entity.system.platform_family == 'debian'"
- platform: "debian9"
arch: "amd64"
asset_filename: "#{repo}_#{version}_debian9_linux_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'amd64'"
- "entity.system.platform_family == 'debian'"
- "entity.system.platform_version.split('.')[0] == '9'"
34 changes: 25 additions & 9 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,46 @@

MethodLength:
Metrics/MethodLength:
Max: 200

LineLength:
Layout/LineLength:
Max: 160

AbcSize:
Metrics/AbcSize:
Max: 100

FileName:
Naming/FileName:
Enabled: false

PerceivedComplexity:
Metrics/PerceivedComplexity:
Enabled: false

CyclomaticComplexity:
Metrics/CyclomaticComplexity:
Enabled: false

ClassLength:
Metrics/ClassLength:
Enabled: false

IfUnlessModifier:
Style/IfUnlessModifier:
Enabled: false

RegexpLiteral:
Style/RegexpLiteral:
Enabled: false

Style/Documentation:
Enabled: false

Lint/RaiseException:
Enabled: true

Lint/StructNewOverride:
Enabled: true

Style/HashEachMethods:
Enabled: true

Style/HashTransformKeys:
Enabled: true

Style/HashTransformValues:
Enabled: true

13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
language: ruby
services:
- docker
cache:
- bundler
install:
Expand All @@ -16,8 +18,10 @@ script:
- bundle exec rake default
- gem build sensu-plugins-kubernetes.gemspec
- gem install sensu-plugins-kubernetes-*.gem
before_deploy:
- bash -c "[ ! -d bonsai/ ] && git clone https://github.com/sensu/sensu-go-bonsai-asset.git bonsai || echo 'bonsai/ exists, skipping git clone'"
deploy:
provider: rubygems
- provider: rubygems
api_key:
secure: EzXA4HctGH56NvP4RS+vEntVwB5q3K7xDnvCS7KQrZIly7B5rlXhJgHzrcdS61AAHybF/C4btOIazx3lkI+TihX3zyztziHa4+vwcavhF86TDk4MmDgYqScSL9agP+LOHlQ38jLY/l8buGLgF96V1/pgNZjnw5vTugE3GXtDfPF6f6CXg/3RqADF8yjglb9HAxWYEkwmPLZynbtHFJA9/h5mggVfjHJFAZLFHsewx4FB4FjxMrt3yusIlNbj9LKHHqsQqJl8DCoxGhiQmysSLS3NoN7vVhi3UA4TdHArtSZgRmsZKhsJDGcgM/DWGFvqmnHTItlAVTKPZhSAYBxIsbpY5adGMNE/QDDDbnjqhCE5PZQ1mQq12E1dmcFGZAV7vVPvzkBGCMNLnlH6KFuqw/mUg/BU7xPPMnvsc51XEbYJtFFZ1UGeJWTe0DTrLCmIZd4r9KaydNeal35iu/s+rC9aPh9u0AsSJiKVi3CewoVAgc+A+uF8WTTjol0APwO4sra4JlNBeKMVgq2/4uEzsSDCz+Y/U4Rw8RLLXi6xGB1PM1Ar9SvIabeoNj9gY+LApYI1YAPUUVUXf44TLSwvDSrUW12DnhPgMg0CjicGlZkXOAnDNob8b8bU8YUP7wN8eOwt0J63hhn40G7XCA5WCpNm0W7qbLlV8sUBb+3F07c=
gem: sensu-plugins-kubernetes
Expand All @@ -27,3 +31,10 @@ deploy:
rvm: 2.3.0
rvm: 2.4.1
repo: sensu-plugins/sensu-plugins-kubernetes
- provider: script
script: bonsai/ruby-runtime/travis-build-ruby-plugin-assets.sh sensu-plugins-kubernetes
skip_cleanup: true
on:
tags: true
all_branches: true
rvm: 2.4.1
33 changes: 32 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,33 @@ This CHANGELOG follows the format listed [here ](https://github.com/sensu-plugin

## [Unreleased]

## [5.0.2] - 2020-09-15
### Fixed
- Fixed frozen_string_literal setting in executables

## [5.0.1] - 2020-04-27
### Changed
- Fixed travis build

## [5.0.0] - 2020-04-27
### Breaking Changes
- Bump `sensu-plugin` dependency from `~> 2.7` to `~> 4.0`
- Bump `activesupport` dependancy to '< 7.0.0'
- Bump `kubeclient` dependency to '>= 2.3', '< 5.0'

### Added
- Bonsai asset support

### Changed
- Updated rubocop dependency to '~> 0.81.0'
- Remediated rubocop issues
- Updated rake dependency to '~> 13.0'
- Removed codeclimate-test-reporter

## [4.0.1] - 2020-03-18
### Fixed
– `check-kube-pods-running.rb`: when POD's status.phase == Pending use the creation time rather than the start time to determine the pod timestamp as it will be nil and cause a downstream type error (@ttarczynski)

## [4.0.0] - 2018-12-15
### Security
- updated rubocop dependency to `~> 0.51.0` per: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8418. (@majormoses)
Expand Down Expand Up @@ -96,7 +123,11 @@ pending pods, the restart count portion has been split into it's own check, `che
### Added
- initial release

[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/4.0.0...HEAD
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/5.0.2...HEAD
[5.0.2]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/5.0.1...5.0.2
[5.0.1]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/5.0.0...5.0.1
[5.0.0]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/4.0.1...5.0.0
[4.0.1]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/4.0.0...4.0.1
[4.0.0]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/3.3.0...4.0.0
[3.3.0]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/3.2.0...3.3.0
[3.2.0]: https://github.com/sensu-plugins/sensu-plugins-kubernetes/compare/3.1.1...3.2.0
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-kubernetes.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-kubernetes)
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-kubernetes.svg)](http://badge.fury.io/rb/sensu-plugins-kubernetes)
[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-kubernetes/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-kubernetes)
[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-kubernetes/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-kubernetes)
[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-kubernetes.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-kubernetes)

## Functionality
Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'github/markup'
require 'redcarpet'
Expand Down Expand Up @@ -27,7 +29,7 @@ desc 'Test for binstubs'
task :check_binstubs do
bin_list = Gem::Specification.load('sensu-plugins-kubernetes.gemspec').executables
bin_list.each do |b|
`which #{ b }`
`which #{b}`
unless $CHILD_STATUS.success?
puts "#{b} was not a binstub"
exit
Expand Down
3 changes: 2 additions & 1 deletion bin/check-kube-apiserver-available.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /usr/bin/env ruby
#
# frozen_string_literal: false

# check-kube-apiserver-available.rb
#
# DESCRIPTION:
Expand Down
4 changes: 3 additions & 1 deletion bin/check-kube-nodes-ready.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /usr/bin/env ruby
#
# frozen_string_literal: false

# check-kube-nodes-ready.rb
#
# DESCRIPTION:
Expand Down Expand Up @@ -64,6 +65,7 @@ def run
warning "#{node.name} does not have a status"
elsif item.status != 'True'
next if should_exclude_node(node.metadata.name)

failed_nodes << node.metadata.name unless node.spec.unschedulable
end
end
Expand Down
8 changes: 6 additions & 2 deletions bin/check-kube-pods-pending.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /usr/bin/env ruby
#
# frozen_string_literal: false

# check-kube-pods-pending
#
# DESCRIPTION:
Expand Down Expand Up @@ -121,6 +122,7 @@ def run
next unless pods_list.include?(pod.metadata.name) || pods_list.include?('all')
# Check for pending state
next unless pod.status.phase == 'Pending'

pod_stamp = Time.parse(pod.metadata.creationTimestamp)
puts pod.metadata.name
if (Time.now.utc - pod_stamp.utc).to_i > config[:pending_timeout]
Expand All @@ -137,13 +139,15 @@ def run
end

def parse_list(list)
return list.split(',') if list && list.include?(',')
return list.split(',') if list&.include?(',')
return [list] if list

['']
end

def should_exclude_namespace(namespace)
return !config[:include_namespace].include?(namespace) unless config[:include_namespace].empty?

config[:exclude_namespace].include?(namespace)
end
end
8 changes: 6 additions & 2 deletions bin/check-kube-pods-restarting.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /usr/bin/env ruby
#
# frozen_string_literal: false

# check-kube-pods-restarting
#
# DESCRIPTION:
Expand Down Expand Up @@ -120,6 +121,7 @@ def run
next unless pods_list.include?(pod.metadata.name) || pods_list.include?('all')
# Check restarts
next if pod.status.containerStatuses.nil?

pod.status.containerStatuses.each do |container|
if container.restartCount.to_i > config[:restart_count]
restarted_pods << "#{pod.metadata.namespace}.#{container.name}"
Expand All @@ -137,13 +139,15 @@ def run
end

def parse_list(list)
return list.split(',') if list && list.include?(',')
return list.split(',') if list&.include?(',')
return [list] if list

['']
end

def should_exclude_namespace(namespace)
return !config[:include_namespace].include?(namespace) unless config[:include_namespace].empty?

config[:exclude_namespace].include?(namespace)
end
end
15 changes: 12 additions & 3 deletions bin/check-kube-pods-running.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /usr/bin/env ruby
#
# frozen_string_literal: false

# check-kube-pods-running
#
# DESCRIPTION:
Expand Down Expand Up @@ -117,9 +118,15 @@ def run
next if should_exclude_node(pod.spec.nodeName)
next unless pods_list.include?(pod.metadata.name) || pods_list.include?('all')
next unless pod.status.phase != 'Succeeded' && !pod.status.conditions.nil?
pod_stamp = Time.parse(pod.status.startTime)

pod_stamp = if pod.status.phase == 'Pending'
Time.parse(pod.metadata.creationTimestamp)
else
Time.parse(pod.status.startTime)
end
runtime = (Time.now.utc - pod_stamp.utc).to_i
next if runtime < config[:not_ready_time]

failed_pods << pod.metadata.name unless ready? pod
end

Expand All @@ -133,13 +140,15 @@ def run
end

def parse_list(list)
return list.split(',') if list && list.include?(',')
return list.split(',') if list&.include?(',')
return [list] if list

['']
end

def should_exclude_namespace(namespace)
return !config[:include_namespace].include?(namespace) unless config[:include_namespace].empty?

config[:exclude_namespace].include?(namespace)
end

Expand Down
7 changes: 5 additions & 2 deletions bin/check-kube-pods-runtime.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /usr/bin/env ruby
#
# frozen_string_literal: false

# check-kube-pods-runtime
#
# DESCRIPTION:
Expand Down Expand Up @@ -85,6 +86,7 @@ def run
next unless pods_list.include?(pod.metadata.name) || pods_list.include?('all')
# Check for Running state
next unless pod.status.phase == 'Running'

pod_stamp = Time.parse(pod.status.startTime)
runtime = (Time.now.utc - pod_stamp.utc).to_i

Expand All @@ -109,8 +111,9 @@ def run
end

def parse_list(list)
return list.split(',') if list && list.include?(',')
return list.split(',') if list&.include?(',')
return [list] if list

['']
end
end
Loading