class Resque::Kubernetes::Context::WellKnown

Kubeclient Context from well-known locations within a Kubernetes cluster.

Constants

CA_FILE
NAMESPACE_FILE
TOKEN_FILE

Public Instance Methods

applicable?() click to toggle source
# File lib/resque/kubernetes/context/well_known.rb, line 12
def applicable?
  File.exist?(TOKEN_FILE)
end
context() click to toggle source
# File lib/resque/kubernetes/context/well_known.rb, line 16
def context
  Resque::Kubernetes::ContextFactory::Context.new(
      "https://kubernetes.default.svc",
      "v1",
      namespace,
      auth_options: {bearer_token_file: TOKEN_FILE},
      ssl_options:  ssl_options
  )
end

Private Instance Methods

namespace() click to toggle source
# File lib/resque/kubernetes/context/well_known.rb, line 28
def namespace
  return nil unless File.exist?(NAMESPACE_FILE)
  File.read(NAMESPACE_FILE)
end
ssl_options() click to toggle source
# File lib/resque/kubernetes/context/well_known.rb, line 33
def ssl_options
  return {} unless File.exist?(CA_FILE)
  {ca_file: CA_FILE}
end