resque-kubernetes 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a5d6e3560f6a7393489b6fe7509e0777e2d60b6
4
- data.tar.gz: bf7ea17b439598dc9ac2946138178dc61eaedf42
3
+ metadata.gz: 321b2f65c516afb26286042a67b215dfbf2d44c4
4
+ data.tar.gz: 55b3b5e011fc5b568bae8a4f573a861cdf84ac5a
5
5
  SHA512:
6
- metadata.gz: 0066365884c83d8479316ddbb340e50222496a6eabf7fc75822ad0d9088c92375bd285c5049fb9566d7c6524575ee0786637eb12f53c46de5fdb2262283279ee
7
- data.tar.gz: c339b564294da1834720fe92a916f82c2b05b110c6c32e30882c3eb65883499862215116aa259fe7b84b27d057d578041daf115627be9f377c5edbd3621b439e
6
+ metadata.gz: ab929f4e0dfead17f4da7bc4c56eb83f467989c2a2c7b731bfbb66c1300786044802e5b2adac3b3f08440a1a5f7e8d71a3891727f5d4f61256fd5baa84941668
7
+ data.tar.gz: 0edaf03ca3bb8cc25cfd464105dbf9370232aa8a3525f79694bfc43c2a8c04fa127b1b1811cbae8f04590bf5f1797f6065b1241eac0182c372c766fd6301272c
@@ -29,22 +29,35 @@ module Resque
29
29
 
30
30
  def client(scope)
31
31
  kubeconfig = File.join(ENV["HOME"], ".kube", "config")
32
+ # TODO: Add ability to load this from config
33
+ context = nil
32
34
 
33
35
  if File.exist?("/var/run/secrets/kubernetes.io/serviceaccount/token")
34
- # When running in k8s cluster, use the service account secret token
35
- auth_options = {bearer_token_file: "/var/run/secrets/kubernetes.io/serviceaccount/token"}
36
- @jobs_client = Kubeclient::Client.new("https://localhost:8443/apis/batch" , "v1", auth_options: auth_options)
36
+ # When running in GKE/k8s cluster, use the service account secret token and ca bundle
37
+ context = new Kubeclient::Config::Context(
38
+ "https://kubernetes",
39
+ "v1",
40
+ {ca_file: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"},
41
+ {bearer_token_file: "/var/run/secrets/kubernetes.io/serviceaccount/token"}
42
+ )
37
43
  elsif File.exist?(kubeconfig)
38
- # When running in development, use the config file for `kubectl`
44
+ # When running in development, use the config file for `kubectl` and default application credentials
39
45
  kubeconfig = File.join(ENV["HOME"], ".kube", "config")
40
- config = Kubeclient::Config.read(kubeconfig)
41
- Kubeclient::Client.new(
42
- config.context.api_endpoint + scope,
46
+ config = Kubeclient::Config.read(kubeconfig)
47
+ context = Kubeclient::Config::Context.new(
48
+ config.context.api_endpoint,
43
49
  config.context.api_version,
44
- {
45
- ssl_options: config.context.ssl_options,
46
- auth_options: {use_default_gcp: true}
47
- }
50
+ config.context.ssl_options,
51
+ {use_default_gcp: true}
52
+ )
53
+ end
54
+
55
+ if context
56
+ Kubeclient::Client.new(
57
+ context.api_endpoint + scope,
58
+ context.api_version,
59
+ ssl_options: context.ssl_options,
60
+ auth_options: context.auth_options,
48
61
  )
49
62
  end
50
63
  end
@@ -1,5 +1,5 @@
1
1
  module Resque
2
2
  module Kubernetes
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -8,7 +8,7 @@ module Resque
8
8
  extend Configurable
9
9
 
10
10
  # By default only manage kubernetes jobs in :production
11
- define_setting :environments, [:production]
11
+ define_setting :environments, ["production"]
12
12
 
13
13
  # Limit the number of workers that should be spun up, default 10
14
14
  define_setting :max_workers, 10
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-kubernetes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Wadsack