resque-kubernetes 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/resque/kubernetes/job.rb +24 -11
- data/lib/resque/kubernetes/version.rb +1 -1
- data/lib/resque/kubernetes.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 321b2f65c516afb26286042a67b215dfbf2d44c4
|
4
|
+
data.tar.gz: 55b3b5e011fc5b568bae8a4f573a861cdf84ac5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
36
|
-
|
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
|
41
|
-
Kubeclient::
|
42
|
-
config.context.api_endpoint
|
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
|
-
|
46
|
-
|
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
|
data/lib/resque/kubernetes.rb
CHANGED
@@ -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, [
|
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
|