Chatbot as a Service on Container(Kubernetes)

5a84ea9a0afaca03be45b87dde58e51c?s=47 Kyle Bai
October 22, 2019

Chatbot as a Service on Container(Kubernetes)

5a84ea9a0afaca03be45b87dde58e51c?s=128

Kyle Bai

October 22, 2019
Tweet

Transcript

  1. @k2r2bai Chatbot as a Service on Container 1 ⽩白凱仁(Kyle Bai)

    <k2r2.bai@gmail.com>
  2. @k2r2bai About Me ⽩白凱仁(Kyle Bai) • Between Jobs. : (

    • Contributor to multiple OSS. • Certified Kubernetes Administrator/Developer. • Co-organizer of Cloud Native Taiwan User Group. • Interested in emerging technologies. @kairen https://k2r2bai.com
  3. @k2r2bai Cloud Native Taiwan User Group SDN, Cloud Native, System

    • Hosted a meetup and conference for sharing and discussing everything related to cloud native and Kubernetes ecosystem. • Hosted a workshop to get local user on-boarded to Kubernetes experience. • Boosted a local community to contribute Kubernetes and
  4. @k2r2bai Agenda Today I would like to talk about •

    Inspired by a true story • How to implement? • Live Demo • Summary
  5. @k2r2bai Inspired by a true story

  6. @k2r2bai One Today….

  7. @k2r2bai ME FRIEND How to become a PROFESSIONAL HUNTER?

  8. @k2r2bai ME FRIEND You need an AIBO!!

  9. @k2r2bai

  10. @k2r2bai ME FRIEND

  11. @k2r2bai How to become a PROFESSIONAL AGENT? ME FRIEND

  12. @k2r2bai You need a TERMINAL!! ME FRIEND

  13. @k2r2bai So I think we need…

  14. @k2r2bai

  15. @k2r2bai

  16. @k2r2bai

  17. @k2r2bai

  18. @k2r2bai

  19. @k2r2bai But…

  20. @k2r2bai How to deploy/manage/configure bots?

  21. @k2r2bai How to add messages and events easily?

  22. @k2r2bai • Process-level isolation, possibly less secure. • High coupling

    for the kernel. • Native performance. • Startup time in milliseconds. • Lightweight Containers(OS-Level Virtualization) Application Virtualization libs app kernel libs app libs app libs app
  23. @k2r2bai • Self-healing • Horizontal scaling • Service discovery and

    Load balancing • Automated rollouts and rollbacks • Secrets and configuration management • Storage orchestration • Extensible Kubernetes
  24. @k2r2bai I have a Chatbot

  25. @k2r2bai I have a Kubernetes

  26. @k2r2bai Ugh…

  27. @k2r2bai Chatbot Operator

  28. @k2r2bai • Bot: defines the desired state of the Bot

    deployment. • Event: defines eventing rules for a bot instance. • EventBinding: defines the set of events to be used by the bot. You select Events to be bound using labels and label selectors. Bot, Event and EventBinding
  29. @k2r2bai Bot, Event and EventBinding

  30. @k2r2bai How to implement?

  31. @k2r2bai Operator https://coreos.com/blog/introducing-operators.html “An Operator is an application-specific controller that

    extends the Kubernetes API to create, configure, and manage instances of complex stateful applications on behalf of a Kubernetes user. It builds upon the basic Kubernetes resource and controller concepts but includes domain or application-specific knowledge to automate common tasks.” —- Brandon Philips, CoreOS
  32. @k2r2bai • Controller for listening and dispatching events (uses informers,

    watchers and event handlers) -> runs as a k8s pod/deployment. • API classes to specify a model that represents the data in the CRD. • Internal Model Objects to manipulate the k8s client to create, update and delete resources based on state. • Hides raw complexities of controllers. • Used to build native Kubernetes applications. Parts of the Operator
  33. @k2r2bai Why are Kubernetes Operators so important?

  34. @k2r2bai

  35. @k2r2bai

  36. @k2r2bai Problems: learn to write operators

  37. @k2r2bai A service that listens for events and acts to

    converge the system to the desired state from the actual state. Custom Controllers • Automate administration tasks as if they were a native Kubernetes component. • State-of-the-art for building distributed apps in Kubernetes. • Interact with the Kubernetes API server.
  38. @k2r2bai • 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. • Do not require programming. CRD(CustomResourceDefinition)
  39. @k2r2bai • CRD to specify new resource that the operator

    manages (optional). • Controller for listening and dispatching events (uses informers, watchers and event handlers) -> runs as a k8s pod/deployment. • API classes to specify a model that represents the data in the CRD. • Internal Model Objects to manipulate the k8s client to create, update and delete resources based on state. • Events: • Added • Updated • Deleted Parts of the Operator
  40. @k2r2bai • Allows manipulation of resource state (eg creation of

    pod, modification of configmap, deletion of persistent volume). • List resources. • Get details about current resource state. • Creates custom controller. client-go https://github.com/kubernetes/client-go
  41. @k2r2bai

  42. @k2r2bai • Go does not have generics in the language.

    • Code generation can be done using k8s code generation scripts. • Generation of typed: • Clientsets • Informers • Listers • This should be part of your build process. https://github.com/kubernetes-client/gen https://github.com/kubernetes/code-generator Code Generation
  43. @k2r2bai // +genclient // +k8s:deepcopy-gen:inteDaces=k8s.io/apimachinery/pkg/runtime.Object type Bot struct { metav1.TypeMeta

    `json:",inline"` metav1.ObjectMeta `json:"metadata"` Spec BotSpec `json:"spec"` Status BotStatus `json:"status,omitempty"` }
  44. @k2r2bai Live Demo

  45. @k2r2bai Summary

  46. @k2r2bai 還不趕快來來學 Kubernetes https://kubernetes.io/docs/tutorials/kubernetes-basics/

  47. @k2r2bai • https://learning.oreilly.com/library/view/programming-kubernetes/9781492047094/ • https://github.com/kubeflow/tf-operator/issues/300 • https://stackoverflow.com/questions/47848258/kubernetes-controller-vs-kubernetes- operator?rq=1 • https://github.com/operator-framework/awesome-operators

    • https://github.com/kubernetes-sigs/kubebuilder • https://github.com/operator-framework References
  48. @k2r2bai Q &A

  49. @k2r2bai KAIREN OUT!! THANK YOU!!!