Kubernetes pod:
DEEP DIVE

ContainerDay 2018

Verona, 26/10/2018

whoami

DARIO TRANCHITELLA

  • Father
  • Developer
  • DevOps
  • Gopher

 

CLOUD DEVOPS ENGINEER
NAMECHEAP (NC Cloud Team)

this
talks
IS ABOUT...

AND WHY THIS TALK?

THIS TALK IS NOT MADE
OF COPY-PASTED QUOTE

- Dario Tranchitella (ContainerDay 2018)

what is a pod?

kubernetes.io

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/

...remember that a container is made of

  • namespace
  • cgroup
  • aufs

 

MORE INFO?
Giulio De Donato: Isoliamo un Processo senza Container (ContainerDay 2016)

K8S_POD_<NAME> AND PAUSE?

what is the pause container?

kuberentes pause container

https://github.com/kubernetes/kubernetes/blob/master/build/pause/pause.c

sigaction

examine and change a signal action.  returns 0 on success; on error, -1 is returned.

SIGINT (2)

Interrupt from keyboard

SIGTERM (15)

Termination signal

SIGCHLD (20,17,18)

Child stopped or terminated

openshift pause container

https://github.com/openshift/origin/blob/master/images/pod/pod.go

signal.Notify

Go signal notification works by sending os.Signal values on a channe

os.Interrupt

It's sigint (2)

syscall.SIGTERM

It's sigterm (15)

os.Kill

It's sigkill (9)

PLEASE
ADD LITTLE
COMPLEXITY

START YOUR OWN POD

  • docker run -d --rm --name pod k8s.gcr.io/pause-amd64:3.1
  • docker run -d --rm --name foo --pid container:pod --ipc container:pod nginx:alpine
  • docker run -d --rm --name bar --pid container:pod --ipc container:pod redis:alpine

PLEASE
ADD MORE
COMPLEXITY

pod.service

[Unit]
Description=PubePod, awesome pod orchestrated at mentula canis
After=docker.service
Requires=docker.service

[Service]
TimeoutStartSec=0
ExecStartPre=/usr/bin/docker pull k8s.gcr.io/pause-amd64:3.1
ExecStartPre=/usr/bin/echo "This could be a init script, wdyt?"
ExecStartPre=/usr/bin/docker volume create pod_volume
ExecStart=/usr/bin/docker run --rm --name pod k8s.gcr.io/pause-amd64:3.1
ExecStop=/usr/bin/docker stop pod
Restart=always

[Install]
WantedBy=multi-user.target

foo.service

[Unit]
Description=pod.foo
After=docker.service pod.service
Requires=docker.service pod.service

[Service]
TimeoutStartSec=0
ExecStartPre=/usr/bin/docker pull redis:alpine
ExecStart=/usr/bin/docker run --rm --name pod.foo -v pod_volume:/etc/pod --pid container:pod redis:alpine
ExecStop=/usr/bin/docker stop pod.foo
Restart=always

[Install]
WantedBy=multi-user.target

bar.service

[Unit]
Description=pod.bar
After=docker.service pod.service
Requires=docker.service pod.service

[Service]
TimeoutStartSec=0
ExecStartPre=/usr/bin/docker pull redis:alpine
ExecStart=/usr/bin/docker run --rm --name pod.bar -v pod_volume:/etc/pod --pid container:pod nginx:alpine
ExecStop=/usr/bin/docker stop pod.bar
Restart=always

[Install]
WantedBy=multi-user.target

...mmm, where are container patterns?

designing distributed systems (brendan burns)

ambassador

https://github.com/prometherion/openshift-prometheus-grafana-ambassador

QUESTIONS??!?!!!1

ContainerDay 2018

By Dario Tranchitella

ContainerDay 2018

  • 2,108