[Argo Events] Argo Events๋ž€?


๐Ÿ’ก Argo events์— ๋Œ€ํ•œ ๊ฐœ๋žต์ ์ธ ๋‚ด์šฉ์„ ์•Œ์•„๋ณด์ž

1. Argo Events๋ž€?

webhook, s3, sqs ๋“ฑ ๋‹ค์–‘ํ•œ ์†Œ์Šค์˜ ์ด๋ฒคํŠธ์—์„œ k8s, workflows, ์›Œํฌ๋กœ๋“œ ๋“ฑ์„ ํŠธ๋ฆฌ๊ฑฐํ•˜๋Š” ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์šฉ ์ด๋ฒคํŠธ๊ธฐ๋ฐ˜ ์›Œํฌํ”Œ๋กœ ์ž๋™ํ™” ํ”„๋ ˆ์ž„์›Œํฌ.

  • 20๊ฐœ ์ด์ƒ์˜ event source ์ง€์›
  • ์‚ฌ์šฉ์ž ์ง€์ • ๋กœ์ง ์„ค์ • ๊ฐ€๋Šฅ
  • ๋‹จ์ˆœํ•œ ์„ ํ˜• ์ด๋ฒคํŠธ๋ถ€ํ„ฐ ๋ณต์žกํ•œ ๋‹ค์ค‘์†Œ์Šค ์ด๋ฒคํŠธ๊นŒ์ง€ ๊ด€๋ฆฌ ๊ฐ€๋Šฅ
  • k8s objects, argo workflow, aws lambda๋“ฑ์„ ํŠธ๋ฆฌ๊ฑฐํ• ์ˆ˜์žˆ์Œ.
  • Cloud Events ์ง€์›
  • ์™ธ๋ถ€ event โ†’ event source (k8s์šฉ ์ด๋ฒคํŠธ) โ†’ eventbus, sensor (k8s์šฉ event์˜ subscriber) โ†’ trigger โ†’ workflow ์ˆœ์„œ๋กœ ์‹คํ–‰๋จ

2. ์„ค์น˜๋ฐฉ๋ฒ•

  1. argo-events ๋„ค์ž„์ŠคํŽ˜์ด์Šค ์ƒ์„ฑ

     kubectl create namespace argo-events
    
  2. Argo Events SA, ClusterRoles, and Controller for Sensor, EventBus, and EventSource ๋ฐฐํฌ

     kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/manifests/install.yaml
     # Install with a validating admission controller
     kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-events/stable/manifests/install-validating-webhook.yaml
    

3. ์ปจ์…‰ ์†Œ๊ฐœ

argo-events

1) Event Source

์™ธ๋ถ€ ์†Œ์Šค(ex. aws sqs, aws sns, gcp pubsub, webhook)๊ฐ™์€ ์™ธ๋ถ€ ์†Œ์Šค์˜ ์ด๋ฒคํŠธ๋ฅผ ์†Œ๋น„ํ•˜๊ธฐ์œ„ํ•ด ์š”๊ตฌ๋˜๋Š” configuration์„ ์ •์˜ํ•˜๋Š”๋†ˆ.

ํ•œ๋งˆ๋””๋กœ ์ด๋ฒคํŠธ๋ฅผ ์“ฐ๋Š”๋†ˆ (Write Events)

apiVersion: argoproj.io/v1alpha1
kind: EventSource
metadata:
  name: calendar
spec:
  calendar:
    example-with-interval:
      # 10์ดˆ๋งˆ๋‹ค ์ด๋ฒคํŠธ๋ฅผ ์ƒ์„ฑํ•˜๊ฒŒ๋จ 
      interval: 10s

์ œ์ผ ๊ฐ„๋‹จํ•œ๋†ˆ์œผ๋กœ๋งŒ ์˜ˆ์‹œ๋ฅผ ๊ฐ€์ ธ์™”๋Š”๋ฐ, ์œ„์—์„œ ์–ธ๊ธ‰ํ•œ ๋‹ค์–‘ํ•œ ์ด๋ฒคํŠธ์†Œ์Šค ์˜ˆ์ œ๋Š” ์—ฌ๊ธธ ์ฐธ์กฐ.

2) Sensor

์ด๋ฒคํŠธ์˜ input(dependency)๊ณผ output(trigger)๋ฅผ ์ •์˜ํ•˜๋Š” ๋†ˆ.

ํ•œ๋งˆ๋””๋กœ ์ด๋ฒคํŠธ๋ฅผ ์ฝ๋Š”๋†ˆ (Read Events)

apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
  name: calendar
spec:
  template:
    serviceAccountName: operate-workflow-sa
 # calendar ์ด๋ฒคํŠธ์†Œ์Šค์˜ example-with-interval ์ด๋ฒคํŠธ๋ฅผ ๊ตฌ๋…ํ•˜๊ฒ ๋‹ค 
 # ์ฆ‰ ์ด๋…€์„์€ 10์ดˆ์— ํ•œ๋ฒˆ์”ฉ ์‹คํ–‰ํ•˜๊ฒŒ๋จ 
  dependencies:
    - name: test-dep
      eventSourceName: calendar
      eventName: example-with-interval
  triggers:
    - template:
        name: calendar-workflow-trigger
        k8s:
          operation: create
          source:
            resource:
              apiVersion: argoproj.io/v1alpha1
              kind: Workflow
              metadata:
                generateName: calendar-workflow-
              spec:
                entrypoint: whalesay
                arguments:
                  parameters:
                  - name: message
                    # value will get overridden by the event payload
                    value: hello world
                templates:
                - name: whalesay
                  inputs:
                    parameters:
                    - name: message
                  container:
                    image: docker/whalesay:latest
                    command: [cowsay]
                    args: [""]
          parameters:
            - src:
                dependencyName: test-dep
                dataKey: eventTime
              dest: spec.arguments.parameters.0.value
      retryStrategy:
        steps: 3

๋‹ค์–‘ํ•œ ์„ผ์„œ ์˜ˆ์‹œ๋Š” ์—ฌ๊ธฐ๋ฅผ ์ฐธ์กฐ.

3) Event Bus

์ด๋ฒคํŠธ ์†Œ์Šค์™€ ์„ผ์„œ๋ฅผ ์—ฐ๊ฒฐํ•˜๋Š” ๋…€์„์ž„. NATS Jetstream์œผ๋กœ ๊ตฌ์„ฑ๋˜์–ด์žˆ๋‹ค๊ณ ํ•จ. (์œ„ ์•„ํ‚คํ…์ณ ๊ทธ๋ฆผ์—๋Š” NATS streaming ์œผ๋กœ ์จ์žˆ๋Š” ์ด์œ ๋Š” ์˜›๋‚ ์—๋Š” ๊ทธ๊ฑธ ์ป๋”ฐ๊ณ ํ•จ. ์ง€๊ธˆ์€ deprecated๋˜๊ณ  jetstream์œผ๋กœ ์‹คํ–‰๋œ๋‹ค๊ณ ํ•จ)

apiVersion: argoproj.io/v1alpha1
kind: EventBus
metadata:
  name: default
spec:
  nats:
    native:
      # ๊ฐ€๋Šฅํ•˜๋ฉด 3๊ฐœ ์ด์ƒ์˜ replica๋ฅผ ๋„์šฐ๋ผ๊ณ ํ•จ 
      replicas: 3
      # ์ธ์ฆ ์—†๊ฑฐ๋‚˜ (none) ํ† ํฐ์œผ๋กœ ์ธ์ฆํ•˜๊ฑฐ๋‚˜ (token) 
      auth: token

๊ทธ๋ƒฅ jetstrem ๋„์šฐ๋Š”๋…€์„์ด๋ผ๊ทธ๋Ÿฐ์ง€ ๋ณ„ ์„ค์ •์ด ์—†๋‹ค. ์œ„ ๋ช‡ ์ค„๋กœ ๋œ ๋†ˆ์„ ๋„์›Œ์ฃผ๋ฉด ๋œ๋‹ค.

์ด๋ฒคํŠธ๋ฒ„์Šค๋Š” ํ•˜๋‚˜๋งŒ ๋„์›Œ์ฃผ๋ฉด, ์ดํ›„์— ๋‚ด๊ฐ€ ์›ํ•˜๋Š” ์ด๋ฒคํŠธ ์†Œ์Šค์™€ ์„ผ์„œ๋ฅผ ๋งˆ๊ตฌ ์ถ”๊ฐ€ํ•˜๋ฉฐ ๋†€๋ฉด ๋œ๋‹ค.

https://argoproj.github.io/argo-events/installation/ https://argoproj.github.io/argo-events/concepts/architecture/






ยฉ 2020. by berrrrr

Powered by berrrrr