Slide 1

Slide 1 text

Automating Stateful Applications with Kubernetes Operators Jan Kleinert [email protected] September 23, 2019

Slide 2

Slide 2 text

@jankleinert 2 Jan Kleinert Developer Advocate, Red Hat twitter/github: @jankleinert Hello!

Slide 3

Slide 3 text

@jankleinert 3 What is Kubernetes? An open source orchestration system for managing containerized workloads across a cluster of nodes.

Slide 4

Slide 4 text

@jankleinert 4 Pod Deployment DaemonSet ReplicaSet StatefulSet Job Kubernetes objects are persistent entities that represent the state of your cluster that you can manage with the K8s API EndPoints Ingress Service ConfigMap Secret StorageClass Namespace NetworkPolicy PersistentVolume Role RoleBinding ServiceAccount Understanding Kubernetes objects

Slide 5

Slide 5 text

@jankleinert 5 Kubernetes Object Definitions kind: Pod apiVersion: v1 metadata: name: example-app spec: containers: - name: example image: quay.io/my/app:v1.2.0 [...]

Slide 6

Slide 6 text

@jankleinert 6 Why should you care about operators?

Slide 7

Slide 7 text

@jankleinert 7 Scaling stateless apps: easy

Slide 8

Slide 8 text

@jankleinert 8 $ kubectl scale deploy/staticweb --replicas=3

Slide 9

Slide 9 text

@jankleinert 9 scale up count=1 desired=3 ReplicaSet

Slide 10

Slide 10 text

@jankleinert 10 start count=3 desired=3 ReplicaSet

Slide 11

Slide 11 text

@jankleinert 11 What about apps that store data?

Slide 12

Slide 12 text

@jankleinert 12 Creating a database is easy

Slide 13

Slide 13 text

@jankleinert 13 $ kubectl run db --image=quay.io/my/db

Slide 14

Slide 14 text

@jankleinert 14 Running a database over time is harder

Slide 15

Slide 15 text

@jankleinert 15 ⏣ Resize/Upgrade ⏣ Reconfigure ⏣ Backup ⏣ Healing

Slide 16

Slide 16 text

@jankleinert 16 Every application on any platform must be installed, configured, managed, and upgraded over time Patching is critical to security

Slide 17

Slide 17 text

@jankleinert 17 Anything not automated is slowing you down

Slide 18

Slide 18 text

@jankleinert 18 If only Kubernetes knew...

Slide 19

Slide 19 text

@jankleinert 19

Slide 20

Slide 20 text

@jankleinert 20

Slide 21

Slide 21 text

@jankleinert 21 Operators are automated software managers that deal with installation and lifecycle of Kubernetes applications

Slide 22

Slide 22 text

@jankleinert 22 1. Application-specific custom controllers 2. Custom resource definitions (CRD) Extending the Kubernetes API

Slide 23

Slide 23 text

@jankleinert 23 The Operator Pattern K8S API CUSTOM RESOURCE & MY APP STATE WATCH EVENTS RECONCILE MY K8S APPLICATION Controller

Slide 24

Slide 24 text

@jankleinert 24 Application-Specific Controllers

Slide 25

Slide 25 text

@jankleinert 25 Custom Resource Definition (CRD) kind: ProductionReadyDatabase apiVersion: database.example.com/v1alpha1 metadata: name: my-production-ready-database spec: clusterSize: 3 readReplicas: 2 version: v4.0.1 [...]

Slide 26

Slide 26 text

@jankleinert 26 { }

Slide 27

Slide 27 text

@jankleinert 27 What is etcd? Example: etcd Operator ● distributed key-value store ● primary datastore of Kubernetes ● stores and replicates all Kubernetes cluster state

Slide 28

Slide 28 text

@jankleinert 28 Example: etcd Operator kind: EtcdCluster apiVersion: etcd.database.coreos.com/v1beta2 metadata: name: example-etcd-cluster spec: size: 3 version: "3.1.0"

Slide 29

Slide 29 text

@jankleinert 29 Example: etcd Operator

Slide 30

Slide 30 text

@jankleinert 30

Slide 31

Slide 31 text

@jankleinert 31 https://learn.openshift.com/operatorframework/ Try It! Hands-On Operator Tutorials

Slide 32

Slide 32 text

@jankleinert 32 Use Operators Today OperatorHub.io is a home for the Kubernetes community to share Operators. Find an existing Operator or list your own today.

Slide 33

Slide 33 text

@jankleinert 33 https://github.com/operator-framework

Slide 34

Slide 34 text

@jankleinert 34

Slide 35

Slide 35 text

@jankleinert 35

Slide 36

Slide 36 text

@jankleinert 36

Slide 37

Slide 37 text

@jankleinert 37 Operator Maturity Model Phase I Phase II Phase III Phase IV Phase V Basic Install Automated application provisioning and configuration management Seamless Upgrades Patch and minor version upgrades supported Full Lifecycle App lifecycle, storage lifecycle (backup, failure recovery) Deep Insights Metrics, alerts, log processing and workload analysis Auto Pilot Horizontal/vertical scaling, auto config tuning, abnormal detection, scheduling tuning

Slide 38

Slide 38 text

@jankleinert 38 https://github.com/operator-framework https://coreos.com/operators/ https://operatorhub.io https://coreos.com/blog/introducing-operator-framework https://learn.openshift.com/operatorframework/ Resources

Slide 39

Slide 39 text

linkedin.com/company/red-hat youtube.com/user/RedHatVideos facebook.com/redhatinc twitter.com/RedHat Red Hat is the world’s leading provider of enterprise open source software solutions. Award-winning support, training, and consulting services make Red Hat a trusted adviser to the Fortune 500. Thank you 39