[Argo Events] Argo Events๋?
in Programming on DevOps
๐ก 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. ์ค์น๋ฐฉ๋ฒ
argo-events ๋ค์์คํ์ด์ค ์์ฑ
kubectl create namespace argo-events
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. ์ปจ์ ์๊ฐ
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/