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

Chatbot as a Service on Container(Kubernetes)

Kyle Bai
October 22, 2019

Chatbot as a Service on Container(Kubernetes)

Kyle Bai

October 22, 2019
Tweet

More Decks by Kyle Bai

Other Decks in Technology

Transcript

  1. @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
  2. @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
  3. @k2r2bai Agenda Today I would like to talk about •

    Inspired by a true story • How to implement? • Live Demo • Summary
  4. @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
  5. @k2r2bai • Self-healing • Horizontal scaling • Service discovery and

    Load balancing • Automated rollouts and rollbacks • Secrets and configuration management • Storage orchestration • Extensible Kubernetes
  6. @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
  7. @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
  8. @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
  9. @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.
  10. @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)
  11. @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
  12. @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
  13. @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
  14. @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"` }