Class: Rubernetes::Auth::KubeConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/rubernetes/auth/kube_config.rb

Overview

This class is used to read and parse a KUBECONFIG file. It will try to read the KUBECONFIG from ENV first, otherwise it will fallback to ~/.kube/config. It extracts the kube API endpoint and authentication details.

Constant Summary collapse

KUBECONFIG_DEFAULT_PATH =
"#{Dir.home}/.kube/config"

Instance Method Summary collapse

Constructor Details

#initializeKubeConfig

Returns a new instance of KubeConfig.



11
12
13
14
15
# File 'lib/rubernetes/auth/kube_config.rb', line 11

def initialize
  config_path = ENV.fetch('KUBECONFIG', KUBECONFIG_DEFAULT_PATH)
  config = Kubeclient::Config.read(config_path)
  @context = config.context
end

Instance Method Details

#api_endpointObject



17
18
19
# File 'lib/rubernetes/auth/kube_config.rb', line 17

def api_endpoint
  @context.api_endpoint
end

#auth_optionsObject



25
26
27
# File 'lib/rubernetes/auth/kube_config.rb', line 25

def auth_options
  @context.auth_options
end

#ssl_optionsObject



21
22
23
# File 'lib/rubernetes/auth/kube_config.rb', line 21

def ssl_options
  @context.ssl_options
end