mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-07-20 21:39:22 +00:00
split out the 'declarative/imperative' explanation
This commit is contained in:
63
slides/common/declarative.md
Normal file
63
slides/common/declarative.md
Normal file
@@ -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*
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -211,86 +211,3 @@ class: pic
|
||||

|
||||
|
||||
(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
|
||||
<br/>(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
|
||||
|
||||
14
slides/kube/declarative.md
Normal file
14
slides/kube/declarative.md
Normal file
@@ -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
|
||||
<br/>(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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
<br/>(services, out-of-the-box overlay networks, etc.)
|
||||
|
||||
.exercise[
|
||||
|
||||
- Try a Swarm-specific command:
|
||||
```bash
|
||||
docker node ls
|
||||
```
|
||||
|
||||
<!-- Ignore errors: ```wait ``` -->
|
||||
|
||||
]
|
||||
|
||||
--
|
||||
|
||||
You will get an error message:
|
||||
```
|
||||
Error response from daemon: This node is not a swarm manager. [...]
|
||||
```
|
||||
|
||||
46
slides/swarm/swarmmode.md
Normal file
46
slides/swarm/swarmmode.md
Normal file
@@ -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
|
||||
<br/>(services, out-of-the-box overlay networks, etc.)
|
||||
|
||||
.exercise[
|
||||
|
||||
- Try a Swarm-specific command:
|
||||
```bash
|
||||
docker node ls
|
||||
```
|
||||
|
||||
<!-- Ignore errors: ```wait ``` -->
|
||||
|
||||
]
|
||||
|
||||
--
|
||||
|
||||
You will get an error message:
|
||||
```
|
||||
Error response from daemon: This node is not a swarm manager. [...]
|
||||
```
|
||||
Reference in New Issue
Block a user