rhea 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +165 -2
- data/app/assets/javascripts/rhea/application.js +2 -0
- data/app/assets/javascripts/rhea/main.js +3 -0
- data/app/assets/javascripts/vendor/jquery-1.11.3.js +10351 -0
- data/app/assets/stylesheets/rhea/application.css.sass +1 -0
- data/app/assets/stylesheets/rhea/layout.css.sass +31 -0
- data/app/controllers/rhea/base_controller.rb +26 -0
- data/app/controllers/rhea/commands_controller.rb +168 -0
- data/app/controllers/rhea/events_controller.rb +8 -0
- data/app/controllers/rhea/nodes_controller.rb +7 -0
- data/app/controllers/rhea/system_services_controller.rb +7 -0
- data/app/helpers/rhea/helper.rb +42 -0
- data/app/views/rhea/command_types/_list.html.haml +5 -0
- data/app/views/rhea/commands/_form.html.haml +22 -0
- data/app/views/rhea/commands/_table.html.haml +51 -0
- data/app/views/rhea/commands/index.html.haml +51 -0
- data/app/views/rhea/errors/index.html.haml +2 -0
- data/app/views/rhea/events/index.html.haml +24 -0
- data/app/views/rhea/layouts/application.html.haml +35 -0
- data/app/views/rhea/nodes/index.html.haml +29 -0
- data/app/views/rhea/system_services/index.html.haml +2 -0
- data/config/routes.rb +21 -0
- data/docs/commands.gif +0 -0
- data/docs/commands.mov +0 -0
- data/docs/events.png +0 -0
- data/docs/logo.png +0 -0
- data/docs/nodes.png +0 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_All/_perform/an_existing_rc/returns_the_rc.yml +197 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Delete/_perform/an_existing_rc/deletes_the_rc.yml +163 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Export/_perform/an_existing_rc/returns_the_data.yml +197 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Get/_perform/an_existing_rc/gets_the_rc.yml +196 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Import/_perform/no_existing_rcs/creates_the_rcs.yml +197 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Redeploy/_perform/an_existing_rc/redeploys_the_rc.yml +424 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Reschedule/_perform/an_existing_rc/reschedules_the_rc.yml +421 -0
- data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Scale/_perform/no_existing_rc/creates_an_rc.yml +165 -0
- data/lib/rhea.rb +15 -1
- data/lib/rhea/command.rb +35 -0
- data/lib/rhea/command_type.rb +35 -0
- data/lib/rhea/engine.rb +16 -0
- data/lib/rhea/kubernetes.rb +5 -0
- data/lib/rhea/kubernetes/api.rb +15 -0
- data/lib/rhea/kubernetes/commands/all.rb +16 -0
- data/lib/rhea/kubernetes/commands/base.rb +28 -0
- data/lib/rhea/kubernetes/commands/delete.rb +18 -0
- data/lib/rhea/kubernetes/commands/export.rb +23 -0
- data/lib/rhea/kubernetes/commands/get.rb +18 -0
- data/lib/rhea/kubernetes/commands/import.rb +20 -0
- data/lib/rhea/kubernetes/commands/redeploy.rb +22 -0
- data/lib/rhea/kubernetes/commands/reschedule.rb +21 -0
- data/lib/rhea/kubernetes/commands/scale.rb +108 -0
- data/lib/rhea/kubernetes/configuration.rb +30 -0
- data/lib/rhea/kubernetes/events/recent.rb +23 -0
- data/lib/rhea/kubernetes/nodes/all.rb +45 -0
- data/lib/rhea/kubernetes/system_services.rb +22 -0
- data/lib/rhea/version.rb +1 -1
- data/rhea.gemspec +11 -3
- data/spec/lib/rhea/kubernetes/commands/all_spec.rb +29 -0
- data/spec/lib/rhea/kubernetes/commands/delete_spec.rb +22 -0
- data/spec/lib/rhea/kubernetes/commands/export_spec.rb +31 -0
- data/spec/lib/rhea/kubernetes/commands/get_spec.rb +28 -0
- data/spec/lib/rhea/kubernetes/commands/import_spec.rb +39 -0
- data/spec/lib/rhea/kubernetes/commands/redeploy_spec.rb +35 -0
- data/spec/lib/rhea/kubernetes/commands/reschedule_spec.rb +32 -0
- data/spec/lib/rhea/kubernetes/commands/scale_spec.rb +31 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/kubernetes_spec_helper.rb +43 -0
- data/spec/support/vcr.rb +9 -0
- metadata +170 -11
data/fixtures/vcr_cassettes/Rhea_Kubernetes_Commands_Scale/_perform/no_existing_rc/creates_an_rc.yml
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://vagrant:vagrant@kube.local/api/v1/replicationcontrollers?labelSelector=name=rhea-7370-foo-bar
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- "*/*; q=0.5, application/xml"
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Content-Type:
|
22
|
+
- application/json
|
23
|
+
Date:
|
24
|
+
- Thu, 12 Nov 2015 19:03:23 GMT
|
25
|
+
Content-Length:
|
26
|
+
- '147'
|
27
|
+
body:
|
28
|
+
encoding: UTF-8
|
29
|
+
string: '{"kind":"ReplicationControllerList","apiVersion":"v1","metadata":{"selfLink":"/api/v1/replicationcontrollers","resourceVersion":"1647"},"items":[]}'
|
30
|
+
http_version:
|
31
|
+
recorded_at: Thu, 12 Nov 2015 19:03:23 GMT
|
32
|
+
- request:
|
33
|
+
method: post
|
34
|
+
uri: https://vagrant:vagrant@kube.local/api/v1/namespaces/default/replicationcontrollers
|
35
|
+
body:
|
36
|
+
encoding: UTF-8
|
37
|
+
string: '{"metadata":{"name":"rhea-7370-foo-bar","namespace":"default","labels":{"name":"rhea-7370-foo-bar"},"annotations":{"rhea_command":"foo
|
38
|
+
-bar"}},"spec":{"replicas":2,"selector":{"name":"rhea-7370-foo-bar"},"template":{"metadata":{"labels":{"name":"rhea-7370-foo-bar"},"annotations":{"rhea_command":"foo
|
39
|
+
-bar"}},"spec":{"containers":[{"name":"rhea-7370-foo-bar","image":"docker.local/myimage:latest","env":[{"name":"MY_ENV_VAR_NAME","value":"my_env_var_value"}],"command":["foo","-bar"]}]}}},"kind":"ReplicationController","apiVersion":"v1"}'
|
40
|
+
headers:
|
41
|
+
Accept:
|
42
|
+
- "*/*; q=0.5, application/xml"
|
43
|
+
Accept-Encoding:
|
44
|
+
- gzip, deflate
|
45
|
+
Content-Length:
|
46
|
+
- '526'
|
47
|
+
User-Agent:
|
48
|
+
- Ruby
|
49
|
+
response:
|
50
|
+
status:
|
51
|
+
code: 201
|
52
|
+
message: Created
|
53
|
+
headers:
|
54
|
+
Content-Type:
|
55
|
+
- application/json
|
56
|
+
Date:
|
57
|
+
- Thu, 12 Nov 2015 19:03:28 GMT
|
58
|
+
Content-Length:
|
59
|
+
- '961'
|
60
|
+
body:
|
61
|
+
encoding: UTF-8
|
62
|
+
string: '{"kind":"ReplicationController","apiVersion":"v1","metadata":{"name":"rhea-7370-foo-bar","namespace":"default","selfLink":"/api/v1/namespaces/default/replicationcontrollers/rhea-7370-foo-bar","uid":"0ef4994d-8970-11e5-8c9b-0800279dd272","resourceVersion":"1649","generation":1,"creationTimestamp":"2015-11-12T19:03:28Z","labels":{"name":"rhea-7370-foo-bar"},"annotations":{"rhea_command":"foo
|
63
|
+
-bar"}},"spec":{"replicas":2,"selector":{"name":"rhea-7370-foo-bar"},"template":{"metadata":{"creationTimestamp":null,"labels":{"name":"rhea-7370-foo-bar"},"annotations":{"rhea_command":"foo
|
64
|
+
-bar"}},"spec":{"containers":[{"name":"rhea-7370-foo-bar","image":"docker.local/myimage:latest","command":["foo","-bar"],"env":[{"name":"MY_ENV_VAR_NAME","value":"my_env_var_value"}],"resources":{},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"Always"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst"}}},"status":{"replicas":0}}'
|
65
|
+
http_version:
|
66
|
+
recorded_at: Thu, 12 Nov 2015 19:03:28 GMT
|
67
|
+
- request:
|
68
|
+
method: get
|
69
|
+
uri: https://vagrant:vagrant@kube.local/api/v1/replicationcontrollers
|
70
|
+
body:
|
71
|
+
encoding: US-ASCII
|
72
|
+
string: ''
|
73
|
+
headers:
|
74
|
+
Accept:
|
75
|
+
- "*/*; q=0.5, application/xml"
|
76
|
+
Accept-Encoding:
|
77
|
+
- gzip, deflate
|
78
|
+
User-Agent:
|
79
|
+
- Ruby
|
80
|
+
response:
|
81
|
+
status:
|
82
|
+
code: 200
|
83
|
+
message: OK
|
84
|
+
headers:
|
85
|
+
Content-Type:
|
86
|
+
- application/json
|
87
|
+
Date:
|
88
|
+
- Thu, 12 Nov 2015 19:03:33 GMT
|
89
|
+
Transfer-Encoding:
|
90
|
+
- chunked
|
91
|
+
body:
|
92
|
+
encoding: UTF-8
|
93
|
+
string: '{"kind":"ReplicationControllerList","apiVersion":"v1","metadata":{"selfLink":"/api/v1/replicationcontrollers","resourceVersion":"1673"},"items":[{"metadata":{"name":"rhea-7370-foo-bar","namespace":"default","selfLink":"/api/v1/namespaces/default/replicationcontrollers/rhea-7370-foo-bar","uid":"0ef4994d-8970-11e5-8c9b-0800279dd272","resourceVersion":"1658","generation":1,"creationTimestamp":"2015-11-12T19:03:28Z","labels":{"name":"rhea-7370-foo-bar"},"annotations":{"rhea_command":"foo
|
94
|
+
-bar"}},"spec":{"replicas":2,"selector":{"name":"rhea-7370-foo-bar"},"template":{"metadata":{"creationTimestamp":null,"labels":{"name":"rhea-7370-foo-bar"},"annotations":{"rhea_command":"foo
|
95
|
+
-bar"}},"spec":{"containers":[{"name":"rhea-7370-foo-bar","image":"docker.local/myimage:latest","command":["foo","-bar"],"env":[{"name":"MY_ENV_VAR_NAME","value":"my_env_var_value"}],"resources":{},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"Always"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst"}}},"status":{"replicas":2,"observedGeneration":1}},{"metadata":{"name":"kube-dns-v8","namespace":"kube-system","selfLink":"/api/v1/namespaces/kube-system/replicationcontrollers/kube-dns-v8","uid":"e97525d7-8967-11e5-8c9b-0800279dd272","resourceVersion":"63","generation":1,"creationTimestamp":"2015-11-12T18:05:09Z","labels":{"k8s-app":"kube-dns","kubernetes.io/cluster-service":"true","version":"v8"}},"spec":{"replicas":1,"selector":{"k8s-app":"kube-dns","version":"v8"},"template":{"metadata":{"creationTimestamp":null,"labels":{"k8s-app":"kube-dns","kubernetes.io/cluster-service":"true","version":"v8"}},"spec":{"volumes":[{"name":"etcd-storage","emptyDir":{}}],"containers":[{"name":"etcd","image":"gcr.io/google_containers/etcd:2.0.9","command":["/usr/local/bin/etcd","-data-dir","/var/etcd/data","-listen-client-urls","http://127.0.0.1:2379,http://127.0.0.1:4001","-advertise-client-urls","http://127.0.0.1:2379,http://127.0.0.1:4001","-initial-cluster-token","skydns-etcd"],"resources":{"limits":{"cpu":"100m","memory":"50Mi"},"requests":{"cpu":"100m","memory":"50Mi"}},"volumeMounts":[{"name":"etcd-storage","mountPath":"/var/etcd/data"}],"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"},{"name":"kube2sky","image":"gcr.io/google_containers/kube2sky:1.11","args":["-domain=cluster.local"],"resources":{"limits":{"cpu":"100m","memory":"50Mi"},"requests":{"cpu":"100m","memory":"50Mi"}},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"},{"name":"skydns","image":"gcr.io/google_containers/skydns:2015-03-11-001","args":["-machines=http://localhost:4001","-addr=0.0.0.0:53","-domain=cluster.local."],"ports":[{"name":"dns","containerPort":53,"protocol":"UDP"},{"name":"dns-tcp","containerPort":53,"protocol":"TCP"}],"resources":{"limits":{"cpu":"100m","memory":"50Mi"},"requests":{"cpu":"100m","memory":"50Mi"}},"livenessProbe":{"httpGet":{"path":"/healthz","port":8080,"scheme":"HTTP"},"initialDelaySeconds":30,"timeoutSeconds":5},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"},{"name":"healthz","image":"gcr.io/google_containers/exechealthz:1.0","args":["-cmd=nslookup
|
96
|
+
kubernetes.default.svc.cluster.local localhost \u003e/dev/null","-port=8080"],"ports":[{"containerPort":8080,"protocol":"TCP"}],"resources":{"limits":{"cpu":"10m","memory":"20Mi"},"requests":{"cpu":"10m","memory":"20Mi"}},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"Default"}}},"status":{"replicas":1,"observedGeneration":1}},{"metadata":{"name":"kube-ui-v1","namespace":"kube-system","selfLink":"/api/v1/namespaces/kube-system/replicationcontrollers/kube-ui-v1","uid":"e962afd4-8967-11e5-8c9b-0800279dd272","resourceVersion":"58","generation":1,"creationTimestamp":"2015-11-12T18:05:09Z","labels":{"k8s-app":"kube-ui","kubernetes.io/cluster-service":"true","version":"v1"}},"spec":{"replicas":1,"selector":{"k8s-app":"kube-ui","version":"v1"},"template":{"metadata":{"creationTimestamp":null,"labels":{"k8s-app":"kube-ui","kubernetes.io/cluster-service":"true","version":"v1"}},"spec":{"containers":[{"name":"kube-ui","image":"gcr.io/google_containers/kube-ui:v1.1","ports":[{"containerPort":8080,"protocol":"TCP"}],"resources":{"limits":{"cpu":"100m","memory":"50Mi"},"requests":{"cpu":"100m","memory":"50Mi"}},"livenessProbe":{"httpGet":{"path":"/","port":8080,"scheme":"HTTP"},"initialDelaySeconds":30,"timeoutSeconds":5},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst"}}},"status":{"replicas":1,"observedGeneration":1}},{"metadata":{"name":"monitoring-heapster-v8","namespace":"kube-system","selfLink":"/api/v1/namespaces/kube-system/replicationcontrollers/monitoring-heapster-v8","uid":"e9614810-8967-11e5-8c9b-0800279dd272","resourceVersion":"49","generation":1,"creationTimestamp":"2015-11-12T18:05:09Z","labels":{"k8s-app":"heapster","kubernetes.io/cluster-service":"true","version":"v8"}},"spec":{"replicas":1,"selector":{"k8s-app":"heapster","version":"v8"},"template":{"metadata":{"creationTimestamp":null,"labels":{"k8s-app":"heapster","kubernetes.io/cluster-service":"true","version":"v8"}},"spec":{"containers":[{"name":"heapster","image":"gcr.io/google_containers/heapster:v0.17.0","command":["/heapster","--source=kubernetes:''''","--sink=influxdb:http://monitoring-influxdb:8086"],"resources":{"limits":{"cpu":"100m","memory":"300Mi"},"requests":{"cpu":"100m","memory":"300Mi"}},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst"}}},"status":{"replicas":1,"observedGeneration":1}},{"metadata":{"name":"monitoring-influx-grafana-v1","namespace":"kube-system","selfLink":"/api/v1/namespaces/kube-system/replicationcontrollers/monitoring-influx-grafana-v1","uid":"e9749ef6-8967-11e5-8c9b-0800279dd272","resourceVersion":"62","generation":1,"creationTimestamp":"2015-11-12T18:05:09Z","labels":{"k8s-app":"influxGrafana","kubernetes.io/cluster-service":"true","version":"v1"}},"spec":{"replicas":1,"selector":{"k8s-app":"influxGrafana","version":"v1"},"template":{"metadata":{"creationTimestamp":null,"labels":{"k8s-app":"influxGrafana","kubernetes.io/cluster-service":"true","version":"v1"}},"spec":{"volumes":[{"name":"influxdb-persistent-storage","emptyDir":{}}],"containers":[{"name":"influxdb","image":"gcr.io/google_containers/heapster_influxdb:v0.3","ports":[{"hostPort":8083,"containerPort":8083,"protocol":"TCP"},{"hostPort":8086,"containerPort":8086,"protocol":"TCP"}],"resources":{"limits":{"cpu":"100m","memory":"200Mi"},"requests":{"cpu":"100m","memory":"200Mi"}},"volumeMounts":[{"name":"influxdb-persistent-storage","mountPath":"/data"}],"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"},{"name":"grafana","image":"gcr.io/google_containers/heapster_grafana:v0.7","env":[{"name":"INFLUXDB_EXTERNAL_URL","value":"/api/v1/proxy/namespaces/kube-system/services/monitoring-influxdb:api/db/"},{"name":"INFLUXDB_HOST","value":"monitoring-influxdb"},{"name":"INFLUXDB_PORT","value":"8086"}],"resources":{"limits":{"cpu":"100m","memory":"100Mi"},"requests":{"cpu":"100m","memory":"100Mi"}},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst"}}},"status":{"replicas":1,"observedGeneration":1}}]}'
|
97
|
+
http_version:
|
98
|
+
recorded_at: Thu, 12 Nov 2015 19:03:33 GMT
|
99
|
+
- request:
|
100
|
+
method: delete
|
101
|
+
uri: https://vagrant:vagrant@kube.local/api/v1/namespaces/default/replicationcontrollers/rhea-7370-foo-bar
|
102
|
+
body:
|
103
|
+
encoding: US-ASCII
|
104
|
+
string: ''
|
105
|
+
headers:
|
106
|
+
Accept:
|
107
|
+
- "*/*; q=0.5, application/xml"
|
108
|
+
Accept-Encoding:
|
109
|
+
- gzip, deflate
|
110
|
+
User-Agent:
|
111
|
+
- Ruby
|
112
|
+
response:
|
113
|
+
status:
|
114
|
+
code: 200
|
115
|
+
message: OK
|
116
|
+
headers:
|
117
|
+
Content-Type:
|
118
|
+
- application/json
|
119
|
+
Date:
|
120
|
+
- Thu, 12 Nov 2015 19:03:38 GMT
|
121
|
+
Content-Length:
|
122
|
+
- '100'
|
123
|
+
body:
|
124
|
+
encoding: UTF-8
|
125
|
+
string: |-
|
126
|
+
{
|
127
|
+
"kind": "Status",
|
128
|
+
"apiVersion": "v1",
|
129
|
+
"metadata": {},
|
130
|
+
"status": "Success",
|
131
|
+
"code": 200
|
132
|
+
}
|
133
|
+
http_version:
|
134
|
+
recorded_at: Thu, 12 Nov 2015 19:03:38 GMT
|
135
|
+
- request:
|
136
|
+
method: get
|
137
|
+
uri: https://vagrant:vagrant@kube.local/api/v1/replicationcontrollers
|
138
|
+
body:
|
139
|
+
encoding: US-ASCII
|
140
|
+
string: ''
|
141
|
+
headers:
|
142
|
+
Accept:
|
143
|
+
- "*/*; q=0.5, application/xml"
|
144
|
+
Accept-Encoding:
|
145
|
+
- gzip, deflate
|
146
|
+
User-Agent:
|
147
|
+
- Ruby
|
148
|
+
response:
|
149
|
+
status:
|
150
|
+
code: 200
|
151
|
+
message: OK
|
152
|
+
headers:
|
153
|
+
Content-Type:
|
154
|
+
- application/json
|
155
|
+
Date:
|
156
|
+
- Thu, 12 Nov 2015 19:06:53 GMT
|
157
|
+
Transfer-Encoding:
|
158
|
+
- chunked
|
159
|
+
body:
|
160
|
+
encoding: UTF-8
|
161
|
+
string: '{"kind":"ReplicationControllerList","apiVersion":"v1","metadata":{"selfLink":"/api/v1/replicationcontrollers","resourceVersion":"1835"},"items":[{"metadata":{"name":"kube-dns-v8","namespace":"kube-system","selfLink":"/api/v1/namespaces/kube-system/replicationcontrollers/kube-dns-v8","uid":"e97525d7-8967-11e5-8c9b-0800279dd272","resourceVersion":"63","generation":1,"creationTimestamp":"2015-11-12T18:05:09Z","labels":{"k8s-app":"kube-dns","kubernetes.io/cluster-service":"true","version":"v8"}},"spec":{"replicas":1,"selector":{"k8s-app":"kube-dns","version":"v8"},"template":{"metadata":{"creationTimestamp":null,"labels":{"k8s-app":"kube-dns","kubernetes.io/cluster-service":"true","version":"v8"}},"spec":{"volumes":[{"name":"etcd-storage","emptyDir":{}}],"containers":[{"name":"etcd","image":"gcr.io/google_containers/etcd:2.0.9","command":["/usr/local/bin/etcd","-data-dir","/var/etcd/data","-listen-client-urls","http://127.0.0.1:2379,http://127.0.0.1:4001","-advertise-client-urls","http://127.0.0.1:2379,http://127.0.0.1:4001","-initial-cluster-token","skydns-etcd"],"resources":{"limits":{"cpu":"100m","memory":"50Mi"},"requests":{"cpu":"100m","memory":"50Mi"}},"volumeMounts":[{"name":"etcd-storage","mountPath":"/var/etcd/data"}],"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"},{"name":"kube2sky","image":"gcr.io/google_containers/kube2sky:1.11","args":["-domain=cluster.local"],"resources":{"limits":{"cpu":"100m","memory":"50Mi"},"requests":{"cpu":"100m","memory":"50Mi"}},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"},{"name":"skydns","image":"gcr.io/google_containers/skydns:2015-03-11-001","args":["-machines=http://localhost:4001","-addr=0.0.0.0:53","-domain=cluster.local."],"ports":[{"name":"dns","containerPort":53,"protocol":"UDP"},{"name":"dns-tcp","containerPort":53,"protocol":"TCP"}],"resources":{"limits":{"cpu":"100m","memory":"50Mi"},"requests":{"cpu":"100m","memory":"50Mi"}},"livenessProbe":{"httpGet":{"path":"/healthz","port":8080,"scheme":"HTTP"},"initialDelaySeconds":30,"timeoutSeconds":5},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"},{"name":"healthz","image":"gcr.io/google_containers/exechealthz:1.0","args":["-cmd=nslookup
|
162
|
+
kubernetes.default.svc.cluster.local localhost \u003e/dev/null","-port=8080"],"ports":[{"containerPort":8080,"protocol":"TCP"}],"resources":{"limits":{"cpu":"10m","memory":"20Mi"},"requests":{"cpu":"10m","memory":"20Mi"}},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"Default"}}},"status":{"replicas":1,"observedGeneration":1}},{"metadata":{"name":"kube-ui-v1","namespace":"kube-system","selfLink":"/api/v1/namespaces/kube-system/replicationcontrollers/kube-ui-v1","uid":"e962afd4-8967-11e5-8c9b-0800279dd272","resourceVersion":"58","generation":1,"creationTimestamp":"2015-11-12T18:05:09Z","labels":{"k8s-app":"kube-ui","kubernetes.io/cluster-service":"true","version":"v1"}},"spec":{"replicas":1,"selector":{"k8s-app":"kube-ui","version":"v1"},"template":{"metadata":{"creationTimestamp":null,"labels":{"k8s-app":"kube-ui","kubernetes.io/cluster-service":"true","version":"v1"}},"spec":{"containers":[{"name":"kube-ui","image":"gcr.io/google_containers/kube-ui:v1.1","ports":[{"containerPort":8080,"protocol":"TCP"}],"resources":{"limits":{"cpu":"100m","memory":"50Mi"},"requests":{"cpu":"100m","memory":"50Mi"}},"livenessProbe":{"httpGet":{"path":"/","port":8080,"scheme":"HTTP"},"initialDelaySeconds":30,"timeoutSeconds":5},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst"}}},"status":{"replicas":1,"observedGeneration":1}},{"metadata":{"name":"monitoring-heapster-v8","namespace":"kube-system","selfLink":"/api/v1/namespaces/kube-system/replicationcontrollers/monitoring-heapster-v8","uid":"e9614810-8967-11e5-8c9b-0800279dd272","resourceVersion":"49","generation":1,"creationTimestamp":"2015-11-12T18:05:09Z","labels":{"k8s-app":"heapster","kubernetes.io/cluster-service":"true","version":"v8"}},"spec":{"replicas":1,"selector":{"k8s-app":"heapster","version":"v8"},"template":{"metadata":{"creationTimestamp":null,"labels":{"k8s-app":"heapster","kubernetes.io/cluster-service":"true","version":"v8"}},"spec":{"containers":[{"name":"heapster","image":"gcr.io/google_containers/heapster:v0.17.0","command":["/heapster","--source=kubernetes:''''","--sink=influxdb:http://monitoring-influxdb:8086"],"resources":{"limits":{"cpu":"100m","memory":"300Mi"},"requests":{"cpu":"100m","memory":"300Mi"}},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst"}}},"status":{"replicas":1,"observedGeneration":1}},{"metadata":{"name":"monitoring-influx-grafana-v1","namespace":"kube-system","selfLink":"/api/v1/namespaces/kube-system/replicationcontrollers/monitoring-influx-grafana-v1","uid":"e9749ef6-8967-11e5-8c9b-0800279dd272","resourceVersion":"62","generation":1,"creationTimestamp":"2015-11-12T18:05:09Z","labels":{"k8s-app":"influxGrafana","kubernetes.io/cluster-service":"true","version":"v1"}},"spec":{"replicas":1,"selector":{"k8s-app":"influxGrafana","version":"v1"},"template":{"metadata":{"creationTimestamp":null,"labels":{"k8s-app":"influxGrafana","kubernetes.io/cluster-service":"true","version":"v1"}},"spec":{"volumes":[{"name":"influxdb-persistent-storage","emptyDir":{}}],"containers":[{"name":"influxdb","image":"gcr.io/google_containers/heapster_influxdb:v0.3","ports":[{"hostPort":8083,"containerPort":8083,"protocol":"TCP"},{"hostPort":8086,"containerPort":8086,"protocol":"TCP"}],"resources":{"limits":{"cpu":"100m","memory":"200Mi"},"requests":{"cpu":"100m","memory":"200Mi"}},"volumeMounts":[{"name":"influxdb-persistent-storage","mountPath":"/data"}],"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"},{"name":"grafana","image":"gcr.io/google_containers/heapster_grafana:v0.7","env":[{"name":"INFLUXDB_EXTERNAL_URL","value":"/api/v1/proxy/namespaces/kube-system/services/monitoring-influxdb:api/db/"},{"name":"INFLUXDB_HOST","value":"monitoring-influxdb"},{"name":"INFLUXDB_PORT","value":"8086"}],"resources":{"limits":{"cpu":"100m","memory":"100Mi"},"requests":{"cpu":"100m","memory":"100Mi"}},"terminationMessagePath":"/dev/termination-log","imagePullPolicy":"IfNotPresent"}],"restartPolicy":"Always","terminationGracePeriodSeconds":30,"dnsPolicy":"ClusterFirst"}}},"status":{"replicas":1,"observedGeneration":1}}]}'
|
163
|
+
http_version:
|
164
|
+
recorded_at: Thu, 12 Nov 2015 19:06:53 GMT
|
165
|
+
recorded_with: VCR 2.9.3
|
data/lib/rhea.rb
CHANGED
@@ -1,5 +1,19 @@
|
|
1
|
+
require 'kaminari'
|
2
|
+
require 'kubeclient'
|
3
|
+
require 'ostruct'
|
4
|
+
|
1
5
|
directory = File.dirname(File.absolute_path(__FILE__))
|
2
|
-
|
6
|
+
require "#{directory}/rhea/kubernetes/commands/base"
|
7
|
+
Dir.glob("#{directory}/rhea/**/*.rb") { |file| require file }
|
3
8
|
|
4
9
|
module Rhea
|
10
|
+
module_function
|
11
|
+
|
12
|
+
def self.configure
|
13
|
+
yield(configuration) if block_given?
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.configuration
|
17
|
+
@configuration ||= Configuration.new
|
18
|
+
end
|
5
19
|
end
|
data/lib/rhea/command.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Rhea
|
2
|
+
class Command
|
3
|
+
attr_accessor :expression, :image, :process_count, :created_at
|
4
|
+
|
5
|
+
KEY_PREFIX = 'rhea-'
|
6
|
+
IMAGE_EXPRESSION_SEPARATOR = '____'
|
7
|
+
|
8
|
+
def initialize(expression:, image: nil, process_count: nil, created_at: nil)
|
9
|
+
self.expression = expression
|
10
|
+
self.image = image || Rhea.configuration.default_image
|
11
|
+
self.process_count = process_count
|
12
|
+
self.created_at = created_at
|
13
|
+
end
|
14
|
+
|
15
|
+
def attributes
|
16
|
+
{
|
17
|
+
expression: expression,
|
18
|
+
image: image,
|
19
|
+
process_count: process_count,
|
20
|
+
created_at: created_at
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def key
|
25
|
+
command_hash = Digest::MD5.hexdigest("#{image}#{expression}")[0..3]
|
26
|
+
command_for_host = expression.downcase.gsub(/[^-a-z0-9]+/i, '-').squeeze('-')
|
27
|
+
key = "#{KEY_PREFIX}#{command_hash}-#{command_for_host}"
|
28
|
+
max_host_name_length = 62
|
29
|
+
key = key[0,max_host_name_length]
|
30
|
+
# The key can't end with a '-'
|
31
|
+
key.gsub!(/\-+$/, '')
|
32
|
+
key
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Rhea
|
2
|
+
class CommandType
|
3
|
+
attr_accessor :key, :name, :format
|
4
|
+
|
5
|
+
def initialize(key:, name:, format:)
|
6
|
+
self.key = key
|
7
|
+
self.name = name
|
8
|
+
self.format = format
|
9
|
+
end
|
10
|
+
|
11
|
+
def input_to_command_expression(input)
|
12
|
+
format.gsub('$INPUT', input)
|
13
|
+
end
|
14
|
+
|
15
|
+
def displayed_format
|
16
|
+
format.gsub('$INPUT', '$input')
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.all
|
20
|
+
@all ||= Rhea.configuration.command_types.map do |attributes|
|
21
|
+
new(attributes)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.find(key)
|
26
|
+
command_type = all.find { |command_type| command_type.key == key }
|
27
|
+
raise "Invalid key: #{key}" unless command_type
|
28
|
+
command_type
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.options_for_select
|
32
|
+
all.map { |command_type| [command_type.name, command_type.key] }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/rhea/engine.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'haml'
|
2
|
+
require 'sass-rails'
|
3
|
+
|
4
|
+
module Rhea
|
5
|
+
class Engine < ::Rails::Engine
|
6
|
+
isolate_namespace Rhea
|
7
|
+
|
8
|
+
initializer "rhea.asset_pipeline" do |app|
|
9
|
+
app.config.assets.precompile << 'rhea/application.js'
|
10
|
+
end
|
11
|
+
|
12
|
+
config.generators do |g|
|
13
|
+
g.test_framework :rspec
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Rhea
|
2
|
+
module Kubernetes
|
3
|
+
class Api
|
4
|
+
attr_accessor :client
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
self.client = Kubeclient::Client.new(Rhea.configuration.kube_api[:url] , 'v1', Rhea.configuration.kube_api[:options])
|
8
|
+
end
|
9
|
+
|
10
|
+
def method_missing(method, *args)
|
11
|
+
self.client.public_send(method, *args)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Rhea
|
2
|
+
module Kubernetes
|
3
|
+
module Commands
|
4
|
+
class All < Base
|
5
|
+
def perform
|
6
|
+
controllers = api.get_replication_controllers
|
7
|
+
commands = controllers.map do |controller|
|
8
|
+
controller_to_command(controller)
|
9
|
+
end.compact
|
10
|
+
commands = commands.sort_by(&:expression)
|
11
|
+
commands
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Rhea
|
2
|
+
module Kubernetes
|
3
|
+
module Commands
|
4
|
+
class Base
|
5
|
+
NAMESPACE = 'default'
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def api
|
10
|
+
@api ||= Rhea::Kubernetes::Api.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def controller_to_command(controller)
|
14
|
+
expression = controller.spec.template.metadata.annotations.try(:rhea_command)
|
15
|
+
return if expression.nil?
|
16
|
+
process_count = controller.status.replicas
|
17
|
+
image = controller.spec.template.spec.containers.first.image
|
18
|
+
Command.new(
|
19
|
+
expression: expression,
|
20
|
+
image: image,
|
21
|
+
process_count: process_count,
|
22
|
+
created_at: Time.parse(controller.metadata.creationTimestamp)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Rhea
|
2
|
+
module Kubernetes
|
3
|
+
module Commands
|
4
|
+
class Delete < Base
|
5
|
+
attr_accessor :command
|
6
|
+
|
7
|
+
def initialize(command_attributes)
|
8
|
+
self.command = Command.new(command_attributes)
|
9
|
+
end
|
10
|
+
|
11
|
+
def perform
|
12
|
+
# NOTE: Deleting the rc sends a kill signal that doesn't gracefully stop Resque worker processes.
|
13
|
+
api.delete_replication_controller(command.key, NAMESPACE)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Rhea
|
2
|
+
module Kubernetes
|
3
|
+
module Commands
|
4
|
+
class Export < Base
|
5
|
+
def perform
|
6
|
+
commands = All.new.perform
|
7
|
+
commands_data = commands.map do |command|
|
8
|
+
{
|
9
|
+
expression: command.expression,
|
10
|
+
image: command.image,
|
11
|
+
process_count: command.process_count
|
12
|
+
}
|
13
|
+
end
|
14
|
+
{
|
15
|
+
version: Rhea::VERSION,
|
16
|
+
created_at: Time.now.utc,
|
17
|
+
commands: commands_data
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Rhea
|
2
|
+
module Kubernetes
|
3
|
+
module Commands
|
4
|
+
class Get < Base
|
5
|
+
attr_accessor :command
|
6
|
+
|
7
|
+
def initialize(command_attributes)
|
8
|
+
self.command = Command.new(command_attributes)
|
9
|
+
end
|
10
|
+
|
11
|
+
def perform
|
12
|
+
controller = api.get_replication_controllers(label_selector: "name=#{command.key}").first
|
13
|
+
controller_to_command(controller)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Rhea
|
2
|
+
module Kubernetes
|
3
|
+
module Commands
|
4
|
+
class Import < Base
|
5
|
+
attr_accessor :data
|
6
|
+
|
7
|
+
def initialize(data)
|
8
|
+
self.data = data
|
9
|
+
end
|
10
|
+
|
11
|
+
def perform
|
12
|
+
commands_data = data['commands']
|
13
|
+
commands_data.each do |command_data|
|
14
|
+
Scale.new(expression: command_data['expression'], process_count: command_data['process_count'], image: command_data['image']).perform
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Rhea
|
2
|
+
module Kubernetes
|
3
|
+
module Commands
|
4
|
+
class Redeploy < Base
|
5
|
+
attr_accessor :command
|
6
|
+
|
7
|
+
def initialize(command_attributes)
|
8
|
+
self.command = Command.new(command_attributes)
|
9
|
+
end
|
10
|
+
|
11
|
+
def perform
|
12
|
+
command_attributes = command.attributes.slice(:image, :expression)
|
13
|
+
controller = Get.new(command_attributes).perform
|
14
|
+
process_count = controller.process_count
|
15
|
+
Scale.new(command_attributes.merge(process_count: 0)).perform
|
16
|
+
Delete.new(command_attributes).perform
|
17
|
+
Scale.new(command_attributes.merge(process_count: process_count)).perform
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|