3 Getting Started Kubernetes m3 Slides
3 Getting Started Kubernetes m3 Slides
Nigel Poulton
@nigelpoulton www.nigelpoulton.com
Kubernetes Architecture
Nigel Poulton
@nigelpoulton www.nigelpoulton.com
Module Outline
Manager
(coach)
Team
Team
RW HM
CH
S RB
Manager LW
(coach)
CH AM
LB
S
S
S1 GK
1
S2 S3
HTTPS HTTPS
Search Auth
Log Load
balancer
HTTPS HTTPS
Search Auth
Log Load
balancer
Load
balancer
HTTPS
HTTPS
Auth
Search Log
Node 1
Node 2
Node Node
K8s cluster
Node Node
K8s cluster
Node Node
K8s cluster
KV
apiserver {}
Node Node
Pod
Node Node
Pod Pod
K8s cluster
Masters Fe
KV
{}
Linux
Fe
Multi-master HA
Master
Master
KV
Master
KV
KV
{}
{}
Linux {}
Fe Linux
Fe Linux
Fe
Node Node
Linux Linux
Fe Fe
Node Node
Linux Linux
Fe Distributed Control Plane Fe
(future)
Pod
Pod Pod
Node Node
Linux Linux
Fe Fe
Pod
Pod Pod
Node Node
Linux Linux
Fe Don’t run user workloads on Fe
“Master”
Pod
Pod Pod
Node Node
Linux
Master Linux
Fe Fe
KV
{}
Pod Linux
Pod Pod
Fe
Node Node
Linux Linux
Fe Don’t run user workloads on Fe
“Master”
Master
KV
apiserver
{} {}
Linux
Fe
Master
KV
apiserver {}
Linux
Fe
kube-apiserver Master
KV
Front-end to the control
plane
Exposes the API (REST)
apiserver {}
Consumes JSON
(via manifest files)
Linux
Fe
kube-apiserver Master
KV
Front-end to the control
plane
Exposes the API (REST)
apiserver {}
Consumes JSON
(via manifest files)
Linux
Fe
Cluster store
Master
Persistent storage Cluster
KV Store
KV
Cluster state and config
Uses etcd
Distributed, consistent,
watchable… apiserver {}
• constraints
Linux
• resources
Fe
• …
kube-scheduler Master
Cluster
KV Store
KV
Watches apiserver for
new pods
Scheduler Controller
• constraints
Linux
• resources
Fe
• …
Master
Cluster
KV Store
KV
Scheduler Controller
apiserver {}
Linux
Fe
Master
Cluster
KV Store
KV
Scheduler Controller
apiserver {}
Master
Cluster
KV Store
KV Pod Pod
Node
Scheduler Controller
apiserver {}
commands
Pod Pod
Node
$kubectl JSON
Nodes
a.k.a. “Minions”
The Kubernetes Workers
Node
Nodes
K
a.k.a. “Minions”
The Kubernetes Workers
Linux
Fe
Node
K
Linux
Fe
K
Node
Kubelet
• The main Kubernetes agent
•
•
•
•
Registers node with cluster
Watches apiserver
Instantiates pods
Reports back to master
K
• Exposes endpoint on :10255
Linux
Fe
Node
Container Engine
Does container management:
• Pulling images
• Starting/stopping containers
• …
K
Pluggable:
• Usually Docker Linux
• Can be rkt Fe
Node
kube-proxy
Kubernetes networking:
• Pod IP addresses
• All containers in a pod
share a single IP
K
• Load balances across all
pods in a service
Linux
Fe
Kubelet
K Main Kubernetes agent
Node
K
Linux
Fe
Kubelet
K Main Kubernetes agent
Node
Container engine K
Docker or rkt
Linux
Fe
Pod Pod Pod Pod
Service
IP: 10.0.0.60
DNS: db.myservice
Container engine K
Docker or rkt
Linux
kube-proxy
Fe
Kubernetes networking
Declarative Model
&
Desired State
Master
KV
apiserver {}
Manifest
file
YAML or JSON
Describe desired
state
Master
KV
apiserver {}
3 x pods
nginx
…
Master
KV
apiserver {}
3 x pods
nginx
…
apiserver {}
Actual state
• 3 x nginx pods
apiserver {}
Actual state
• 2 x nginx pods
apiserver {}
Actual state
• 2 x nginx pods
apiserver {}
Actual state
• 3 x nginx pods
Pod
Pod
Loose Coupling
Pod
Loose Coupling
Pod Pod
Loose Coupling
Pod Pod
Pods and Scaling
Pod Pod
nginx nginx
Pod nginx
nginx
nginx
Pod
nginx
nginx
nginx
Pod
nginx
Pods and Scaling
Pod Pod
nginx nginx
Pod nginx
nginx
nginx
Pod
nginx
nginx
nginx
Pod
nginx
Multi-container Pods
Pod
Web server Log scraper
main sidecar
container container
Multi-container Pods
Pod
Web server Log scraper
main sidecar
container container
Pods are Atomic
Pod
Env
net sidecar
IPC
mount
main
…
Pods are Atomic
Pod Pod
Env
net sidecar
Scale
IPC
mount
main
…
Pods are Atomic
Pod Pod
Env Env
net sidecar net sidecar
IPC IPC
mount mount
main main
… …
#1 Status:ready #2 Status:pending
Pods are Atomic
Pod Pod
Env Env
net sidecar net sidecar
IPC IPC
mount mount
main main
… …
#1 Status:ready #2 Status:pending
Pod Lifecycle
KV
apiserver {}
apiVersion: v1
kind: Pod
metadata:
Pod
xyz
Node Node Node
Deploying Pods
Replication Controller
Pod
…
mnt
IPC
net ...
Services
Node1 Node2 Node3
Pod Pod Pod Pod
fe db fe db
db fe db fe
Pod Pod
db:v1 db:v1
10.0.0.91 10.0.0.44
Pod Pod Pod Pod
Pod Pod
db:v1 db:v2
db:v1
10.0.0.91 10.0.0.44
10.0.0.70
Pod Pod Pod Pod
Pod Pod
db:v2 db:v2
10.0.0.70 10.0.0.53
Pod Pod Pod Pod
Service
IP: 10.0.0.60
DNS: db.myservice
Pod Pod
db:v1 db:v1
10.0.0.91 10.0.0.44
Pod Pod Pod Pod
Service
IP: 10.0.0.60
DNS: db.myservice
Pod Pod
10.0.0.37 10.0.0.100
db:v1 db:v1
10.0.0.61
10.0.0.91 10.0.0.44
Pod Pod Pod Pod
Service
IP: 10.0.0.60
DNS: db.myservice
Pod Pod
10.0.0.37 10.0.0.100
db:v1
db:v1.2 db:v1.2
db:v1
10.0.0.61
10.0.0.113 10.0.0.44
10.0.0.32
Service
Pod
IP: 10.0.0.60
auth
DNS: db.myservice
10.0.0.113
Pod Pod
db db
10.0.0.113 10.0.0.32
Service
Pod
IP: 10.0.0.60
auth
DNS: db.myservice
10.0.0.113
Pod Pod
db db
10.0.0.113 10.0.0.32
Service
IP: 10.0.0.60
DNS: db.myservice
Service
IP: 10.0.0.60
DNS: db.myservice
Only send to healthy pods
Service
IP: 10.0.0.60
DNS: db.myservice
Only send to healthy pods
Can be configured for
session affinity
Service
IP: 10.0.0.60
DNS: db.myservice
Only send to healthy pods
Can be configured for
session affinity
Service Can point to things outside
IP: 10.0.0.60 the cluster
DNS: db.myservice
Only send to healthy pods
Can be configured for
session affinity
Service Can point to things outside
IP: 10.0.0.60 the cluster
DNS: db.myservice Random load balancing
Only send to healthy pods
Can be configured for
session affinity
Service Can point to things outside
IP: 10.0.0.60 the cluster
DNS: db.myservice Random load balancing
Uses TCP by default
Master
KV
apiserver {}
Deployments
Node Node Node Node
Pod Pod Pod Pod
apiVersion: v1
kind: ReplicationController KV
metadata:
name: xyz
spec: apiserver {}
replicas: 4
apiVersion: v1
kind: ReplicationController KV
metadata:
name: xyz
spec: apiserver {}
replicas: 4
apiVersion: v1
kind: ReplicationController KV
metadata:
name: xyz
spec: apiserver {}
replicas: 4
apiVersion: v1
kind: ReplicationController KV
metadata:
name: xyz
spec: apiserver {}
replicas: 4
apiVersion: v1
kind: ReplicationController KV
metadata:
name: xyz
spec: apiserver {}
replicas: 4
apiVersion: extensions/v1beta1
kind: Deployment Simple rolling updates
Spec-once deploy-many metadata: and rollbacks
name: xyz
spec:
replicas: 4
Add features to
Replication Controllers Deployed via the
Versioned
apiserver
(Replica Sets)
Deployed via YAML or
REST objects Self documenting
JSON manifests
apiVersion: extensions/v1beta1
kind: Deployment Simple rolling updates
Spec-once deploy-many metadata: and rollbacks
name: xyz
spec:
replicas: 4
Add features to
Replication Controllers Deployed via the
Versioned
apiserver
(Replica Sets)
Multiple concurrent versions
• Blue-green deployments
• Canary releases
apiVersion: extensions/v1beta1
kind: Deployment Simple rolling updates
metadata: and rollbacks
name: xyz
spec:
replicas: 4
Linux Linux
Fe Fe
Master
KV
{}
Linux Linux
Fe Fe
Node Node
Linux Linux
Fe Fe
Master (control plane)
KV
{}
Linux Linux
Fe Fe
Node Node
Linux Linux
Master (control plane)
Fe Fe
Master (control plane)
KV
Master (control plane)
KV
KV
{}
{}
Linux
Fe {}
Node Linux Node
Fe Linux
Fe
Linux Linux
Fe Fe
Node Node
Cluster Store
Linux Linux
Fe Fe
Master (control plane)
KV
{}
KV
{}
KV
Kubelet
Main Kubernetes agent
{}
{}
Linux
Fe
Node/Minion
Manifest
apiVersion: extensions..
kind: Deployment
metadata: Linux
name: xyz
Fe
spec:
replicas: 4
Pods : Atomic unit of scheduling…
Replication
Objects
Controllers : Scale pods, desired state etc…
in the
K8s API
Deployments : RC + rolling updates, rollbacks…
Installing Kubernetes