Cloud-Native Streaming Platform: Apache Kafka Meets Kubernetes

A presentation at Oracle Code One 2018 in October 2018 in San Francisco, CA, USA by Viktor Gamov

Slide 1

Slide 1

Cloud-Native Streaming Platform: Apache Kafka Meets Kubernetes @gamussa #OracleCodeOne @confluentinc

Slide 2

Slide 2

#devkafkaops @gamussa #OracleCodeOne @ @confluentinc

Slide 3

Slide 3

@gamussa #OracleCodeOne @confluentinc

Slide 4

Slide 4

https://twitter.com/kelseyhightower/status/963413508300812295 @gamussa #OracleCodeOne @ @confluentinc

Slide 5

Slide 5

https://twitter.com/kelseyhightower/status/963414038603427840 @gamussa #OracleCodeOne @ @confluentinc

Slide 6

Slide 6

Don’t despair Not even over the fact that you don’t despair -= Franz Kafka =@gamussa #OracleCodeOne @ @confluentinc

Slide 7

Slide 7

Kafka Streaming Architecture Fundamentals

Slide 8

Slide 8

@gamussa #OracleCodeOne @ @confluentinc

Slide 9

Slide 9

@gamussa #OracleCodeOne @ @confluentinc

Slide 10

Slide 10

@

Slide 11

Slide 11

Kafka as Microservices Backbone HTTP etc Online Offline Billing Inventory @gamussa Fulfillment #OracleCodeOne @ Finance @confluentinc Fraud

Slide 12

Slide 12

High-level Architecture Application Application Application Native Client library Kafka Streams Load Balancer * REST Proxy Schema Registry Kafka Brokers @gamussa Kafka Connect Zookeeper Nodes #OracleCodeOne @ @confluentinc

Slide 13

Slide 13

Bare minimum Kafka Brokers @gamussa Zookeeper Nodes #OracleCodeOne @ @confluentinc

Slide 14

Slide 14

Shard data to get scalability Producer (1) Producer (2) Producer (3) Messages are sent to different partitions Cluster of machines Partitions live on different machines @gamussa #OracleCodeOne @confluentinc

Slide 15

Slide 15

Linearly Scalable Architecture Producers Single topic: - Many producers machines - Many consumer machines - Many Broker machines No Bottleneck!! Consumers @gamussa #OracleCodeOne @confluentinc

Slide 16

Slide 16

Replicate to get fault tolerance leader msg Machine A @gamussa Machine B replicate msg #OracleCodeOne @confluentinc

Slide 17

Slide 17

Replication provides resiliency A ‘replica’ takes over on machine failure @gamussa #OracleCodeOne @confluentinc

Slide 18

Slide 18

Kubernetes Fundamentals

Slide 19

Slide 19

Microservices Docker Kubernetes Monolith @gamussa #OracleCodeOne @ @confluentinc

Slide 20

Slide 20

https://twitter.com/sahrizv/status/1018184792611827712 @gamussa #OracleCodeOne @ @confluentinc

Slide 21

Slide 21

@gamussa #OracleCodeOne @ @confluentinc

Slide 22

Slide 22

Orchestration Compute Networking Storage Service Discovery @gamussa #OracleCodeOne @ @confluentinc

Slide 23

Slide 23

Kubernetes Schedules and allocates resources Networking between Pods Storage Service Discovery @gamussa #OracleCodeOne @ @confluentinc

Slide 24

Slide 24

Refresher - Kubernetes Architecture kubectl https://thenewstack.io/kubernetes-an-overview/ @gamussa #OracleCodeOne @ @confluentinc

Slide 25

Slide 25

Pod Basic Unit of Deployment in Kubernetes A collection of containers sharing: Namespace Network Volumes @gamussa #OracleCodeOne @ @confluentinc

Slide 26

Slide 26

Storage Persistent Volume (PV) & Persistent Volume Claim (PVC) Both PV and PVC are ‘resources’ @gamussa #OracleCodeOne @ @confluentinc

Slide 27

Slide 27

Storage Persistent Volume (PV) & Persistent Volume Claim (PVC) PV is a piece of storage that is provisioned dynamic or static of any individual pod that uses the PV @gamussa #OracleCodeOne @ @confluentinc

Slide 28

Slide 28

Storage Persistent Volume (PV) & Persistent Volume Claim (PVC) PVC is a request for storage by a User @gamussa #OracleCodeOne @ @confluentinc

Slide 29

Slide 29

Storage Persistent Volume (PV) & Persistent Volume Claim (PVC) PVCs consume PV @gamussa #OracleCodeOne @ @confluentinc

Slide 30

Slide 30

Stateful Workloads

Slide 31

Slide 31

StatefulSet Rely on Headless Service to provide network identity Headless Service Ideal for highly available stateful workloads @gamussa Pod-0 Pod-2 Containers Containers Containers Volumes Volumes Volumes #OracleCodeOne @ Pod-1 @confluentinc

Slide 32

Slide 32

StatefulSet Rely on Headless Service to provide network identity @gamussa Headless Service Pod-0 Pod-2 Containers Containers Containers Volumes Volumes Volumes #OracleCodeOne @ Pod-1 @confluentinc

Slide 33

Slide 33

StatefulSet Ideal for highly available stateful workloads @gamussa Headless Service Pod-0 Pod-2 Containers Containers Containers Volumes Volumes Volumes #OracleCodeOne @ Pod-1 @confluentinc

Slide 34

Slide 34

Workloads Deployment @gamussa #OracleCodeOne @confluentinc

Slide 35

Slide 35

Helm Charts @gamussa #OracleCodeOne @ @confluentinc

Slide 36

Slide 36

Helm Charts @gamussa #OracleCodeOne @ @confluentinc

Slide 37

Slide 37

Helm Charts @gamussa #OracleCodeOne @ @confluentinc

Slide 38

Slide 38

https://cnfl.io/helm_video @gamussa #OracleCodeOne @confluentinc

Slide 39

Slide 39

Basic components are not enough @gamussa #OracleCodeOne @confluentinc

Slide 40

Slide 40

Kafka deployment checklist PVC for Storage Uses ZK Headless Svc StatefulSet for 3-node zk PVC for Storage Optional Pod Anti-Affinity to spread the ZK ensemble across nodes StatefulSet for n-node Kafka Headless Service A group of NodePort Services for external traffic ConfigMap for Prometheus JMX exporter ConfigMap for Prometheus JMX exporter @gamussa #OracleCodeOne @ @confluentinc

Slide 41

Slide 41

Kafka Kubernetes journey: Step 1 https://cnfl.io/cp-helm @gamussa #OracleCodeOne @ @confluentinc

Slide 42

Slide 42

Let’s see some YAML!

Slide 43

Slide 43

Meet Kubernetes Operator @gamussa #OracleCodeOne @ @confluentinc

Slide 44

Slide 44

Kubernetes Operator Embedded with operational knowledge of both data software and Kubernetes Backup/restore Scale up/down Rebalance data Regular health checks @gamussa #OracleCodeOne @ @confluentinc

Slide 45

Slide 45

Controller Brain behind Kubernetes resources e.g. replication controller, namespace controller etc. @gamussa #OracleCodeOne @ @confluentinc

Slide 46

Slide 46

Custom Resource Definition(CRD) Extend existing Kubernetes API API StatefulSet ReplicaSet ... CRD Controller StatefulSet Controller ReplicaSet Controller ... Custom Controller ReplicaSet ... Custom Resource Instance @gamussa StatefulSet #OracleCodeOne @ @confluentinc

Slide 47

Slide 47

Custom Resource Definition(CRD) Usually works together Custom Controller API StatefulSet ReplicaSet ... CRD Controller StatefulSet Controller ReplicaSet Controller ... Custom Controller ReplicaSet ... Custom Resource Instance @gamussa StatefulSet #OracleCodeOne @ @confluentinc

Slide 48

Slide 48

Custom Resource Definition(CRD) Users can create and access Customer Resources with kubectl, just as they do for built-in API StatefulSet ReplicaSet ... CRD Controller StatefulSet Controller ReplicaSet Controller ... Custom Controller ReplicaSet ... Custom Resource Instance StatefulSet resources like pods. @gamussa #OracleCodeOne @ @confluentinc

Slide 49

Slide 49

Operator Deploy and Manage your production streaming platform with Confluent Operator. Automated Provisioning Platform Operations Resiliency Monitoring @gamussa #OracleCodeOne @ @confluentinc

Slide 50

Slide 50

Confluent Platform Reference Architecture Each Confluent Platform component has specific characteristics: Security (SSL certificates) DNS names and zones Application Application Application Native Client library Kafka Streams Load Balancer * Schema Registry REST Proxy Kafka Connect Host selection Fault tolerance Zookeeper Nodes Kafka Brokers Scaling @gamussa #OracleCodeOne @ @confluentinc

Slide 51

Slide 51

Confluent Operator: Automated Provisioning Load Balancer Kafka Pod Kafka Pod Kafka Pod Storage @gamussa #OracleCodeOne @ @confluentinc

Slide 52

Slide 52

Confluent Operator: Scale Horizontally Automate scaling: Spin up new broker pod(s) Distribute partitions to the new broker(s) Determine balancing plan Execute balancing plan Monitor resources @gamussa #OracleCodeOne @ @confluentinc

Slide 53

Slide 53

Confluent Operator: Rolling Upgrade Automated rolling upgrade with no downtime for Kafka. Stop broker Wait for leader election to complete Start broker with new version Wait for zero under-replicatedpartitions Repeat @gamussa #OracleCodeOne @ @confluentinc

Slide 54

Slide 54

Will it fly? Let’s see @gamussa #OracleCodeOne @confluentinc

Slide 55

Slide 55

Confluent Operator Automate provisioning Scale your Kafkas and CP clusters elastically Monitor SLAs through Confluent Control Center or Prometheus Operate at scale with enterprise support from Confluent @gamussa #OracleCodeOne @ @confluentinc

Slide 56

Slide 56

Advanced use cases vs. @gamussa #OracleCodeOne @confluentinc

Slide 57

Slide 57

Don’t despair! @gamussa #OracleCodeOne @ @confluentinc

Slide 58

Slide 58

Resources and Next Steps https://cnfl.io/helm_video https://cnfl.io/cp-helm https://cnfl.io/k8s https://slackpass.io/confluentcommunity #kubernetes @gamussa #OracleCodeOne @confluentinc

Slide 59

Slide 59

Thanks! @gamussa viktor@confluent.io We are hiring! https://cnfl.io/open_house @gamussa #OracleCodeOne @ @confluentinc