So, I have all these containers! Now what?
Image by Connie Zhou
Developer View job hello_world = { runtime = { cell = 'ic' } // Cell (cluster) to run in binary = '.../hello_world_webserver' // Program to run args = { port = '%port%' } // Command line parameters requirements = { // Resource requirements ram = 100M disk = 100M cpu = 0.1 } 10000 replicas = 5 // Number of tasks } @tekgrrl #europython #kubernetesio
Developer View @tekgrrl #europython #kubernetesio
Binary Config Developer View file web browsers borgcfg web browsers BorgMaster What just BorgMaster UI shard BorgMaster UI shard BorgMaster UI shard BorgMaster UI shard UI shard happened? persistent store Scheduler scheduler (Paxos) link shard link shard link shard link shard link shard Borglet Borglet Borglet Borglet @tekgrrl #europython #kubernetesio
Hello world! Hello Hello Hello Hello world! world! Hello Hello Hello Hello Hello Hello world! world! Hello Hello world! world! Hello Hello Hello Hello world! world! world! world! Hello Hello Hello Hello Hello world! world! world! world! Hello Hello Hello world! Hello world! Hello Hello Hello Hello world! world! Hello Hello world! world! Hello world! Hello Hello world! world! world! world! Hello Hello world! Hello world! world! world! world! world! Hello Hello world! world! world! Hello world! world! Hello Hello world! Hello Hello world! Hello world! Hello world! Hello Hello world! world! Hello world! world! world! world! Hello world! world! world! world! Image by Connie Zhou
Developer View @tekgrrl #europython #kubernetesio
Failures task-eviction rates and causes @tekgrrl #europython #kubernetesio
Efficiency Advanced bin- packing algorithms Experimental placement of production VM workload, July 2014 one stranded resources available resources machine @tekgrrl #europython #kubernetesio
Efficiency Multiple applications per machine CPI^2 paper, EuroSys 2013 tasks per machine @tekgrrl #europython #kubernetesio
Efficiency Resource reclamation limit: amount of resource requested potentially reusable resources reservation: estimate of future usage usage: actual resource consumption time @tekgrrl #europython #kubernetesio
Observations: 1. If your developers are spending time thinking about individual machines , you’re operating at too low-level of an abstraction . You want to operate at the level of applications 2. We get efficiency by: a. sharing resources b. reclaiming unused allocations 3. Containers make users more productive http://kubernetes.io http://goo.gl/1C4nuo (Borg paper) Images by Connie Zhou
Guestbook App MySQL php Client php php Python memcached @tekgrrl #europython #kubernetesio
Containers
Old Way: Shared Machines No isolation No namespacing app app Common libs app app Highly coupled apps and OS libs kernel @tekgrrl #europython #kubernetesio
Old Way: Virtual Machines Some isolation Inefficient app app libs libs Still highly coupled to the guest OS kernel kernel Hard to manage app app libs libs kernel kernel @tekgrrl #europython #kubernetesio
New Way: Containers app app libs libs app app libs libs kernel @tekgrrl #europython #kubernetesio
Docker Example Docker PHP & Apache Memcached MySQL Engine libs libs libs libs Debian Server @tekgrrl #europython #kubernetesio
Why containers? • Performance • Repeatability • Quality of service • Accounting • Portability A fundamentally different way of managing applications Images by Connie Zhou
Demo
Kubernetes
Kubernetes Greek for “Helmsman” ; also the root of the word “Governor” • Orchestrator for Docker containers • Supports multi-cloud environments • Inspired and informed by Google’s experiences and internal systems • Open source , written in Go Manage applications, not machines @tekgrrl #europython #kubernetesio
Concepts Intro Container Pod Service Volume Replication Controller Label Node @tekgrrl #europython #kubernetesio
Kubernetes Cluster Kubelet Proxy Kubelet Proxy Kubernetes Master Kubelet Proxy Pod Pod Replication Pod Pod Scheduler Controller Container Container Pod Pod Container Container Container Container Container Container Container Container Container Container Container Container Container Container Container Container Container API Server Kubernetes Node Kubernetes Node Kubernetes Node @tekgrrl #europython #kubernetesio
Cluster Options From Laptop to high-availability multi-node cluster Hosted or self managed On-Premise or Cloud Bare Metal or Virtual Machines Many options, See Matrix for details Kubernetes Cluster Matrix: http://bit.ly/1MmhpMW @tekgrrl #europython #kubernetesio
Pods Consumers The atom of scheduling for containers Application specific “logical host” Ephemeral • can die and be replaced Web Server Single container pods can be created directly from a container image Volume Pod @tekgrrl #europython #kubernetesio
Pods Github Consumers Can be used to group containers & shared volumes Containers are tightly coupled Git Node.js App Shared namespace Synchronizer Container • Shared network IP and port namespace Ephemeral • Containers in pods live and die together Volume Pod Think in terms of services that you usually run on the same machine @tekgrrl #europython #kubernetesio
Volume Bound to the Pod that encloses it Look like Directories to Containers What and where they are determined by Volume Type Many Volume Type options Pod EmptyDir ● Lives with the pod ○ Can be backed by ○ Memory (tmpfs) @tekgrrl #europython #kubernetesio
Volume Bound to the Pod that encloses it Look like Directories to Containers What and where they are determined by Volume Type Many Volume Type options Pod EmptyDir ● HostPath ● /<rootdir> Maps to directory on host ○ | |__/etc Use with caution ○ |--/usr |--/var | |--/log @tekgrrl #europython #kubernetesio
Volume Bound to the Pod that encloses it Look like Directories to Containers What and where they are determined by Volume Type Many Volume Type options Pod EmptyDir ● HostPath ● nfs (and similar services) ● NFS @tekgrrl #europython #kubernetesio
Volume Bound to the Pod that encloses it Look like Directories to Containers What and where they are determined by Volume Type Many Volume Type options Pod EmptyDir ● HostPath ● nfs (and similar services) ● Cloud Provider Persistent Block Storage ● @tekgrrl #europython #kubernetesio
Sidecar Pattern Github Consumers Git Node.js App Synchronizer Container Volume Pod @tekgrrl #europython #kubernetesio
Ambassador Pattern Consumers Redis Shards PHP App Redis Proxy localhost Pod @tekgrrl #europython #kubernetesio
Adapter Pattern Monitoring System Redis Redis Exporter localhost OR Volume Pod @tekgrrl #europython #kubernetesio
Labels Dashboard Dashboard Pod Pod Pod Pod Pod frontend frontend show: type = FE show: version = v2 type = FE type = FE version = v2 version = v2 Behavior Benefits Metadata with semantic meaning Allow for intent of many users (e.g. dashboards) ● ➔ Membership identifier Build higher level systems … ● ➔ The only Grouping Mechanism Queryable by Selectors ● ➔ @tekgrrl #europython #kubernetesio
Replication Controllers Replication Replication Replication Controller Controller Controller Pod Pod Pod Pod Pod #pods = 1 #pods = 2 frontend frontend version = v2 version = v1 version= v1 version = v1 version = v2 show: version = v2 show: version = v2 Behavior Benefits Keeps Pods running Recreates Pods, maintains desired state ● ➔ Gives direct control of Pod #s Fine-grained control for scaling ● ➔ Grouped by Label Selector Standard grouping semantics ● ➔ @tekgrrl #europython #kubernetesio
Replication Controller Replication Controllers Canonical example of control loops Replication Controller Have one job: ensure N copies of a pod - Name = “nifty-rc” if too few, start new ones - Selector = {“App”: “Nifty”} ● - PodTemplate = { ... } if too many, kill some ● - NumReplicas = 4 group == selector ● Replicated pods are fungible How Start 1 How many? more many? No implied order or identity ● 4 3 OK API Server @tekgrrl #europython #kubernetesio
Container Liveness Process Level: Kubelet checks with Docker that Container is running App Level: User defined health checks: HTTP Health checks (Kubelet calls ● a Web Hook) Container Exec (Kubelet runs ● command in container) TCP Socket (Kubelet attempts to ● open a socket to the container) Image: IStockPhoto @tekgrrl #europython #kubernetesio
Recommend
More recommend