class Resque::Kubernetes::Context::Kubectl

Kubeclient Context from `kubectl` config file.

Public Instance Methods

applicable?() click to toggle source
# File lib/resque/kubernetes/context/kubectl.rb, line 8
def applicable?
  File.exist?(kubeconfig)
end
context() click to toggle source
# File lib/resque/kubernetes/context/kubectl.rb, line 12
def context
  config = Kubeclient::Config.read(kubeconfig)

  Resque::Kubernetes::ContextFactory::Context.new(
      config.context.api_endpoint,
      config.context.api_version,
      config.context.namespace,
      auth_options: auth_options(config),
      ssl_options:  config.context.ssl_options
  )
end

Private Instance Methods

auth_options(config) click to toggle source
# File lib/resque/kubernetes/context/kubectl.rb, line 30
def auth_options(config)
  options = config.context.auth_options
  return options unless options.empty?
  google_application_default_credentials
end
google_application_default_credentials() click to toggle source
# File lib/resque/kubernetes/context/kubectl.rb, line 36
def google_application_default_credentials
  return unless defined?(Google) && defined?(Google::Auth)
  {bearer_token: Kubeclient::GoogleApplicationDefaultCredentials.token}
end
kubeconfig() click to toggle source
# File lib/resque/kubernetes/context/kubectl.rb, line 26
def kubeconfig
  File.join(ENV["HOME"], ".kube", "config")
end