Class: Sensu::Plugins::Kubernetes::CLI

Inherits:
Sensu::Plugin::Check::CLI
  • Object
show all
Includes:
Client
Defined in:
lib/sensu-plugins-kubernetes/cli.rb

Overview

Abstract base class for a Sensu check that also provides Kubernetes client connection support.

Constant Summary

Constants included from Client

Sensu::Plugins::Kubernetes::Client::INCLUSTER_CA_FILE, Sensu::Plugins::Kubernetes::Client::INCLUSTER_TOKEN_FILE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Client

#kubeclient

Constructor Details

#initialize(argv = ARGV) ⇒ CLI

Initializes the Sensu check by creating a Kubernetes client from the given options and will report a critical error if those arguments are incorrect.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/sensu-plugins-kubernetes/cli.rb', line 81

def initialize(argv = ARGV)
  super()
  self.argv = parse_options(argv)
  begin
    @client = kubeclient(
      server: config[:api_server],
      version: config[:api_version],
      incluster: config[:api_incluster],
      ca_file: config[:api_ca_file],
      client_cert_file: config[:api_client_cert],
      client_key_file: config[:api_client_key],
      username: config[:api_user],
      password: config[:api_password],
      token: config[:api_token],
      token_file: config[:api_token_file],
      kube_config: config[:kube_config]
    )
  rescue ArgumentError => e
    critical e.message
  end
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



76
77
78
# File 'lib/sensu-plugins-kubernetes/cli.rb', line 76

def client
  @client
end