The document discusses running Apache Cassandra on Kubernetes with K8ssandra. K8ssandra combines Kubernetes and Cassandra to provide a scalable data store with an API layer and administration tools. It addresses challenges of running stateful applications in containers by providing scaling, consistency and resilience. K8ssandra allows Cassandra to be deployed in a cloud-native way on Kubernetes and provides easy and secure data access.
2. About me
➢ Training
➢ Teaching
➢ Reference Applications
➢ Support
➢ Public Speaking
➢ Creator of ff4j (ff4j.org)
➢ Maintainer for 7 years+
@clunven
@clun
3. Stateful Applications on
Kubernetes with K8ssandra
1. What’s Cassandra good for ?
2. Running Cassandra: From Docker to
Kubernetes
3. Stateful Applications: From
Kubernetes to K8ssandra
3
8. Cloud Native Asturias @cloudnativeast @clunven
Country City Population
USA New York 8.000.000
USA Los Angeles 4.000.000
FR Paris 2.230.000
DE Berlin 3.350.000
UK London 9.200.000
AU Sydney 4.900.000
FR Toulouse 1.100.000
JP Tokyo 37.430.000
IN Mumbai 20.200.000
DE Nuremberg 500.000
CA Montreal 4.200.000
CA Toronto 6.200.000
Partition Key
Data is distributed
8
9. Cloud Native Asturias @cloudnativeast @clunven
Country City Population
USA New York 8.000.000
USA Los Angeles 4.000.000
UK London 9.200.000
AU Sydney 4.900.000
JP Tokyo 37.430.000
IN Mumbai 20.200.000
DE Berlin 3.350.000
DE Nuremberg 500.000
CA Montreal 4.200.000
CA Toronto 6.200.000
FR Toulouse 1.100.000
FR Paris 2.230.000
Data is Distributed
9
10. Cloud Native Asturias @cloudnativeast @clunven
RF = 3
Replication Factor 3
means that every
row is stored on 3
different nodes
0
50
33
17
83
67
Data is Replicated
10
11. Cloud Native Asturias @cloudnativeast @clunven
59 (data)
RF = 3
0
50
33
17
83
67
Replication within the Ring
11
12. Cloud Native Asturias @cloudnativeast @clunven
RF = 3
0
50
33
17
83
67
59 (data)
Replication within the Ring
12
13. Cloud Native Asturias @cloudnativeast @clunven
RF = 3
0
50
33
17
83
67
59 (data)
59 (data)
59 (data)
Replication within the Ring
13
16. Cloud Native Asturias @cloudnativeast @clunven
• Geographic Distribution • Hybrid-Cloud and Multi-Cloud
Data Distributed Everywhere
On-premise
16
17. Cloud Native Asturias @cloudnativeast @clunven
High Throughput
High Volume
Heavy Writes
Heavy Reads
Event Streaming Log Analytics
Internet of Things Other Time Series
Mission-Critical
No Data Loss
Always-on
Scalability
Availability
Distributed
Cloud-native
Caching Pricing
Market Data Inventory
Banking Retail
Tracking /
Logistics
Customer
Experience
API Layer
Cloud
Deployments
Distributed Data
Network
Horizontal Scaling
Modern Cloud
Applications
Global Presence
Workload Mobility
Compliance /
GDPR
Understanding Use Cases
17
24. Cloud Native Asturias @cloudnativeast @clunven
Why Kubernetes ?
Automatic bin packing
Self-healing
Horizontal scaling
Service discovery
Load balancing
Automated rollouts and rollbacks
Storage orchestration
Secret and configuration
management
Batch execution
24
25. Cloud Native Asturias @cloudnativeast @clunven
K8s Infrastructure
Cluster:
Kubernetes cluster.
Node:
Worker machine in Kubernetes cluster.
Master:
Kubernetes Control Plane.
Kubernetes Control Plane
REST API
25
26. Cloud Native Asturias @cloudnativeast @clunven
K8s Infrastructure
K8s API Server
Kubernetes API.
Controller Manager
Kubernetes controller manager.
Scheduler
In charge of ensuring Pods placement.
ETCD
Kubernetes’ backing store.
Kubernetes Control Plane
Scheduler
(bind pod to node)
API Server
(REST API)
Controller Manager
(controller loop)
ETCD
(k/v db - ssot)
26
27. Cloud Native Asturias @cloudnativeast @clunven
K8s Infrastructure
Kubernetes Workers (minion)
Kubelet:
The kubelet is the primary “node agent”
that runs on each node.
Kube-proxy
The Kubernetes network proxy runs on
each node. This reflects services as
defined in the Kubernetes API on each
node.
POD
Collection of containers that can
run on a host.
This resource is created by clients
and scheduled onto hosts.
Operating System
Containerd
container
27
28. Kubernetes Namespace
28
Namespace: Namespace provides a
scope for Names. Use of multiple
namespaces is optional.
default kube-system
kube-public
cass-operator
We create resources in
namespaces span across node.
29. K8s Primitives : Configuration
cass-operator
ConfigMap: ConfigMap holds
configuration data for pods to
consume..
Secret: Secret holds secret data of a
certain type..
30. PersistentVolume: is a storage
resource provisioned by an
administrator.
PersistentVolumeClaim:
PersistentVolumeClaim is a user's
request for and claim to a persistent
volume.
StorageClass: StorageClass describes
the parameters for a class of storage
for which PersistentVolumes can be
dynamically provisioned.
K8s Primitives : Storage
cass-operator
create
31. K8s Primitives : StatefulSet
cass-operator
create
StatefulSet: StatefulSet represents
a set of pods with consistent
identities. Identities are defined as:
network, storage.
create
34. K8s Primitives : Custom Resources
34
Custom Resource Definition :
Extensions of the Kubernetes API.
Customization making K8s more modular
• Spec declares the desired state of a resource
○ Configuration settings provided by the user
○ Default values expanded by the system
○ Other properties initialized by other internal
components after resource creation.
• Status : describes the object’s current, observed state.
○ Kubernetes API server provides a REST API to
clients. A Kubernetes object or resource is a REST
resource.
○ The status of a Kubernetes resource is typically
implemented as a REST subresource that can
only be modified by internal, system components
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: crontabs.stable.example.com
spec:
# group name to use for REST API: /apis/<group>/<version>
group: stable.example.com
# list of versions supported by this CustomResourceDefinition
versions:
- name: v1
# Each version can be enabled/disabled by Served flag.
served: true
# One and only one version must be marked as the storage
version.
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
cronSpec:
type: string
image:
type: string
replicas:
type: integer
# either Namespaced or Cluster
scope: Namespaced
names:
[...}
35. K8s Primitives : Operator
35
Building an application and driving an application on top
of Kubernetes, behind Kubernetes APIs
A Kubernetes Operator helps extend the types of
applications that can run on Kubernetes by allowing
developers to provide additional knowledge to applications
that need to maintain state.” –Jonathan S. Katz
● Reconcile CRD instances which states defined within
the “spec” attribute.
● Listen events and status evolution to react
accordingly.
cass-operator
Operator
reconcile
e
v
e
n
t
s
events
states
36. Kubernetes Probes (readiness, liveness)
36
Cassandra Management API Service
CASSANDRA
side-car
busybox
https://github.com/datastax/management-api-for-apache-cassandra
47. “Start with Why” Simon Sinek
• SRE, Operators and Databases Administrators…
• Do you allow developers to execute direct queries against your DB ?
• Do you like opening port ranges like 0-65536 to allow
communications with applications, especially in the cloud.
• Do you like creating dedicated projects and hiring people just to
create APIs to expose an existing treatment (digital transformation
FTW)
49. API Data Gateways rational
Ubiquitous, API-based Consumption
MICROSERVICES
DEVELOPERS
Developers want the option
to use modern APIs and
development gateways.
Cassandra is a database
designed for the new
standard and the associated
APIs that facilitate the first
choice of developers.
54. ● Apache Cassandra™ match Cloud Deployments
principles by design
● Apache Cassandra™ evolved from Docker to
fully “kubernetes ready” (operator)
● Stateful applications in containers are
challenging: scaling, consistency, resilience
● K8ssandra provides
○ a scalable data store based on Cassandra
○ an api layer named Stargate
and can be used to store data or states.
KEY IDEAS
59. About me
➢ Training
➢ Teaching
➢ Reference Applications
➢ Support
➢ Public Speaking
➢ Creator of ff4j (ff4j.org)
➢ Maintainer for 7 years+
@clunven
@clun