[Argo Workflow] Argo Workflow๋?
in Programming on DevOps
๐ก Argo Workflow์๋ํด araboza
1. Argo Workflow๋?
Kubernetes ํ๊ฒฝ์์ ๋ณ๋ ฌ๋ก ์คํ๋๋ ์ฌ๋ฌ Job ์ ํตํฉ ๊ด๋ฆฌํ๊ธฐ ์ํด ๋ง๋ค์ด์ง ์ํฌํ๋ก์ฐ ์์ง
- Workflow์ ๊ฐ Step์ ์ปจํ ์ด๋๋ก ์ ์๋จ
- DAG(Directed Acyclic Graph) ๋ฅผ ์ฌ์ฉํ์ฌ task ์ํ์ค (๋๋ task dependency) ๋ฅผ multi-step Workflow ๋ก ๋ชจ๋ธ๋ง
- Kubernetes ํ๊ฒฝ์์ Job ์ ์ฝ๊ฒ ์คํํ ์ ์์
- ์ฟ ๋ฒ๋คํฐ์คํ๊ฒฝ์์ CI/CD ํ์ดํ๋ผ์ธ์ ๋ณต์กํ ์ค์ ์์ด ์คํํ ์์์
2. ๋ก์ปฌํ๊ฒฝ์์ ์คํํด๋ณด๊ธฐ
k8s ํ๊ฒฝ ๊ตฌ์ฑ
์ฐ์ ๋ก์ปฌ์ k8sํ๊ฒฝ์ ๊ตฌ์ฑํ๋ค. docker-desktop์ kubernetes ๊ธฐ๋ฅ์ ํ์ฑํํ์ฌ ์ฌ์ฉํ๊ฑฐ๋, minikube
๋ฑ์ ๋ก์ปฌ์ ์ค์นํ์ฌ ๊ตฌ์ฑํ ์ ์๋ค.
argo workflow ์ค์น
kubectl create namespace argo
kubectl apply -n argo -f https://github.com/argoproj/argo-workflows/releases/download/v3.3.9/install.yaml
๋๋ ์ง๊ธ์์ ์ 3.3.9๊ฐ ์ต์ ์ด๋ผ ๊ทธ ๋ฒ์ ์ผ๋ก ๊น์๋๋ฐ ์ฌ๊ธฐ์ ์ต์ ๋ฒ์ ํ์ธํด์ ๊ทธ๊ฑธ๋ก ๊น๋ฉด๋๋ค
argo CLI ์ค์น
# Download the binary
curl -sLO https://github.com/argoproj/argo-workflows/releases/download/v3.3.9/argo-darwin-amd64.gz
# Unzip
gunzip argo-darwin-amd64.gz
# Make binary executable
chmod +x argo-darwin-amd64
# Move binary to path
sudo mv ./argo-darwin-amd64 /usr/local/bin/argo
# Test installation
argo version
argo: v3.3.9
BuildDate: 2022-08-10T00:52:18Z
GitCommit: 5db53aa0ca54e51ca69053e1d3272e37064559d7
GitTreeState: clean
GitTag: v3.3.9
GoVersion: go1.17.13
Compiler: gc
Platform: darwin/amd64
์ธ์ฆ์ฐํ
์๋ ์๋ฅด๊ณ ui๋ค์ด๊ฐ๋ ค๋ฉด ํด๋ผ์ด์ธํธ์ธ์ฆํ์ํ๋ฐ ์๋์ค์ ๋ฃ์ด์ฃผ๋ฉด ์ฐํ๊ฐ๋ฅํ๋ค๊ณ ํจ
kubectl patch deployment \
argo-server \
--namespace argo \
--type='json' \
-p='[{"op": "replace", "path": "/spec/template/spec/containers/0/args", "value": [
"server",
"--auth-mode=server"
]}]'
UI ํฌํธํฌ์๋ฉ
kubectl -n argo port-forward deployment/argo-server 2746:2746
# ํน์
argo server
์ด์ https://localhost:2746 ์ฌ๊ธฐ๋ก ๋ค์ด๊ฐ์ argo workflow ui๋ฅผ ๊ตฌ๊ฒฝํ ์์๋ค
3. workflow ๋ฑ๋กํด๋ณด๊ธฐ
argo workflow ๋ ํ
ํ๋ฆฟ ๊ธฐ๋ฐ์ผ๋ก ์คํ๋๋๋ฐ ์ด ํ
ํ๋ฆฟ์ yaml
ํ์์ผ๋ก ์์ฑํ๋ฉด ๋จ
์๋์๊ฐ์ด argo workflow ๊ณต์ repo์ ์ฌ๋ผ์์๋ ์์ ํ์ผ์ submitํด๋ณด์
argo submit -n argo --watch https://raw.githubusercontent.com/argoproj/argo-workflows/master/examples/hello-world.yaml
์คํํ๋ฉด ์ด๋ฐ ํํฉํ์ ๋์์ค๋ค
Name: hello-world-d5j49
Namespace: argo
ServiceAccount: unset (will run with the default ServiceAccount)
Status: Succeeded
Conditions:
PodRunning False
Completed True
Created: Tue Sep 06 14:18:57 +0900 (1 minute ago)
Started: Tue Sep 06 14:18:57 +0900 (1 minute ago)
Finished: Tue Sep 06 14:20:09 +0900 (now)
Duration: 1 minute 12 seconds
Progress: 1/1
ResourcesDuration: 28s*(1 cpu),28s*(100Mi memory)
STEP TEMPLATE PODNAME DURATION MESSAGE
โ hello-world-d5j49 whalesay hello-world-d5j49 1m
This workflow does not have security context set. You can run your workflow pods more securely by setting it.
Learn more at https://argoproj.github.io/argo-workflows/workflow-pod-security-context/
argo list -n argo
# ์กฐํํ๋ฉด ํ์ฌ workflow ์ํ๋ ๋ณผ์์๋ค
NAME STATUS AGE DURATION PRIORITY
hello-world-d5j49 Running 25s 25s 0
NAME STATUS AGE DURATION PRIORITY
hello-world-d5j49 Succeeded 2m 1m 0
๋ค์ํ workflow ํ ํ๋ฆฟ์ ์ฌ๊ธฐ์ ํ์ธ ๊ฐ๋ฅ
argo-workflows/examples at master ยท argoproj/argo-workflows
4. argo-cli ๋ช ๋ น์ด ๋ชจ์
# ๊ฐ์ฅ ์ต๊ทผ์ ์คํ๋ workflow ์์ธ์ ๋ณด
argo get -n argo @latest
# argo log tailing
argo logs -f {workflowName}