kubernetes-deploy 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3658ae1e0a4c2163f17843504df7fe4252f7f0ea
|
4
|
+
data.tar.gz: 78b8016923a5cbccda633cb9651e12fe678f2cc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88e9824411a939c1d5c864602a512d4ec420f18984e54138c0cf8bc9edbbc0e82190499b74900bcc624dfd190b6b766e83c78d491f5ca5c9c128c03284cb63bb
|
7
|
+
data.tar.gz: 5d663ab66c6d2fdeb41dbafa4289c129bc43bd8eb68b84d4feba3062bde215133c80f8521dc58b8f43032ac3616dfc13b69edea9f3992a77c7fe3dbd1ded78dc
|
@@ -16,6 +16,7 @@ module KubernetesDeploy
|
|
16
16
|
when 'configmap' then ConfigMap.new(name, namespace, context, file)
|
17
17
|
when 'deployment' then Deployment.new(name, namespace, context, file)
|
18
18
|
when 'pod' then Pod.new(name, namespace, context, file)
|
19
|
+
when 'redis' then Redis.new(name, namespace, context, file)
|
19
20
|
when 'ingress' then Ingress.new(name, namespace, context, file)
|
20
21
|
when 'persistentvolumeclaim' then PersistentVolumeClaim.new(name, namespace, context, file)
|
21
22
|
when 'service' then Service.new(name, namespace, context, file)
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module KubernetesDeploy
|
2
|
+
class Redis < KubernetesResource
|
3
|
+
TIMEOUT = 5.minutes
|
4
|
+
UUID_ANNOTATION = "redis.stable.shopify.io/owner_uid".freeze
|
5
|
+
|
6
|
+
def initialize(name, namespace, context, file)
|
7
|
+
@name, @namespace, @context, @file = name, namespace, context, file
|
8
|
+
end
|
9
|
+
|
10
|
+
def sync
|
11
|
+
_, st = run_kubectl("get", type, @name)
|
12
|
+
@found = st.success?
|
13
|
+
@status = if redis_deployment_exists? && redis_service_exists?
|
14
|
+
"Provisioned"
|
15
|
+
else
|
16
|
+
"Unknown"
|
17
|
+
end
|
18
|
+
|
19
|
+
log_status
|
20
|
+
end
|
21
|
+
|
22
|
+
def deploy_succeeded?
|
23
|
+
redis_deployment_exists? && redis_service_exists?
|
24
|
+
end
|
25
|
+
|
26
|
+
def deploy_failed?
|
27
|
+
false
|
28
|
+
end
|
29
|
+
|
30
|
+
def tpr?
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
def exists?
|
35
|
+
@found
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def redis_deployment_exists?
|
40
|
+
deployment, st = run_kubectl("get", "deployments", "redis-#{redis_resource_uuid}", "-o=json")
|
41
|
+
|
42
|
+
if st.success?
|
43
|
+
parsed = JSON.parse(deployment)
|
44
|
+
|
45
|
+
if parsed.fetch("status", {}).fetch("availableReplicas", -1) == parsed.fetch("status", {}).fetch("replicas", 0)
|
46
|
+
# all redis pods are running
|
47
|
+
return true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
false
|
52
|
+
end
|
53
|
+
|
54
|
+
def redis_service_exists?
|
55
|
+
service, st = run_kubectl("get", "services", "redis-#{redis_resource_uuid}", "-o=json")
|
56
|
+
|
57
|
+
if st.success?
|
58
|
+
parsed = JSON.parse(service)
|
59
|
+
|
60
|
+
if parsed.fetch("spec", {}).fetch("clusterIP", "") != ""
|
61
|
+
return true
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
false
|
66
|
+
end
|
67
|
+
|
68
|
+
def redis_resource_uuid
|
69
|
+
return @redis_resource_uuid if defined?(@redis_resource_uuid) && @redis_resource_uuid
|
70
|
+
|
71
|
+
redis, st = run_kubectl("get", "redises", @name, "-o=json")
|
72
|
+
if st.success?
|
73
|
+
parsed = JSON.parse(redis)
|
74
|
+
|
75
|
+
@redis_resource_uuid = parsed.fetch("metadata", {}).fetch("uid", nil)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -13,6 +13,7 @@ require 'kubernetes-deploy/kubernetes_resource'
|
|
13
13
|
ingress
|
14
14
|
persistent_volume_claim
|
15
15
|
pod
|
16
|
+
redis
|
16
17
|
service
|
17
18
|
).each do |subresource|
|
18
19
|
require "kubernetes-deploy/kubernetes_resource/#{subresource}"
|
@@ -22,6 +23,7 @@ module KubernetesDeploy
|
|
22
23
|
class Runner
|
23
24
|
PREDEPLOY_SEQUENCE = %w(
|
24
25
|
Cloudsql
|
26
|
+
Redis
|
25
27
|
ConfigMap
|
26
28
|
PersistentVolumeClaim
|
27
29
|
Pod
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubernetes-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kir Shatrov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-02-
|
13
|
+
date: 2017-02-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- lib/kubernetes-deploy/kubernetes_resource/ingress.rb
|
94
94
|
- lib/kubernetes-deploy/kubernetes_resource/persistent_volume_claim.rb
|
95
95
|
- lib/kubernetes-deploy/kubernetes_resource/pod.rb
|
96
|
+
- lib/kubernetes-deploy/kubernetes_resource/redis.rb
|
96
97
|
- lib/kubernetes-deploy/kubernetes_resource/service.rb
|
97
98
|
- lib/kubernetes-deploy/runner.rb
|
98
99
|
- lib/kubernetes-deploy/version.rb
|