From 6b3d0efa56a203f3eeacd0dcc470858625d75eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Petazzoni?= Date: Tue, 7 Nov 2017 11:23:53 -0800 Subject: [PATCH] split out the 'declarative/imperative' explanation --- slides/common/declarative.md | 63 +++++++++++++++++++++++++++ slides/dockercon.yml | 2 + slides/kube.yml | 2 + slides/kube/concepts-k8s.md | 83 ------------------------------------ slides/kube/declarative.md | 14 ++++++ slides/lisa.yml | 2 + slides/selfpaced.yml | 2 + slides/swarm/swarmkit.md | 49 --------------------- slides/swarm/swarmmode.md | 46 ++++++++++++++++++++ 9 files changed, 131 insertions(+), 132 deletions(-) create mode 100644 slides/common/declarative.md create mode 100644 slides/kube/declarative.md create mode 100644 slides/swarm/swarmmode.md diff --git a/slides/common/declarative.md b/slides/common/declarative.md new file mode 100644 index 00000000..14dcd1c3 --- /dev/null +++ b/slides/common/declarative.md @@ -0,0 +1,63 @@ +# Declarative vs imperative + +- Our container orchestrator puts a very strong emphasis on being *declarative* + +- Declarative: + + *I would like a cup of tea.* + +- Imperative: + + *Boil some water. Pour it in a teapot. Add tea leaves. Steep for a while. Serve in cup.* + +-- + +- Declarative seems simpler at first ... + +-- + +- ... As long as you know how to brew tea + +--- + +## Declarative vs imperative + +- What declarative would really be: + + *I want a cup of tea, obtained by pouring an infusion¹ of tea leaves in a cup.* + +-- + + *¹An infusion is obtained by letting the object steep a few minutes in hot² water.* + +-- + + *²Hot liquid is obtained by pouring it in an appropriate container³ and setting it on a stove.* + +-- + + *³Ah, finally, containers! Something we know about. Let's get to work, shall we?* + +-- + +.footnote[Did you know there was an [ISO standard](https://en.wikipedia.org/wiki/ISO_3103) +specifying how to brew tea?] + +--- + +## Declarative vs imperative + +- Imperative systems: + + - simpler + + - if a task is interrupted, we have to restart from scratch + +- Declarative systems: + + - if a task is interrupted (or if we show up to the party half-way through), + we can figure out what's missing and do only what's necessary + + - we need to be able to *observe* the system + + - ... and compute a "diff" between *what we have* and *what we want* diff --git a/slides/dockercon.yml b/slides/dockercon.yml index a57a0188..b762fc27 100644 --- a/slides/dockercon.yml +++ b/slides/dockercon.yml @@ -19,6 +19,8 @@ chapters: - swarm/versions.md - common/sampleapp.md - swarm/swarmkit.md + - common/declarative.md + - swarm/swarmmode.md - swarm/creatingswarm.md - swarm/morenodes.md - - swarm/firstservice.md diff --git a/slides/kube.yml b/slides/kube.yml index 7b052922..88d4c4f7 100644 --- a/slides/kube.yml +++ b/slides/kube.yml @@ -17,6 +17,8 @@ chapters: - kube/versions-k8s.md - common/sampleapp.md - - kube/concepts-k8s.md + - common/declarative.md + - kube/declarative.md - kube/kubenet.md - kube/kubectlget.md - kube/setup-k8s.md diff --git a/slides/kube/concepts-k8s.md b/slides/kube/concepts-k8s.md index b7b9c16c..067c3165 100644 --- a/slides/kube/concepts-k8s.md +++ b/slides/kube/concepts-k8s.md @@ -211,86 +211,3 @@ class: pic ![Node, pod, container](images/thanks-weave.png) (Diagram courtesy of Weave Works, used with permission.) - ---- - -# Declarative vs imperative - -- Kubernetes puts a very strong emphasis on being *declarative* - -- Declarative: - - *I would like a cup of tea.* - -- Imperative: - - *Boil some water. Pour it in a teapot. Add tea leaves. Steep for a while. Serve in cup.* - --- - -- Declarative seems simpler at first ... - --- - -- ... As long as you know how to brew tea - ---- - -## Declarative vs imperative - -- What declarative would really be: - - *I want a cup of tea, obtained by pouring an infusion¹ of tea leaves in a cup.* - --- - - *¹An infusion is obtained by letting the object steep a few minutes in hot² water.* - --- - - *²Hot liquid is obtained by pouring it in an appropriate container³ and setting it on a stove.* - --- - - *³Ah, finally, containers! Something we know about. Let's get to work, shall we?* - --- - -.footnote[Did you know there was an [ISO standard](https://en.wikipedia.org/wiki/ISO_3103) -specifying how to brew tea?] - ---- - -## Declarative vs imperative - -- Imperative systems: - - - simpler - - - if a task is interrupted, we have to restart from scratch - -- Declarative systems: - - - if a task is interrupted (or if we show up to the party half-way through), - we can figure out what's missing and do only what's necessary - - - we need to be able to *observe* the system - - - ... and compute a "diff" between *what we have* and *what we want* - ---- - -## Declarative vs imperative in Kubernetes - -- Virtually everything we create in Kubernetes is created from a *spec* - -- Watch for the `spec` fields in the YAML files later! - -- The *spec* describes *how we want the thing to be* - -- Kubernetes will *reconcile* the current state with the spec -
(technically, this is done by a number of *controllers*) - -- When we want to change some resource, we update the *spec* - -- Kubernetes will then *converge* that resource diff --git a/slides/kube/declarative.md b/slides/kube/declarative.md new file mode 100644 index 00000000..de9fa995 --- /dev/null +++ b/slides/kube/declarative.md @@ -0,0 +1,14 @@ +## Declarative vs imperative in Kubernetes + +- Virtually everything we create in Kubernetes is created from a *spec* + +- Watch for the `spec` fields in the YAML files later! + +- The *spec* describes *how we want the thing to be* + +- Kubernetes will *reconcile* the current state with the spec +
(technically, this is done by a number of *controllers*) + +- When we want to change some resource, we update the *spec* + +- Kubernetes will then *converge* that resource diff --git a/slides/lisa.yml b/slides/lisa.yml index 1fd4ea70..9d51ec7f 100644 --- a/slides/lisa.yml +++ b/slides/lisa.yml @@ -19,6 +19,8 @@ chapters: - swarm/versions.md - common/sampleapp.md - swarm/swarmkit.md + - common/declarative.md + - swarm/swarmmode.md - swarm/creatingswarm.md - swarm/morenodes.md - - swarm/firstservice.md diff --git a/slides/selfpaced.yml b/slides/selfpaced.yml index 59217246..f6934e17 100644 --- a/slides/selfpaced.yml +++ b/slides/selfpaced.yml @@ -22,6 +22,8 @@ chapters: Part 1 - common/sampleapp.md - swarm/swarmkit.md + - common/declarative.md + - swarm/swarmmode.md - swarm/creatingswarm.md - swarm/machine.md - swarm/morenodes.md diff --git a/slides/swarm/swarmkit.md b/slides/swarm/swarmkit.md index 35e06702..acee6dbd 100644 --- a/slides/swarm/swarmkit.md +++ b/slides/swarm/swarmkit.md @@ -118,52 +118,3 @@ class: pic - *Nodes* know which *tasks* should be running, and will start or stop containers accordingly (through the Docker Engine API) You can refer to the [NOMENCLATURE](https://github.com/docker/swarmkit/blob/master/design/nomenclature.md) in the SwarmKit repo for more details. - ---- - -## Swarm Mode - -- Since version 1.12, Docker Engine embeds SwarmKit - -- All the SwarmKit features are "asleep" until you enable "Swarm Mode" - -- Examples of Swarm Mode commands: - - - `docker swarm` (enable Swarm mode; join a Swarm; adjust cluster parameters) - - - `docker node` (view nodes; promote/demote managers; manage nodes) - - - `docker service` (create and manage services) - -??? - -- The Docker API exposes the same concepts - -- The SwarmKit API is also exposed (on a separate socket) - ---- - -## You need to enable Swarm mode to use the new stuff - -- By default, all this new code is inactive - -- Swarm Mode can be enabled, "unlocking" SwarmKit functions -
(services, out-of-the-box overlay networks, etc.) - -.exercise[ - -- Try a Swarm-specific command: - ```bash - docker node ls - ``` - - - -] - --- - -You will get an error message: -``` -Error response from daemon: This node is not a swarm manager. [...] -``` diff --git a/slides/swarm/swarmmode.md b/slides/swarm/swarmmode.md new file mode 100644 index 00000000..e13dab47 --- /dev/null +++ b/slides/swarm/swarmmode.md @@ -0,0 +1,46 @@ +# Swarm Mode + +- Since version 1.12, Docker Engine embeds SwarmKit + +- All the SwarmKit features are "asleep" until you enable "Swarm Mode" + +- Examples of Swarm Mode commands: + + - `docker swarm` (enable Swarm mode; join a Swarm; adjust cluster parameters) + + - `docker node` (view nodes; promote/demote managers; manage nodes) + + - `docker service` (create and manage services) + +??? + +- The Docker API exposes the same concepts + +- The SwarmKit API is also exposed (on a separate socket) + +--- + +## You need to enable Swarm mode to use the new stuff + +- By default, all this new code is inactive + +- Swarm Mode can be enabled, "unlocking" SwarmKit functions +
(services, out-of-the-box overlay networks, etc.) + +.exercise[ + +- Try a Swarm-specific command: + ```bash + docker node ls + ``` + + + +] + +-- + +You will get an error message: +``` +Error response from daemon: This node is not a swarm manager. [...] +```