Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Automating Stateful Applications with Kubernetes Operators

Jan Kleinert
September 23, 2019

Automating Stateful Applications with Kubernetes Operators

Jan Kleinert

September 23, 2019
Tweet

More Decks by Jan Kleinert

Other Decks in Technology

Transcript

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

    View Slide

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

    View Slide

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

    View Slide

  4. @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

    View Slide

  5. @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
    [...]

    View Slide

  6. @jankleinert
    6
    Why should you care about operators?

    View Slide

  7. @jankleinert
    7
    Scaling stateless apps: easy

    View Slide

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

    View Slide

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

    View Slide

  10. @jankleinert
    10
    start
    count=3
    desired=3
    ReplicaSet

    View Slide

  11. @jankleinert
    11
    What about apps that store data?

    View Slide

  12. @jankleinert
    12
    Creating a database is easy

    View Slide

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

    View Slide

  14. @jankleinert
    14
    Running a database over time is harder

    View Slide

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

    View Slide

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

    View Slide

  17. @jankleinert
    17
    Anything not automated is slowing you down

    View Slide

  18. @jankleinert
    18
    If only Kubernetes knew...

    View Slide

  19. @jankleinert
    19

    View Slide

  20. @jankleinert
    20

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  24. @jankleinert
    24
    Application-Specific Controllers

    View Slide

  25. @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
    [...]

    View Slide

  26. @jankleinert
    26
    {
    }

    View Slide

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

    View Slide

  28. @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"

    View Slide

  29. @jankleinert
    29
    Example: etcd Operator

    View Slide

  30. @jankleinert
    30

    View Slide

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

    View Slide

  32. @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.

    View Slide

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

    View Slide

  34. @jankleinert
    34

    View Slide

  35. @jankleinert
    35

    View Slide

  36. @jankleinert
    36

    View Slide

  37. @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

    View Slide

  38. @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

    View Slide

  39. 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

    View Slide