Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Automating stateful applications with kubernetes operators - Openstack Summit EU 2018

304 views

Published on

Automating stateful applications with kubernetes operators

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Automating stateful applications with kubernetes operators - Openstack Summit EU 2018

  1. 1. Automating with Operators Marek Jelen Red Hat @marek_jelen Jorge Morales Red Hat @jorgemoralespou
  2. 2. @jorgemoralespou / @marek_jelen ● OpenShift Developer Advocate @ Red Hat ● Python, Ruby, Java, PHP developer ● Automation and cloud specialist ● OpenShift Developer Advocate @ Red Hat ● Java developer ● Developer experience and devops fanboy Marek Jelen Jorge Morales
  3. 3. @jorgemoralespou / @marek_jelen ● Why you should care about Operators ● What are Operators? ● How Operators work ● Building Operators ● Managing Operators ● Examples ● Installing OpenShift via Operators What we’ll cover
  4. 4. @jorgemoralespou / @marek_jelen Scaling stateless apps: Easy
  5. 5. @jorgemoralespou / @marek_jelen $ kubectl scale deploy/staticweb --replicas=3
  6. 6. @jorgemoralespou / @marek_jelen
  7. 7. @jorgemoralespou / @marek_jelen
  8. 8. @jorgemoralespou / @marek_jelen What about apps that… store data? Or have their own notion of a “cluster”? Databases?
  9. 9. @jorgemoralespou / @marek_jelen Running a database is easy
  10. 10. @jorgemoralespou / @marek_jelen $ kubectl run db --image=quay.io/my/db
  11. 11. @jorgemoralespou / @marek_jelen Running it over time is harder
  12. 12. @jorgemoralespou / @marek_jelen ⏣ Resize/Upgrade ⏣ Reconfigure ⏣ Backup ⏣ Healing
  13. 13. @jorgemoralespou / @marek_jelen Every application on any platform must be installed, configured, managed, and upgraded over time Patching is critical to security
  14. 14. @jorgemoralespou / @marek_jelen “Anything not automated is slowing you down.”
  15. 15. @jorgemoralespou / @marek_jelen If only k8s knew…
  16. 16. @jorgemoralespou / @marek_jelen Grant Pequeño Hombre MEET THIS GUY
  17. 17. @jorgemoralespou / @marek_jelen KNOWLEDGE IN A BOX
  18. 18. @jorgemoralespou / @marek_jelen PRODUCTION READY DBs
  19. 19. @jorgemoralespou / @marek_jelen Operators are automated software managers for Kubernetes applications: Install and Lifecycle
  20. 20. @jorgemoralespou / @marek_jelen The recipe
  21. 21. @jorgemoralespou / @marek_jelen Extend Kubernetes
  22. 22. @jorgemoralespou / @marek_jelen Application-specific controllers that extend the Kubernetes API to create, configure, and manage instances of complex stateful applications on behalf of a Kubernetes user
  23. 23. @jorgemoralespou / @marek_jelen kind: ProductionReadyDatabase apiVersion: database.example.com/v1alpha1 metadata: name: my-production-ready-database spec: clusterSize: 3 readReplicas: 2 version: v4.0.1 Extend the Kubernetes API through the Custom Resource Definition (CRD) mechanism
  24. 24. @jorgemoralespou / @marek_jelen Extend the Kubernetes API through the Custom Resource Definition (CRD) mechanism { }
  25. 25. @jorgemoralespou / @marek_jelen Reconciling desired state for your application { }
  26. 26. @jorgemoralespou / @marek_jelen https://github.com/operator-framework
  27. 27. Keep Operators up to date
  28. 28. @jorgemoralespou / @marek_jelen An Operator for Operators OPERATOR LIFECYCLE MANAGER
  29. 29. @jorgemoralespou / @marek_jelen Over-the-air updates
  30. 30. @jorgemoralespou / @marek_jelen https://github.com/operator-framework/awesome-operators
  31. 31. @jorgemoralespou / @marek_jelen OPERATOR MARKETPLACE
  32. 32. @jorgemoralespou / @marek_jelen OPERATOR METERING
  33. 33. @jorgemoralespou / @marek_jelen Build your own operator
  34. 34. @jorgemoralespou / @marek_jelen makes it easier to build Operators OPERATOR SDK
  35. 35. @jorgemoralespou / @marek_jelen 1. Scaffolding and code generation to bootstrap new projects
  36. 36. @jorgemoralespou / @marek_jelen 2. Extension points that cover common Operator use cases
  37. 37. @jorgemoralespou / @marek_jelen 3. High level APIs and abstractions to write operational logic
  38. 38. @jorgemoralespou / @marek_jelen Step by step
  39. 39. @jorgemoralespou / @marek_jelen 1. Create a new operator project using the SDK Command Line Interface(CLI) $ operator-sdk new prodready-db-operator --api-version=database.example.com/v1alpha1 --kind=ProductionReadyDatabase
  40. 40. @jorgemoralespou / @marek_jelen kind: ProductionReadyDatabase apiVersion: database.example.com/v1alpha1 metadata: name: my-production-ready-database spec: clusterSize: 3 readReplicas: 2 version: v4.0.1 2. Define new resource APIs by adding Custom Resource Definitions(CRD)
  41. 41. @jorgemoralespou / @marek_jelen 3. Specify resources to watch using the SDK API func main() { printVersion() sdk.Watch("database.example.com/v1alpha1", "ProductionReadyDatabase", "default",5) sdk.handle(stub.newHandler()) sdk.Run(context.TODO()) }
  42. 42. @jorgemoralespou / @marek_jelen 4. Define the operator reconciliation logic in a designated handler and use the SDK API to interact with resources
  43. 43. @jorgemoralespou / @marek_jelen 5. Use the SDK CLI to build and generate the operator and deployment manifests $ operator-sdk generate k8s
  44. 44. @jorgemoralespou / @marek_jelen 6. Deploy and run the operator in the cluster $ operator-sdk build example/prodreadydb:v0.0.1 $ docker push example/prodreadydb:v0.0.1 $ k apply -f deploy/rbac.yaml $ k apply -f deploy/operator.yaml
  45. 45. @jorgemoralespou / @marek_jelen 7. Deploy your own kubernetes applications $ cat <<EOF | k apply -f - kind: ProductionReadyDatabase apiVersion: database.example.com/v1alpha1 metadata: name: my-production-ready-database spec: clusterSize: 3 readReplicas: 2 version: v4.0.1 EOF
  46. 46. @jorgemoralespou / @marek_jelen Taste it!
  47. 47. @jorgemoralespou / @marek_jelen etcd Operator
  48. 48. @jorgemoralespou / @marek_jelen etcd Operator 3.3.8 3.3.8 3.3.9
  49. 49. @jorgemoralespou / @marek_jelen
  50. 50. @jorgemoralespou / @marek_jelen Database
  51. 51. @jorgemoralespou / @marek_jelen Deploying OpenShift via Operators
  52. 52. @jorgemoralespou / @marek_jelen DEMO ● Installer ○ Provision the infrastructure ○ Deploy temporary K8s cluster ○ Ignite the deployment process ● Operators ○ Do the rest ...
  53. 53. @jorgemoralespou / @marek_jelen
  54. 54. @jorgemoralespou / @marek_jelen DEMO cluster-kube-apiserver-operator* cluster-kube-controller-manager-operator* cluster-kube-scheduler-operator* cluster-openshift-api-server-operator cluster-openshift-controller-manager-operator cluster-monitoring-operator cluster-network-operator cluster-dns-operator cluster-ingress-operator machine-api-operator auth-config-operator cluster-autoscaler-operator cluster-node-tuning-operator cluster-storage-operator cluster-samples-operator cluster-image-registry-operator cluster-logging-operator cluster-service-catalog-operator console-operator machine-config-operator service-serving-cert-signer olm-operator
  55. 55. @jorgemoralespou / @marek_jelen Helpful resources
  56. 56. @jorgemoralespou / @marek_jelen Resources ● Operator Framework and SDK on Github https://github.com/operator-framework/ ● Awesome Operators! https://github.com/operator-framework/awesome-operators ● Introducing the Operator Framework https://coreos.com/blog/introducing-operator-framework ● Make a Kubernetes Operator in 15 mins with Helm https://blog.openshift.com/make-a-kubernetes-operator-in-15-minutes-with-hel m/ ● Kubernetes Custom Resources Grow up in v1.10.0 https://blog.openshift.com/kubernetes-custom-resources-grow-up-in-v1-10/
  57. 57. Coming Soon: Operators tutorials OpenShift Learning Portal http://learn.openshift.com
  58. 58. Automating with Operators Jorge Morales Red Hat @jorgemoralespou Marek Jelen Red Hat @marek_jelen Thanks for attending

×