Custom Resources for Cloud Native DevOps

3f4444967dfc7a5a2a71d24175d94c3c?s=47 Jelmer Snoeck
September 26, 2018

Custom Resources for Cloud Native DevOps

In this talk Jelmer will share with you what Kubernetes' Custom Resources exactly are and how they can help reduce YAML boilerplate. You'll learn how to create an Operator from scratch which you can use to automate DevOps tasks in a CloudNative manner.

3f4444967dfc7a5a2a71d24175d94c3c?s=128

Jelmer Snoeck

September 26, 2018
Tweet

Transcript

  1. Custom Resources for Cloud Native DevOps

  2. FIND ME github.com/jelmersnoeck twitter.com/jelmersnoeck Jelmer Snoeck ABOUT ME - OX

    Tech Lead at manifold.co - Kubernetes - Terraform - Kubelist Editor
  3. $ tree custom-resources-cloud-native-devops/ - What are Custom Resources - How

    to build Custom Resources - Publishing Custom Resources
  4. Custom Resource (Definitions) Photo by The Roaming Platypus on Unsplash

  5. A custom resource is an extension of the Kubernetes API

    that is not necessarily available on every Kubernetes cluster. In other words, it represents a customization of a particular Kubernetes installation.
  6. Custom Resource Definition (CRD)

  7. The CustomResourceDefinition API resource allows you to define custom resources.

    Defining a CRD object creates a new custom resource with a name and schema that you specify. The Kubernetes API serves and handles the storage of your custom resource.
  8. None
  9. None
  10. None
  11. Validation

  12. Open API Schema

  13. None
  14. None
  15. None
  16. Admission Webhooks

  17. Printer Columns

  18. None
  19. None
  20. Finalizers

  21. Controller vs Operator

  22. Controller <> Operator - Controller purely interacts with k8s objects

    (even custom ones) - Operator knows about a different domain outside of k8s (etcd, prometheus, …)
  23. Some CRDs in the wild

  24. - cert-manager - prometheus-operator - ingress-nginx-controller - contour - ingress-monitor

    - istio Examples
  25. What’s under the hood Photo by Wade Lambert on Unsplash

  26. Defining APIs

  27. API Definitions

  28. None
  29. Generated runtime.Object code

  30. type Object interface { GetObjectKind() schema.ObjectKind DeepCopyObject() Object }

  31. None
  32. Scheme Definitions

  33. None
  34. None
  35. Generating Clients

  36. k8s.io/code-generator/generate-groups.sh

  37. None
  38. ./vendor/k8s.io/code-generator/generate-groups.sh \ all \ github.com/jelmersnoeck/ingress-monitor/pkg/client/generated \ github.com/jelmersnoeck/ingress-monitor/apis \ ingressmonitor:v1alpha1 \

    --go-header-file boilerplate.go.txt
  39. None
  40. None
  41. None
  42. Controller

  43. Cache Informers

  44. None
  45. None
  46. Event Handlers

  47. type ResourceEventHandler interface { OnAdd(obj interface{}) OnUpdate(oldObj, newObj interface{}) OnDelete(obj

    interface{}) }
  48. None
  49. None
  50. Workqueue

  51. Built in queue features • Fair: items processed in the

    order in which they are added. • Stingy: a single item will not be processed multiple times concurrently, and if an item is added multiple times before it can be processed, it will only be processed once. • Multiple consumers and producers. In particular, it is allowed for an item to be reenqueued while it is being processed. • Shutdown notifications.
  52. None
  53. None
  54. None
  55. Label Selectors

  56. Labels

  57. None
  58. None
  59. None
  60. None
  61. None
  62. None
  63. Survive Rescheduling

  64. None
  65. Testing

  66. Testing - Fake Clients - Add wrappers to test informers

    - Use of testing.Fake Actions
  67. Publishing Photo by chuttersnap on Unsplash

  68. RBAC

  69. Survive Rescheduling

  70. Validation

  71. Resource Utilization

  72. Application Structuring

  73. Observability

  74. Thanks! Questions? @jelmersnoeck manifold.co