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

#initializeCLI

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



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/sensu-plugins-kubernetes/cli.rb', line 74

def initialize
  super()
  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]
    )
  rescue ArgumentError => e
    critical e.message
  end
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



69
70
71
# File 'lib/sensu-plugins-kubernetes/cli.rb', line 69

def client
  @client
end