-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
378 lines (322 loc) · 11.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Re-ops, a Functional Live-Infrastructure as Code</title>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css" id="theme">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- <link rel="stylesheet" href="lib/styles/github-gist.css"> -->
<!-- <link rel="stylesheet" href="lib/styles/docco.css"> -->
<!-- <link rel="stylesheet" href="lib/styles/github.css"> -->
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section id="title">
<h1>Re-ops</h1>
<h3>Functional Live-Infrastructure as Code</h3>
<p>
<small>Created by <a href="https://narkisr.com">Ronen Narkis</a> / <a href="http://twitter.com/narkisr">@narkisr</a></small>
<small><a href="#/themes">settings</a></small>
</p>
</section>
<section id="Intro">
<h2>Operations</h2>
<p> The process of managing computerized resources </p>
<p> by manipulating their state </span> </p>
</section>
<section id="shorts">
<h2> Status quo</h2>
<p class ="fragment fade-down">Complex </p>
<p class ="fragment fade-down">Slow to react</p>
<p class ="fragment fade-down">Hard to composes</p>
<p class ="fragment fade-down">Data is second class</p>
</section>
<section id= "re-ops">
<h2>Re-ops</h2>
<p class="fragment">Live environment for managing servers</p>
<p class="fragment">Composed from <span class="fragment fade-up">re-core,</span> <span class="fragment fade-up">re-mote</span><span class="fragment fade-up">, re-gent</span></p>
<p class="fragment">No magic, functions and a dash of macros! </p>
</section>
<section id="re-mote-overview">
<h2>Re-mote</h2>
<p> Remote automation</p>
<p> Data collection, publishing</p>
<p> Scheduled execution </p>
</section>
<section id="hosts">
<h2>Hosts</h2>
<pre><code class="clojure" data-trim contenteditable>
(def sandbox (Hosts. {:user "ronen"} ["host-a" ,,,,]))
(defprotocol Shell
(ls [this target flags]))
(extend-type Hosts
Shell
(ls [this target flags]
; implementation
))
(defn listing [hs]
(run (ls hs "/" "-la") | (pretty)))
</code></pre>
</section>
<section id="pipelines-overview">
<h2> Pipelines </h2>
<p class="fragment"> Series of functions (operations)</p>
<p class="fragment"> Data flows from one function to the next </p>
<p class="fragment"> Intermediate functions operate on data </p>
<p class="fragment"> Final function output, publish, block/run async etc..</p>
<p class="fragment"> We can compose pipelines (just functions)</p>
</section>
<section id="pipelines-example">
<h2>Pipeline deconstruction</h2>
<pre><code class="clojure" data-trim contenteditable>
filtering output
^ ^
(defn listing [hs] | |
(run (ls hs "/" "-la") | (pick successful) | (pretty)))
| |
| V
| [this, {:successful [], :failure []}
V
expands to: (| (| (ls ..) (pick ..)) (pretty))
; pipe expansion
(let [[this' res] (ls hs)]
(pick this' res))
</code></pre>
</section>
<section id="publishing">
<h2> Publishing </h2>
<pre><code class="clojure" data-trim contenteditable>
; free uses free-script
(defn #^{:category :stats} ram-publish
"RAM free and used percentage collection and publishing"
[hs]
(run (free hs)
| (collect)
| (publish (stock "Free RAM" :timeseries :free))
| (publish (stock "Used RAM" :timeseries :used))))
</code></pre>
</section>
<section id="dashboard">
<h2> Dashboard </h2>
<img src="./img/dashboard.png" alt="">
</section>
<section id="stevedore">
<h2>Stevedore</h2>
<pre><code class="clojure" data-trim contenteditable>
; expands into
; # base.clj:190
; ls / -la
(let [target "/" flags "-la"]
(script ("ls" ~target ~flags)))
(defn free-script []
(script
(set! R @("free" "-m"))
(if (not (= $? 0)) ("exit" 1))
(pipe
((println (quoted "${R}")))
("awk" "'NR==2 { print $2 \" \" $3 \" \" $4 }'"))))
</code></pre>
</section>
<section id="re-mote-demo">
<p>Re-mote demo </p>
<a href="./gifs/re-mote-demo.gif">
<img src="./gifs/re-mote-demo.gif" alt="" width="1500px" height="500px">
</a>
</section>
<section id="scheduling">
<h2>Scheduling</h2>
<pre><code class="clojure" data-trim contenteditable>
; every day on 10 AM
(defn apt-jobs [hs]
(watch :update (every-day 10) (fn [] (aptdate hs))))
; every 5 seconds
(defn stats-jobs [hs]
(watch :cpu (seconds 5) (fn [] (cpu-publish hs))))
; Saturday 4 AM
(defn zfs-jobs [hs]
(watch :scrub (at-day DateTimeConstants/SATURDAY 4)
(fn [] (run (scrub hs "tank") | (email "scrub done")))))
</code></pre>
</section>
<section id="time-seqs">
<h2>Time sequences</h2>
<pre><code class="clojure" data-trim contenteditable>
(defn seconds
([n f]
(periodic-seq
(t/plus (local-now) (t/seconds f)) (-> n t/seconds)))
([n]
(periodic-seq (local-now) (-> n t/seconds))))
</code></pre>
</section>
<section id="re-core-overview">
<h3> Re-core</h3>
<p> Manage VMs (AWS, DigitalOcean, KVM)</p>
<p> Persistent (Redis/ES)</p>
<p> Queue (Redis)</p>
<p> Pipeline/Protocol patterns</p>
</section>
<section id="systems">
<h2>Systems</h2>
<pre><code class="clojure" data-trim contenteditable>
(def systems (Systems.))
(defn list
"List available instances:
(list) ; list all
(list ip) ; list all with ip (running)
"
([]
(list identity))
([f]
(run (ls systems) | (filter-by f) | (pretty))))
^
|
[this, {:systems [...]}]
</code></pre>
</section>
<section id="systems-model">
<h2>System model</h2>
<pre><code class="clojure" data-trim contenteditable>
{
:machine {
:hostname "reops" :user "re-ops" :domain "local"
:os :ubuntu-16.04 :cpu 2 :ram 1024
}
:kvm {
:node :remote
}
:type "reops"
}
</code></pre>
</section>
<section id="re-core-demo">
<p>Re-core Demo</p>
<a href="./gifs/re-core-demo.gif">
<img src="./gifs/re-core-demo.gif" alt="" width="1200px" height="500px">
</a>
</section>
<section id="re-gent-overview">
<h3> Re-gent </h3>
<p> Persistent connections (Zeromq)</p>
<p> Secure (CurveZMQ) </p>
<p> Distributed Clojure functions </p>
<p> Easy to deploy </p>
</section>
<section id="re-gent-example">
<pre><code class="clojure" data-trim contenteditable>
; using serializable.fn
(def ^{:doc "adding one"} plus-one
(s/fn [x] (+ 1 x)))
; run the function on the hosts
(call plus-one [1] hs)
</code></pre>
</section>
<section id="re-gent-demo">
<p>Re-gent Demo</p>
<a href="./gifs/re-gent-demo.gif">
<img src="./gifs/re-gent-demo.gif" alt="" width="1500px" height="500px">
</a>
</section>
<section id="re-gent-metrics">
<h2> Metrics </h2>
<pre><code class="clojure" data-trim contenteditable>
; using oshi
(get-in (read-metrics) [:operatingSystem :processes])
{"7695d7ecbd60484281ff2cd0af979cbe"
[{:group "re-ops",
:groupID "1000",
:kernelTime 420,
:name "java",
:parentProcessID 1,
:path "/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java",
...
}]}
</code></pre>
</section>
<section id="reloaded">
<h2> Reloaded workflow </h2>
<pre><code class="clojure" data-trim contenteditable>
(ns user
[clojure.tools.namespace.repl :refer (refresh refresh-all)]
....
)
; create environment from scratch
(go)
; halt the environment
(stop)
; stop and go (when re-defining does not work)
(reset)
</code></pre>
</section>
<section id="reset">
<h2> Reset </h2>
<p> clojure.tools.namespace.repl refresh refresh-all</p>
<p> Works across threads</p>
<p class="fragment highlight-red"> Reset all VARS</p>
<p class="fragment highlight-red"> Atoms state lost</p>
<p class="fragment highlight-green"> Re-defining preferred (protocols)</p>
</section>
<section id="future">
<h2>Future </h2>
<p> Hosts queries </p>
<p> Re-gent functions in pipelines</p>
<p> Stream into riemann</p>
<p> FreeBSD support </p>
<p> Exposing pipeline end points (http)</p>
</section>
<section>
<h2> Questions ?</h2>
<p> Check <a href="https://github.com/re-ops">https://github.com/re-ops</a> </p>
<p> <a href="https://twitter.com/narkisr">@narkisr</a></p>
</section>
<section id="themes">
<h2>Settings</h2>
<p>
Select theme: <br>
<!-- Hacks to swap themes after the page has loaded. Not flexible and only intended for the reveal.js demo deck. -->
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/black.css'); return false;">Black (default)</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/white.css'); return false;">White</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/league.css'); return false;">League</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/sky.css'); return false;">Sky</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/beige.css'); return false;">Beige</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/simple.css'); return false;">Simple</a> <br>
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/serif.css'); return false;">Serif</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/blood.css'); return false;">Blood</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/night.css'); return false;">Night</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/moon.css'); return false;">Moon</a> -
<a href="#" onclick="document.getElementById('theme').setAttribute('href','css/theme/solarized.css'); return false;">Solarized</a>
</p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
slideNumber: true,
history: true,
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: false, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
</body>
</html>