This repository has been archived by the owner on Mar 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsource.html
503 lines (481 loc) · 27 KB
/
source.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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Kubernetes Custom Resources with Kubeless and Metacontroller</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="node_modules/reveal.js/css/reset.css">
<link rel="stylesheet" href="node_modules/reveal.js/css/reveal.css">
<link rel="stylesheet" href="node_modules/reveal.js/css/theme/black.css">
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i" rel="stylesheet">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="node_modules/reveal.js/lib/css/monokai.css">
<meta name="description" content="Kubernetes offers a lot of basic resources to accomodate most application requirements but sometimes this is not enough. Kubernetes 1.7 introduced a new CustomResourceDefinition (CRD) resource to create your very own kubernetes resources. Although CRDs themselves are easy to use, they provide no way to define the actual logic behind the custom resource. For this the Metacontroller and Kubeless projects can be used, making the whole process a breeze.">
<meta name="author" content="Michael Gruener">
<link rel="author" href="mailto:[email protected]">
<meta property="og:title" content="Kubernetes Custom Resources with Kubeless and Metacontroller">
<meta property="og:type" content="article">
<meta property="og:description" content="Kubernetes offers a lot of basic resources to accomodate most application requirements but sometimes this is not enough. Kubernetes 1.7 introduced a new CustomResourceDefinition (CRD) resource to create your very own kubernetes resources. Although CRDs themselves are easy to use, they provide no way to define the actual logic behind the custom resource. For this the Metacontroller and Kubeless projects can be used, making the whole process a breeze.">
<meta property="og:url" content="https://github.com/bedag/kubeless-metacontroller-crd/index.html">
<meta property="article:author" content="https://github.com/mgruener">
<meta property="article:publisher" content="https://github.com/mgruener">
<meta property="article:published_time" content="2019-05-14T16:00:00+02:00">
<meta property="article:section" content="Talks">
<meta property="og:locale" content="en_GB">
<link rel="stylesheet" type="text/css" href="node_modules/asciinema-player/resources/public/css/asciinema-player.css" />
<style>
mark {background-color: #dc322f;}
</style>
</head>
<body>
<div class="reveal" .slide-number font-size="24pt">
<div class="slides">
<section data-markdown>
<script type="text/template">
# Kubernetes
# Custom Resources
# with Kubeless
# and Metacontroller
</script>
</section>
<section>
<img alt="bedag-logo" src="data/Bedag_Banner.png" style="background:none; border:none; box-shadow:none;"/>
Michael Grüner<br>
<img alt="bedag-map" src="data/map.png" style="background:none; border:none; box-shadow:none;"/>
</section>
<section data-markdown>
<script type="text/template">
The goal
--------
Our very own Kubernetes resource
<pre><code data-trim data-noescape class="shell">$ kubectl create myresource "foobar"
myresource "foobar" created
$ kubectl get myresource
NAME STATUS AGE
foobar Active 57s
</code></pre>
</script>
</section>
<section data-markdown>
<script type="text/template">
The recipe
----------
- A hint of resource definition
- Some logic to make it do something
- Some API magic to make it all stick together
</script>
</section>
<section>
<section data-markdown data-transition="slide-in none-out">
<script type="text/template">
A hint of resource definition
-----------------------------
CustomResourceDefinition
<pre><code data-trim data-noescape class="yaml">apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: myresources.stable.mycompany.com
spec:
group: stable.mycompany.com
versions:
- name: v1
served: true
storage: true
scope: Namespaced
names:
kind: MyResource
plural: myresources
singular: myresource
shortNames:
- mr
</code></pre>
</script>
</section>
<section data-markdown data-transition="none-in none-out">
<script type="text/template">
A hint of resource definition
-----------------------------
CustomResourceDefinition
<pre><code data-trim data-noescape class="yaml">apiVersion: <mark>apiextensions.k8s.io</mark>/v1beta1
kind: CustomResourceDefinition
metadata:
name: myresources.stable.mycompany.com
spec:
group: stable.mycompany.com
versions:
- name: v1
served: true
storage: true
scope: Namespaced
names:
kind: MyResource
plural: myresources
singular: myresource
shortNames:
- mr
</code></pre>
</script>
</section>
<section data-markdown data-transition="none-in none-out">
<script type="text/template">
A hint of resource definition
-----------------------------
CustomResourceDefinition
<pre><code data-trim data-noescape class="yaml">apiVersion: apiextensions.k8s.io/<mark>v1beta1</mark>
kind: CustomResourceDefinition
metadata:
name: myresources.stable.mycompany.com
spec:
group: stable.mycompany.com
versions:
- name: v1
served: true
storage: true
scope: Namespaced
names:
kind: MyResource
plural: myresources
singular: myresource
shortNames:
- mr
</code></pre>
</script>
</section>
<section data-markdown data-transition="none-in none-out">
<script type="text/template">
A hint of resource definition
-----------------------------
CustomResourceDefinition
<pre><code data-trim data-noescape class="yaml">apiVersion: apiextensions.k8s.io/v1beta1
kind: <mark>CustomResourceDefinition</mark>
metadata:
name: myresources.stable.mycompany.com
spec:
group: stable.mycompany.com
versions:
- name: v1
served: true
storage: true
scope: Namespaced
names:
kind: MyResource
plural: myresources
singular: myresource
shortNames:
- mr
</code></pre>
</script>
</section>
<section data-markdown data-transition="none-in none-out">
<script type="text/template">
A hint of resource definition
-----------------------------
CustomResourceDefinition
<pre><code data-trim data-noescape class="yaml">apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: myresources.<mark>stable.mycompany.com</mark>
spec:
group: <mark>stable.mycompany.com</mark>
versions:
- name: v1
served: true
storage: true
scope: Namespaced
names:
kind: MyResource
plural: myresources
singular: myresource
shortNames:
- mr
</code></pre>
</script>
</section>
<section data-markdown data-transition="none-in none-out">
<script type="text/template">
A hint of resource definition
-----------------------------
CustomResourceDefinition
<pre><code data-trim data-noescape class="yaml">apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: myresources.stable.mycompany.com
spec:
group: stable.mycompany.com<mark>
versions:
- name: v1</mark>
served: true
storage: true
scope: Namespaced
names:
kind: MyResource
plural: myresources
singular: myresource
shortNames:
- mr
</code></pre>
</script>
</section>
<section data-markdown data-transition="none-in slide-out">
<script type="text/template">
A hint of resource definition
-----------------------------
CustomResourceDefinition
<pre><code data-trim data-noescape class="yaml">apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: <mark>myresources</mark>.stable.mycompany.com
spec:
group: stable.mycompany.com
versions:
- name: v1
served: true
storage: true
scope: Namespaced
names:
kind: <mark>MyResource</mark>
plural: myresources
singular: myresource
shortNames:
- mr
</code></pre>
</script>
</section>
<section>
<img alt="architecture-crd" src="data/overview/crd.svg" style="background:white; border:none; box-shadow:none;"/>
</section>
</section>
<section>
<section>
<h2>Some logic to make it do something</h2>
<img alt="kubeless-logo" src="data/kubeless-white-test.svg" style="background:none; border:none; box-shadow:none;"/>
</section>
<section data-markdown data-transition="slide-in none-out">
<script type="text/template">
Some logic to make it do something
----------------------------------
Kubeless Functions
<div class="fragment">
<pre><code data-trim data-noescape class="yaml">apiVersion: kubeless.io/v1beta1
kind: Function
metadata:
name: hello-world
namespace: test<span class="fragment">
spec:
runtime: "python2.7"</span><span class="fragment">
handler: "helloget.foo"</span><span class="fragment">
checksum: "sha256:d251999dcbfde..."</span><span class="fragment">
function-content-type: "text"</span><span class="fragment">
function: |
def foo(event, context):
return "Hello {}".format(event['data']['world'])</span>
</code></pre>
</div>
</script>
</section>
<section data-markdown data-transition="none-in slide-out">
<script type="text/template">
Some logic to make it do something
----------------------------------
Kubeless Functions
<pre><code data-trim data-noescape class="yaml">apiVersion: kubeless.io/v1beta1
kind: Function
metadata:
name: hello-world
namespace: test
spec:
runtime: "python2.7"
handler: "helloget.foo"
checksum: "sha256:d251999dcbfde..."
function-content-type: "text"
function: |
def foo(<mark>event</mark>, context):
return "Hello {}".format(<mark>event['data']</mark>['world'])
</code></pre>
</script>
</section>
<section data-markdown>
<script type="text/template">
Some logic to make it do something
----------------------------------
Example function call
<pre><code data-trim data-noescape class="shell">$ curl -d '{"world": "Kubernetes!"}' \
> -H "Content-Type: application/json" \
> -X POST "http://hello-world.test:8080"
Hello Kubernetes!
</code></pre>
</script>
</section>
<section>
<img alt="architecture-crd-kubeless" src="data/overview/crd-kubeless.svg" style="background:white; border:none; box-shadow:none;"/>
</section>
</section>
<section>
<section>
<h2>Some API magic to make it all stick together</h2>
<img alt="metacontroller" src="data/metacontroller.png" style="background:none; border:none; box-shadow:none; vertical-align:middle;" .element height="200" />
<span style="font-size:120px; vertical-align:middle; color:#326ce5;">
Metacontroller
</span>
(MaaS: Magic as a Service)
</section>
<section data-markdown data-transition="slide-in none-out">
<script type="text/template">
Some API magic to make it all stick together
--------------------------------------------
<div class="fragment">
<pre><code data-trim data-noescape class="yaml" style="max-height: 465px;">apiVersion: metacontroller.k8s.io/v1alpha1
kind: CompositeController
metadata:
name: hello-controller<span class="fragment">
spec:
parentResource:
apiVersion: stable.mycompany.com/v1
resource: myresources</span><span class="fragment">
childResources:
- apiVersion: v1
resource: pods
updateStrategy: { method: Recreate }</span><span class="fragment">
generateSelector: true</span><span class="fragment">
hooks:
sync:
webhook:
url: "http://hello-world.test:8080"</span>
</code></pre>
</div>
</script>
</section>
<section data-markdown data-transition="none-in slide-out">
<script type="text/template">
Some API magic to make it all stick together
--------------------------------------------
<pre><code data-trim data-noescape class="yaml" style="max-height: 465px;">apiVersion: metacontroller.k8s.io/v1alpha1
kind: CompositeController
metadata:
name: hello-controller
spec:<mark>
parentResource:</mark>
apiVersion: stable.mycompany.com/v1
resource: myresources
childResources:
- apiVersion: v1
resource: pods
updateStrategy: { method: Recreate }
generateSelector: true
hooks:
sync:<mark>
webhook:</mark>
url: "http://hello-world.test:8080"
</code></pre>
</script>
</section>
<section data-markdown>
<script type="text/template">
Some API magic to make it all stick together
--------------------------------------------
<div class="fragment">
<pre><code data-trim data-noescape class="json">{
"parent": {
"apiVersion": "stable.mycompany.com/v1",
"kind": "myresource",
...
},<span class="fragment">
"children": {
"Pod.v1": {...}
}
}</span>
</code></pre>
</div>
<div class="fragment">
<pre><code data-trim data-noescape class="json">{
"status": {},<span class="fragment">
"children": [
{"apiVersion": "v1", "kind": "pod" ...}
]
}</span>
</code></pre>
</div>
</script>
</section>
<section>
<img alt="architecture-crd-meta-kubeless" src="data/overview/crd-meta-kubeless.svg" style="background:white; border:none; box-shadow:none;"/>
</section>
</section>
<section>
<section data-transition="slide-in none-out">
<img alt="architecture-crd-meta-kubeless" src="data/process/00-start.svg" style="background:white; border:none; box-shadow:none;"/>
</section>
<section data-transition="none-in none-out">
<img alt="architecture-crd-meta-kubeless" src="data/process/01-create-parent.svg" style="background:white; border:none; box-shadow:none;"/>
</section>
<section data-transition="none-in none-out">
<img alt="architecture-crd-meta-kubeless" src="data/process/02-notify-api.svg" style="background:white; border:none; box-shadow:none;"/>
</section>
<section data-transition="none-in none-out">
<img alt="architecture-crd-meta-kubeless" src="data/process/03-notify-meta.svg" style="background:white; border:none; box-shadow:none;"/>
</section>
<section data-transition="none-in none-out">
<img alt="architecture-crd-meta-kubeless" src="data/process/04-notify-function-01.svg" style="background:white; border:none; box-shadow:none;"/>
</section>
<section data-transition="none-in none-out">
<img alt="architecture-crd-meta-kubeless" src="data/process/04-notify-function-02.svg" style="background:white; border:none; box-shadow:none;"/>
</section>
<section data-transition="none-in none-out">
<img alt="architecture-crd-meta-kubeless" src="data/process/04-notify-function-03.svg" style="background:white; border:none; box-shadow:none;"/>
</section>
<section data-transition="none-in none-out">
<img alt="architecture-crd-meta-kubeless" src="data/process/05-return-api.svg" style="background:white; border:none; box-shadow:none;"/>
</section>
<section data-transition="none-in none-out">
<img alt="architecture-crd-meta-kubeless" src="data/process/06-create-resources.svg" style="background:white; border:none; box-shadow:none;"/>
</section>
<section data-transition="none-in none-out">
<img alt="architecture-crd-meta-kubeless" src="data/process/07-loop.svg" style="background:white; border:none; box-shadow:none;"/>
</section>
</section>
<section><h2>Demo</h2></section>
<section>
<asciinema-player cols="200" rows="35" font-size="14px" src="data/demo.cast"></asciinema-player>
</section>
<section>
<h2>The End</h2>
Contact? Well...</br>
<ul>
<li>Github: <a href="https://github.com/mgruener">@mgruener</a></li>
<li>Github: <a href="https://github.com/bedag">@bedag</a></li>
</ul></br></br>
Anyone still using email? </br> <a href="mailto:[email protected]">[email protected]</a>
</section>
<section data-markdown>
<script type="text/template">
References
-------
* [https://metacontroller.app](https://metacontroller.app)
* [https://kubeless.io](https://kubeless.io)
* [https://github.com/bedag/kubeless-metacontroller-crd](https://github.com/bedag/kubeless-metacontroller-crd)
</script>
</section>
</div>
</div>
<script src="node_modules/reveal.js/js/reveal.js"></script>
<script src="node_modules/reveal.js/plugin/markdown/marked.js"></script>
<script src="node_modules/reveal.js/plugin/markdown/markdown.js"></script>
<script src="node_modules/reveal.js/plugin/notes/notes.js"></script>
<script src="node_modules/reveal.js/plugin/highlight/highlight.js"></script>
<script>
hljs.initHighlightingOnLoad()
</script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
history: true,
slideNumber: true,
width: 960,
height: 700,
controlsTutorial: false
});
</script>
<script src="node_modules/asciinema-player/resources/public/js/asciinema-player.js"></script>
</body>
</html>