Class: CronKubernetes::Context::WellKnown

Inherits:
Object
  • Object
show all
Defined in:
lib/cron_kubernetes/context/well_known.rb

Overview

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

Constant Summary collapse

TOKEN_FILE =
"/var/run/secrets/kubernetes.io/serviceaccount/token"
CA_FILE =
"/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
NAMESPACE_FILE =
"/var/run/secrets/kubernetes.io/serviceaccount/namespace"

Instance Method Summary collapse

Instance Method Details

#applicable?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/cron_kubernetes/context/well_known.rb', line 11

def applicable?
  File.exist?(TOKEN_FILE)
end

#contextObject



15
16
17
18
19
20
21
22
23
# File 'lib/cron_kubernetes/context/well_known.rb', line 15

def context
  CronKubernetes::KubeclientContext::Context.new(
    "https://kubernetes.default.svc",
    "v1",
    namespace,
    auth_options: {bearer_token_file: TOKEN_FILE},
    ssl_options:
  )
end