Slide 1

Slide 1 text

Kubernetes and the Potential for Higher Level Interfaces Puppet Labs Gareth Rushgrove Ecosystems, APIs and user needs

Slide 2

Slide 2 text

Gareth Rushgrove @garethr

Slide 3

Slide 3 text

Gareth Rushgrove

Slide 4

Slide 4 text

Human and computer interfaces Concepts and demos Ecosystems and interoperability Gareth Rushgrove - - -

Slide 5

Slide 5 text

The User Interface(s) of Kubernetes What do we mean by user and interface?

Slide 6

Slide 6 text

The user context matters Gareth Rushgrove

Slide 7

Slide 7 text

Creating Consuming Gareth Rushgrove - -

Slide 8

Slide 8 text

Developers Operators Gareth Rushgrove - -

Slide 9

Slide 9 text

Building something new Running in production Gareth Rushgrove - -

Slide 10

Slide 10 text

Team size Regulation/compliance Multi-tenancy Infrastructure size Skills and experience Gareth Rushgrove - - - - -

Slide 11

Slide 11 text

Gareth Rushgrove Gareth Rushgrove

Slide 12

Slide 12 text

kubectl is a user interface Gareth Rushgrove

Slide 13

Slide 13 text

YAML is a user interface Gareth Rushgrove

Slide 14

Slide 14 text

Gareth Rushgrove Dashboard is a user interface Gareth Rushgrove

Slide 15

Slide 15 text

The API is a user interface Gareth Rushgrove

Slide 16

Slide 16 text

Client libraries are a user interface Gareth Rushgrove

Slide 17

Slide 17 text

Different interfaces are useful in different contexts Gareth Rushgrove

Slide 18

Slide 18 text

Different people might use different interfaces to achieve different tasks Gareth Rushgrove

Slide 19

Slide 19 text

Out of the box Just enough user interface

Slide 20

Slide 20 text

kubectl Gareth Rushgrove

Slide 21

Slide 21 text

$ kubectl controls the Kubernetes cluster manager. Find more information at https://github.com/kubernetes/kubernetes. Usage: kubectl [flags] kubectl [command] Available Commands: get Display one or many resources describe Show details of a specific resource or group of resources create Create a resource by filename or stdin replace Replace a resource by filename or stdin. patch Update field(s) of a resource by stdin. delete Delete resources by filenames, stdin, resources and names, or by resources and label selector. edit Edit a resource on the server A universal interface for actions on a Kubernetes cluster Gareth Rushgrove

Slide 22

Slide 22 text

Gareth Rushgrove

Slide 23

Slide 23 text

YAML Gareth Rushgrove

Slide 24

Slide 24 text

template: metadata: labels: app: guestbook tier: frontend spec: containers: - name: php-redis image: gcr.io/google_samples/gb-frontend:v4 resources: requests: cpu: 100m memory: 100Mi env: - name: GET_HOSTS_FROM value: dns # If your cluster config does not include a dns service, then to A data format describing desired state Gareth Rushgrove

Slide 25

Slide 25 text

API wire format as user interface Gareth Rushgrove

Slide 26

Slide 26 text

But isn’t YAML declarative? And other user interface tales

Slide 27

Slide 27 text

Yes Gareth Rushgrove

Slide 28

Slide 28 text

Code plus data has advantages over data alone Gareth Rushgrove

Slide 29

Slide 29 text

The language to represent the data should be a simple, data-only format such as JSON or YAML, and programmatic modification of this data should be done in a real programming language Gareth Rushgrove Borg, Omega, and Kubernetes, ACM Queue, Volume 14, issue 1 http://queue.acm.org/detail.cfm?id=2898444 “

Slide 30

Slide 30 text

Avoid repetition Combine external inputs Correctness Abstractions Gareth Rushgrove - - - -

Slide 31

Slide 31 text

So why are so many people hand writing YAML? Gareth Rushgrove

Slide 32

Slide 32 text

Changes with kubectle patch diverge from the model $ kubectl patch --help Update field(s) of a resource using strategic merge patch JSON and YAML formats are accepted. Usage: kubectl patch (-f FILENAME | TYPE NAME) -p PATCH [flags] Examples: # Partially update a node using strategic merge patch kubectl patch node k8s-node-1 -p '{"spec":{"unschedulable":true}}' Gareth Rushgrove

Slide 33

Slide 33 text

$ kubectl apply --help Apply a configuration to a resource by filename or stdin. JSON and YAML formats are accepted. Usage: kubectl apply -f FILENAME [flags] Examples: # Apply the configuration in pod.json to a pod. $ kubectl apply -f ./pod.json And kubectl apply requires the full object serialisation Gareth Rushgrove

Slide 34

Slide 34 text

A familiar Kubernetes Pod definition in YAML Gareth Rushgrove

Slide 35

Slide 35 text

What happens if you run the same YAML file twice? Gareth Rushgrove

Slide 36

Slide 36 text

How many times do you have to repeat the same label? Gareth Rushgrove

Slide 37

Slide 37 text

kubectl is actually pretty low-level Gareth Rushgrove

Slide 38

Slide 38 text

kubectl get pod mypod -o yaml \ | sed 's/\(image: myimage\):.*$/\1:v4/' \ | kubectl replace -f - This is from the official kubectl help. It pipes to sed. Gareth Rushgrove

Slide 39

Slide 39 text

Declarative code with an idempotent runtime model Gareth Rushgrove

Slide 40

Slide 40 text

Describe what you want Gareth Rushgrove

Slide 41

Slide 41 text

Converge from any state Gareth Rushgrove

Slide 42

Slide 42 text

The same Kubernetes Pod described in Puppet Gareth Rushgrove

Slide 43

Slide 43 text

$ puppet apply examples/init.pp --test Info: Loading facts Notice: Compiled catalog for gareths in environment production in 1.24 seconds Info: Applying configuration version '1453298602' Info: Checking if sample-pod exists Info: Creating kubernetes_pod sample-pod Notice: /Stage[main]/Main/Kubernetes_pod[sample-pod]/ensure: created Notice: Applied catalog in 0.23 seconds Running without that Pod already existing will create it Gareth Rushgrove

Slide 44

Slide 44 text

Running a second time, nothing changes because the Pod already exists Gareth Rushgrove $ puppet apply examples/init.pp --test Info: Loading facts Notice: Compiled catalog for garethr in environment production in 1.33 seconds Info: Applying configuration version '1453298688' Info: Checking if sample-pod exists Notice: Applied catalog in 0.15 seconds

Slide 45

Slide 45 text

$ puppet resource kubernetes_pod sample-pod kubernetes_pod { 'sample-pod': ensure => 'present', metadata => { 'creationTimestamp' => '2016-01-20T14:03:23Z', 'name' => 'sample-pod', 'namespace' => 'default', 'resourceVersion' => '4579', 'selfLink' => '/api/v1/namespaces/default/pods/sample-pod’, 'uid' => '91c8a550-bf7e-11e5-816e-42010af001b1' }, spec => { 'containers' => [{ ‘image' => 'nginx', 'imagePullPolicy' => 'IfNotPresent', 'name' => ‘container-name', 'resources' => {'requests' => {'cpu' => '100m'}}, 'terminationMessagePat [{'mountPath' => '/var/run/secrets/kubernetes.io/serviceaccount', 'name' 'dnsPolicy' => 'ClusterFirst', 'nodeName' => 'gke-guestbook-dc15a31a-nod puppet resource allows for interrogating an existing Kubernetes installation Gareth Rushgrove

Slide 46

Slide 46 text

$ kubectl describe pod sample-pod Name: sample-pod Namespace: default Image(s): nginx Node: gke-guestbook-dc15a31a-node-fyb6/10.240. Start Time: Wed, 20 Jan 2016 14:03:23 +0000 Labels: Status: Running Reason: Message: IP: 10.24.1.7 Replication Controllers: Containers: container-name: Container ID: docker://542389c5b2a98616ba3a8001029bc4a3f00d7c0 Image: nginx Image ID: docker://407195ab8b07 The same information is still accessible via other tooling Gareth Rushgrove

Slide 47

Slide 47 text

Other programming languages exist Gareth Rushgrove

Slide 48

Slide 48 text

DEMO

Slide 49

Slide 49 text

Gareth Rushgrove More details on the official Kubernetes blog Gareth Rushgrove

Slide 50

Slide 50 text

Imperative Interfaces Pragmatism and familiarity

Slide 51

Slide 51 text

Gareth Rushgrove

Slide 52

Slide 52 text

Gareth Rushgrove Deis is an open source PaaS that provides a Heroku- inspired workflow, using Kubernetes under the hood Gareth Rushgrove

Slide 53

Slide 53 text

Interactive CLI to login Gareth Rushgrove $ deis login http://deis.example.com username: deis password: Logged in as deis

Slide 54

Slide 54 text

Create configs locally with the CLI Gareth Rushgrove $ deis create Creating application... done, created boring-huntress Git remote deis added

Slide 55

Slide 55 text

$ git push deis master Counting objects: 95, done. Delta compression using up to 8 threads. Compressing objects: 100% (52/52), done. Writing objects: 100% (95/95), 20.24 KiB | 0 bytes/s, done. Total 95 (delta 41), reused 85 (delta 37) -----> Ruby app detected -----> Compiling Ruby/Rack -----> Using Ruby version: ruby-1.9.3 -----> Installing dependencies using 1.5.2 Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment Fetching gem metadata from http://rubygems.org/.......... Fetching additional metadata from http://rubygems.org/.. Using bundler (1.5.2) Installing tilt (1.3.6) Installing rack (1.5.2) The switch to Git for deployment Gareth Rushgrove

Slide 56

Slide 56 text

Set config using CLI Gareth Rushgrove $ deis config:set FOO=1 BAR=baz && deis config:pull $ cat .env FOO=1 BAR=baz $ echo "TIDE=high" >> .env $ deis config:push Creating config... done, v4 === yuppie-earthman DEIS_APP: yuppie-earthman FOO: 1 BAR: baz TIDE: high

Slide 57

Slide 57 text

$ deis scale web=8 Scaling processes... but first, coffee! done in 20s === boring-huntress Processes --- web: web.1 up (v2) web.2 up (v2) web.3 up (v2) web.4 up (v2) web.5 up (v2) web.6 up (v2) web.7 up (v2) web.8 up (v2) Scale using the CLI Gareth Rushgrove

Slide 58

Slide 58 text

Replication Controllers, Services and Pods are implementation details Gareth Rushgrove

Slide 59

Slide 59 text

Kubernetes is an implementation details from the point of view of the user Gareth Rushgrove

Slide 60

Slide 60 text

Kubernetes is NOT an implementation details from the point of view of the administrator Gareth Rushgrove

Slide 61

Slide 61 text

The advantages of familiarity Gareth Rushgrove

Slide 62

Slide 62 text

The challenges of git as a user interface Gareth Rushgrove

Slide 63

Slide 63 text

Ecosystems and Interoperability Everyone can play together

Slide 64

Slide 64 text

Gareth Rushgrove

Slide 65

Slide 65 text

Package management Gareth Rushgrove

Slide 66

Slide 66 text

Gareth Rushgrove Helm, a package manager for Kubernetes Gareth Rushgrove

Slide 67

Slide 67 text

$ helm install redis-cluster ---> Running `kubectl create -f` ... services/redis-sentinel pods/redis-master replicationcontrollers/redis replicationcontrollers/redis-sentinel ---> Done Help provides distribution tools, plus wraps kubectl Gareth Rushgrove

Slide 68

Slide 68 text

Helm as a user interface Gareth Rushgrove

Slide 69

Slide 69 text

Gareth Rushgrove Charts as a place to share low level descriptions Gareth Rushgrove

Slide 70

Slide 70 text

name: jenkins home: https://jenkins-ci.org/ version: 0.2.0 description: The leading open-source continuous integration server. maintainers: - Matt Fisher details: Jenkins is the leading open-source continuous integration server. Chart.yaml metadata format Gareth Rushgrove

Slide 71

Slide 71 text

Gareth Rushgrove Or, what is the Kubernetes equivalent to MPM metadata? Gareth Rushgrove

Slide 72

Slide 72 text

The importance of sharing metadata Gareth Rushgrove

Slide 73

Slide 73 text

Metadata as a first class user interface Gareth Rushgrove

Slide 74

Slide 74 text

If the API is the point of interoperability, how can it evolve safely? Gareth Rushgrove

Slide 75

Slide 75 text

Gareth Rushgrove Swagger is a specification for describing APIs Gareth Rushgrove

Slide 76

Slide 76 text

Gareth Rushgrove Now being developed by the Open API Initiative Gareth Rushgrove

Slide 77

Slide 77 text

"type": "integer", "format": "int32", "description": "The port on each node on which this service is exposed when type=NodePort or LoadBalancer. Usually assigned by the system. If specified, it will be allocated to the service if unused or else creation of the service will fail. Default is to auto-allocate a port if the ServiceType of this Service requires one. More info: http://releases.k8s.io/HEAD/docs/user- guide/services.md#type--nodeport" } } }, "v1.ServiceStatus": { "id": "v1.ServiceStatus", "description": "ServiceStatus represents the current status of a service.", "properties": { "loadBalancer": { "$ref": "v1.LoadBalancerStatus", "description": "LoadBalancer contains the current status of the load-balancer, if one is present." The Kubernetes API spec is ~14,000 lines of JSON Gareth Rushgrove

Slide 78

Slide 78 text

Some client libraries, including the Puppet module, are generated from the Swagger spec Gareth Rushgrove

Slide 79

Slide 79 text

Gareth Rushgrove

Slide 80

Slide 80 text

Standards mean going slow in the right places Gareth Rushgrove

Slide 81

Slide 81 text

So we can go fast everywhere else Gareth Rushgrove

Slide 82

Slide 82 text

Conclusions Why Kubernetes as a platform

Slide 83

Slide 83 text

Interoperable because of a stable set of APIs Gareth Rushgrove

Slide 84

Slide 84 text

Platforms exposing high level interfaces, without limiting access to lower level ones Gareth Rushgrove

Slide 85

Slide 85 text

Allow for different use-cases and different life-cycles on the same infrastructure Gareth Rushgrove

Slide 86

Slide 86 text

Questions? And thanks for listening