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

在 Cloud Native 中整合 Chatbot 至現有的系統上

在 Cloud Native 中整合 Chatbot 至現有的系統上

在 Cloud Native 中整合 Chatbot 至現有的系統上 - Sam Wang @ COSCUP 2021

Event page: https://coscup.org/2021/zh-TW/session/ED7M9S

2102a6b8760bd6f57f672805723dd83a?s=128

LINE Developers Taiwan
PRO

August 01, 2021
Tweet

Transcript

  1. 在 Cloud Native 中整合 Chatbot ⾄現有的系統上 王松億 Sam Wang 2021.08.01

  2. 2 Who Am I 王松億 Sam LINE TechFRESH • Graduated

    from NTU IM in 2021/06 • Study master degree in NTU IM • Join LINE TechFRESH program in 2020/07 • Learning Cloud Native and Chatbot
  3. 01 02 03 04 05 06 Contents Introduce Cloud Native

    Introduce Kubernetes Introduce Traefik Cloud Native in ChatBot Demo QA
  4. 4 Cloud Native’s concepts and advantages Introduce Cloud Native •

    Utilizes cloud computing • Build and run scalable applications (containers and microservices) • Resilient • Manageable • Observable • Easier for CI/CD
  5. 5 Cloud Native’s observability Introduce Cloud Native • Distributed tracing,

    logging, monitoring • Observability framework: OpenTelemetry • Visualized dashboard: Grafana
  6. 6 Production-Grade Container Orchestration Introduce Kubernetes > Kubernetes, also known

    as K8s, is an open-source system for automating deployment, scaling, and management of containerized applications. ※Source from:https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/
  7. 7 Production-Grade Container Orchestration Introduce Kubernetes > Kubernetes, also known

    as K8S, is an open-source system for automating deployment, scaling, and management of containerized applications. ※Source from:https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/
  8. Ingress External access to cluster Service Expose an application 8

    Introduce Kubernetes K8S resources Pods Smallest deployable units Deployment Declarative update CronJob Scheduled jobs
  9. 9 K8S’s Ingress Controller Introduce Traefik • Load balance •

    Support multiple middlewares • Support TLS
  10. 10 K8S’s advantages to ChatBot Cloud Native in ChatBot •

    Observability -> trouble shooting • Microservices -> clean architecture • CronJob -> periodically execute scripts
  11. 11 Today’s goal Cloud Native in ChatBot We use K8S

    to build our Chatbot application, Traefik as ingress controller, divide Chatbot app into 5 microservices: 1. Chatbot Webhook 2. Register web frontend 3. Register web backend 4. Users API 5. Cronjob to push messages periodically
  12. 12 Flow chart Cloud Native in ChatBot

  13. 13 Requirements Cloud Native in ChatBot 1. Kubectl + Kustomize

    2. KInD (Kubernetes In Docker) 3. Docker 4. MetalLB Github: https://github.com/disam8853/line-webhook-in-k8s
  14. 14 Step 1: install Traefik Cloud Native in ChatBot 1.

    Follow instruction of official document to apply 1. CRD (Customs Resource Definition) and RBAC (Role-based access control) 2. Trafik’s deployment and service 3. Set service type to `Load Balancer` 2. Install MetalLB if on-premises 3. Install docker-tuntap-osx if using Mac OS in order to connect to docker from host ※Source from:https://www.thehumblelab.com/kind-and-metallb-on-mac/
  15. 15 Step 2: Coding!!! Cloud Native in ChatBot 1. Chatbot

    Webhook webhook 2. Register web frontend register-web-client 3. Register web backend register-web-server 4. Users API api-users 5. Cronjob to push messages periodically (TBD)
  16. 16 Step 3: define K8S resources Cloud Native in ChatBot

    deployment.yaml
  17. 17 Step 3: define K8S resources Cloud Native in ChatBot

    service.yaml
  18. 18 Step 3: define K8S resources Cloud Native in ChatBot

    ingressroute.yaml
  19. 19 Step 3: define K8S resources Cloud Native in ChatBot

    cronjob.yaml
  20. Demo

  21. THANK YOU