$30 off During Our Annual Pro Sale. View Details »

A Deep Dive into the Operator Pattern for Non-Clustered Resources

A Deep Dive into the Operator Pattern for Non-Clustered Resources

SQUER Solutions

November 23, 2022
Tweet

More Decks by SQUER Solutions

Other Decks in Technology

Transcript

  1. A Deep Dive into the
    Operator Pattern for
    Non-Clustered
    Resources
    José Molero
    @jmlero | [email protected]
    DevOps Vienna Meetup, 23.11.2022

    View Slide

  2. View Slide

  3. Agenda
    Operator! But, why?
    Overview on Operators.
    Operator-SDK Deep Dive.
    +DEMO
    +DEMO
    +DEMO

    View Slide

  4. Operator!
    But, Why?

    View Slide

  5. Platform Infrastructure
    Kafka
    Kafka
    DevTeam
    1
    Git
    CRs
    YAML
    Kubernetes
    Kube-api
    Operator
    CRD
    2
    4
    3
    Git Repository
    Kubernetes components

    View Slide

  6. DEMO 🚀
    Create a kafka topic with a CR.

    View Slide

  7. Overview
    on operators

    View Slide

  8. Operator — Overview
    Extensibility model for CR (Custom Resources)
    Embed automated operations logic for CR lifecycle
    management
    Supports the Kubernetes control loop architecture

    View Slide

  9. Operator — Reconciler
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: myDeployment
    spec:
    replicas: 3

    Reconcile
    apply
    Desired
    State
    Report
    Status
    Actual
    State
    Knowing the desired state
    Fetch the actual state
    Actions to go from actual to desired state

    View Slide

  10. Operator — CRD
    Custom Resource Definition
    • Extensions of the Kubernetes API
    • CRDs enables Kubernetes to store
    our custom resource in etcd
    • Manage our custom resources like
    a built in Kubernetes resource
    apiVersion: cache.example.com/v1alpha1
    kind: KafkaTopic
    metadata:
    name: myTopic
    spec:
    numPartitions: 5
    replicationFactor: 1

    View Slide

  11. Operator-SDK
    Deep-Dive

    View Slide

  12. Operator-SDK
    Set of open source tools for
    building and packaging operators
    Uses controller-runtime’s Client
    interface
    • Controller Go library by the
    Kubernetes-sig
    • Kubebuilder compatible
    Helm, ansible and Go

    View Slide

  13. DEMO 🌱
    Create my first operator.

    View Slide

  14. Operator-SDK with GO
    Operator-sdk supports the creation
    of operators in Go
    • Flexible and powerful
    Operator-sdk generates most of
    the needed skeleton code
    • Custom Resource Definition (CRDs)
    • A skeleton controller
    • Custom reconciliation loop to the
    controller
    https://blog.deckhouse.io/

    View Slide

  15. DEMO 🔥
    Understanding the Controller.

    View Slide

  16. Pitfalls
    Implementation could become complex
    Manage changes/upgrades in CRD
    Manage the state of external resources
    • Caching validation
    • Finalizers

    View Slide

  17. DEMO 🛳
    Build and Deploy.

    View Slide

  18. T.HANKS

    View Slide

  19. A Deep Dive into the
    Operator Pattern for
    Non-Clustered
    Resources
    José Molero
    @jmlero | [email protected]
    DevOps Vienna Meetup, 23.11.2022

    View Slide