Docker, what else?

(c) George.

Sylvain Bauza / @sylvainbauza / bauzas (Freenode)

Docker Grenoble meetup

19/03/2015

Kubernetes

In old Greek, "Steersman, helmsman, sailing master"

Φιλοσοφία Βιοῦ Κυβερνήτης
"Love of wisdom is the guide of life"

Docker is not...

  1. cluster-centric
  2. declarative
  3. able to scale and schedule thru a massive deployment

Solution:

Docker Compose logo

Docker Entreprise (Swarm and Compose)

Want a big picture ?

K8S big picture

Kubernetes Node

Kubernetes minion diagram  
Minion
(Or "Kubernetes Node"; the name is evolving)
A Docker host running the kubelet and the proxy service.
 
Pod
One or more inter-related (linked) Docker containers.
 
Cluster
A collection of one or more Minions.

Minion Daemon:
kubernetes-kubelet

Kubelet works between etcd and docker.
  • Primary responsilibity: pod management
  • Maintain a record of pod state
  • Take instructions from the cluster master

Minion Daemon:
kubernetes-proxy

The proxy maps a single port on the minion to all relevant pods

 

  • Forward requests to the right container
  • Load-balance requests
  • Ensure minion subnet isolation

etcd

  • Highly available key/value data store
  • Built-in clustering support
  • RAFT consensus-based algorithm for updates
Visualization of raft consensus

Cluster Management

Kubernetes cluster master diagram  
Kubernetes API
RESTful web API for Kubernetes, running on nginx
 
Scheduler
One job: choose minions for pods
 
Controller Manager
Monitoring service for deployed pods
 
kubecfg
(A newer iteration of this is now called kubectl )
CLI for working with a Kubernetes cluster

Replication Controllers

You tell controller-manager what you need, and it does the rest.  
  • You tell it what you need, it decides which minions to deploy on
  • Constant monitoring; starts and stops pods as necessary to match the count
  • Decoupled from service proxying

kubectl

Get details on resource(s)

$ kubectl get pods|services|rc|...

Create a resource

$ kubectl create -f some/body.[json|yaml]

Resize a ReplicationController

$ kubectl resize --replicas=3 foo

Execute a command on a container

$ kubectl exec -p 123456-7890 -c ruby-container -i -t -- bash -il

The Kubernetes API

  • Minions (docker hosts)
  • Pods (docker container configurations)
  • Services (single, stable name for a set of pods, acts as a LB)
  • Replication Controllers (manages the lifecycle of the pods)
  • Labels
Google examples (eh I'm a minion)

Labels

A lot of labels
  • A label or consists of a key and a value (also called a selector)
  • A pod can have any number of labels; each label must have a unique key
  • Examples: service=nginx, environment=prod, tier=frontend

Pods


{
  "id": "redis-master-pod",
  "kind": "Pod",
  "apiVersion": "v1beta1",
  "desiredState": {
    "manifest": {
      "version": "v1beta1",
      "id": "redis-master-pod",
      "containers": [{
        "name": "redis-master",
        "image": "gurpartap/redis",
        "ports": [{ "name": "redis-server", "containerPort": 6379 }]
      }]
    }
  },
  "labels": {"name": "redis"}
}
		        	

Services


{
  "id": "redis-master",
  "kind": "Service",
  "apiVersion": "v1beta1",
  "port": 8888,
  "containerPort": 6379,
  "selector": {
    "name": "redis"
  },
  "labels": {"name": "redis"}
}
		        	

Service env vars


REDIS_PORT='tcp://10.0.29.247:8888'
REDIS_PORT_6379_TCP='tcp://10.0.29.247:8888'
REDIS_PORT_6379_TCP_ADDR='10.0.29.247'
REDIS_PORT_6379_TCP_PORT='8888'
REDIS_PORT_6379_TCP_PROTO='tcp'
REDIS_SERVICE_PORT='8888'
REDIS_SERVICE_HOST='10.0.29.247'
		        	

Replication Controllers


{
  "id": "redisSlaveController",
  "kind": "ReplicationController",
  "apiVersion": "v1beta1",
  "desiredState": {
    "replicas": 2,
    "replicaSelector": {"name": "redisslave"},
    "podTemplate": {
      "desiredState": {
         "manifest": {
           "version": "v1beta1",
           "id": "redisSlaveController",
           "containers": [{
             "name": "slave",
             "image": "brendanburns/redis-slave",
             "ports": [{"containerPort": 6379, "hostPort": 8888}]
           }]
         }
       },
       "labels": {"name": "redisslave"}
      }},
  "labels": {"name": "redisslave"}
}
		        	

Cockpit UI (beta)

Cockpit dash   Cockpit docker pull

That's it !

Questions ?