Slide 1

Slide 1 text

Managing Kubernetes with Puppet Puppet Labs Gareth Rushgrove Declarative code for Pods, Services and ReplicationControllers

Slide 2

Slide 2 text

Gareth Rushgrove @garethr

Slide 3

Slide 3 text

Gareth Rushgrove

Slide 4

Slide 4 text

Human vs computer interfaces Concepts and demos Alternatives and interoperability Gareth Rushgrove - - -

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

Yes Gareth Rushgrove

Slide 7

Slide 7 text

But code has advantages over just data Gareth Rushgrove

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

And context matters to the user interface 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

Also 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 12

Slide 12 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 13

Slide 13 text

Puppet A programming language for infrastructure

Slide 14

Slide 14 text

Declarative code with an idempotent runtime model Gareth Rushgrove

Slide 15

Slide 15 text

Describe what you want Gareth Rushgrove

Slide 16

Slide 16 text

Converge from any state Gareth Rushgrove

Slide 17

Slide 17 text

A familiar Kubernetes Pod definition in YAML Gareth Rushgrove

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

kubectl is actually pretty low-level Gareth Rushgrove

Slide 21

Slide 21 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 22

Slide 22 text

The same Kubernetes Pod described in Puppet Gareth Rushgrove

Slide 23

Slide 23 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 24

Slide 24 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 25

Slide 25 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 26

Slide 26 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 27

Slide 27 text

kubernetes_pod kubernetes_service kubernetes_replication_controller kubernetes_node kubernetes_event kubernetes_endpoint kubernetes_namespace Gareth Rushgrove - - - - - - - kubernetes_secret kubernetes_resource_quota kubernetes_limit_range kubernetes_peristent_volume kubernetes_persistent_volume_claim kubernetes_component_status kubernetes_service_account - - - - - - - - Support for most of the Kubernetes primitives Gareth Rushgrove

Slide 28

Slide 28 text

DEMO

Slide 29

Slide 29 text

Reporting Change control Static analysis/unit testing tools Access control Gareth Rushgrove - - - - Not mentioning other features that come in handy

Slide 30

Slide 30 text

Alternatives and interoperability Why options are a good thing

Slide 31

Slide 31 text

Deis, OpenShift, Fabric8, Kubectl, Helm, Deployment Manager, Dashboard… Gareth Rushgrove

Slide 32

Slide 32 text

Interoperable because of a stable set of primitives Gareth Rushgrove

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

The Puppet interface targets operations use-cases where managing a model over time is useful Gareth Rushgrove

Slide 35

Slide 35 text

Gareth Rushgrove The Puppet Kubernetes module is available on GitHub and on the Puppet Forge Gareth Rushgrove

Slide 36

Slide 36 text

Gareth Rushgrove More details on the official Kubernetes blog Gareth Rushgrove

Slide 37

Slide 37 text

Questions? And thanks for listening