ContainerDays 2019
Hamburg, 26/06/2019
AND WHY THIS TALK?
- Dario Tranchitella (ContainerDay 2018)
A pod (as in a pod of whales or pea pod) is a group of one or more containers (such as Docker containers), with shared storage/network, and a specification for how to run the containers. A pod’s contents are always co-located and co-scheduled, and run in a shared context. A pod models an application-specific “logical host” - it contains one or more application containers which are relatively tightly coupled — in a pre-container world, being executed on the same physical or virtual machine would mean being executed on the same logical host.
https://kubernetes.io/docs/concepts/workloads/pods/pod/
apiVersion: v1
kind: Pod
metadata:
name: containerdays
spec:
containers:
- name: foo
image: nginx:alpine
resources:
limits:
cpu: "500m"
memory: "256Mi"
requests:
cpu: "250m"
memory: "128Mi"
- name: bar
image: redis:alpine
resources:
limits:
cpu: "500m"
memory: "256Mi"
requests:
cpu: "250m"
memory: "128Mi"
MORE INFO?
Giulio De Donato: Isoliamo un Processo senza Container (ContainerDay 2016)
https://github.com/kubernetes/kubernetes/blob/master/build/pause/pause.c
examine and change a signal action: returns 0 on success, -1 on error.
Interrupt from keyboard
Termination signal
Child stopped or terminated
https://github.com/openshift/origin/blob/v4.0.0-alpha.0/images/pod/pod.go
Go signal notification works by sending os.Signal values on a channe
It's sigint (2)
It's sigterm (15)
It's sigkill (9)
docker run \
-d \
--rm \
--name containerdays \
k8s.gcr.io/pause-amd64:3.1
docker run \
-d \
--rm \
--name containerdays_foo \
--network container:containerdays \
--cpu-shares 512 \
--cpu-quota 75000 \
--ipc container:containerdays \
nginx:alpine
docker run \
-d \
--rm \
--name containerdays_bar \
--network container:containerdays \
--cpu-shares 512 \
--cpu-quota 75000 \
--ipc container:containerdays \
redis:alpine
apiVersion: v1
kind: Pod
metadata:
name: containerdays
spec:
containers:
- name: foo
image: nginx:alpine
resources:
limits:
cpu: "750m"
memory: "256Mi"
requests:
cpu: "500m"
memory: "128Mi"
- name: bar
image: redis:alpine
resources:
limits:
cpu: "750m"
memory: "256Mi"
requests:
cpu: "500m"
memory: "128Mi"
[Unit]
Description=EdamamePod, awesome and tasty pod
Requires=docker.service
[Service]
ExecStartPre=/usr/bin/echo "This could be a init script, WDYT?"
ExecStartPre=/usr/bin/docker volume create edamame_volume
ExecStart=/usr/bin/docker run --rm --name edamame k8s.gcr.io/pause-amd64:3.1
ExecStop=/usr/bin/docker stop edamame
Restart=always
[Install]
WantedBy=multi-user.target
[Unit]
Description=edamame.foo, aka Redis
PartOf=edamame.pod.service
[Service]
TimeoutStartSec=0
ExecStart=/usr/bin/docker run --rm --name edamame.foo -v edamame_volume:/etc/edamame --network container:edamame redis:alpine
ExecStop=/usr/bin/docker stop edamame.foo
Restart=always
[Install]
WantedBy=multi-user.target
[Unit]
Description=edamame.bar, aka NGINX
PartOf=edamame.pod.service
[Service]
TimeoutStartSec=0
ExecStart=/usr/bin/docker run --rm --name edamame.bar -v edamame_volume:/etc/edamame --network container:edamame nginx:alpine
ExecStop=/usr/bin/docker stop edamame.bar
Restart=always
[Install]
WantedBy=multi-user.target