Class: Resque::Kubernetes::ContextFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/resque/kubernetes/context_factory.rb

Overview

Create a context for ‘Kubeclient` depending on the environment.

Class Method Summary collapse

Class Method Details

.contextObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/resque/kubernetes/context_factory.rb', line 10

def context
  # TODO: Add ability to load this from config

  if File.exist?("/var/run/secrets/kubernetes.io/serviceaccount/token")
    # When running in GKE/k8s cluster, use the service account secret token and ca bundle
    well_known_context
  elsif File.exist?(kubeconfig)
    # When running in development, use the config file for `kubectl` and default application credentials
    kubectl_context
  end
end