Open7

Argo Workflow試してみる

daylightdaylight

kindでArgo Workflow v3.5.0 をインストール (公式手順)

kindでクラスター作ってローカルで試す。kind, kubectl, argoのインストール方法は割愛。

参考

$ kind version
kind v0.20.0 go1.20.4 darwin/arm64

$ kind create cluster
Creating cluster "kind" ...
 ✓ Ensuring node image (kindest/node:v1.27.3) 🖼
 ✓ Preparing nodes 📦
 ✓ Writing configuration 📜
 ✓ Starting control-plane 🕹️
 ✓ Installing CNI 🔌
 ✓ Installing StorageClass 💾
Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Have a question, bug, or feature request? Let us know! https://kind.sigs.k8s.io/#community 🙂

クラスター接続設定。

$ kubectl version
Client Version: v1.28.2
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.27.3

$ kubectl cluster-info --context kind-kind
Kubernetes control plane is running at https://127.0.0.1:51718
CoreDNS is running at https://127.0.0.1:51718/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

公式の手順引用。
Quick Start - Argo Workflows - The workflow engine for Kubernetes

現時点(2023/10/15)で最新のv3.5.0をインストールする。

$ kubectl create namespace argo
$ kubectl apply -n argo -f https://github.com/argoproj/argo-workflows/releases/download/v3.5.0/install.yaml

Port-forwardで繋げる。

$ kubectl -n argo port-forward deployment/argo-server 2746:2746

ブラウザでアクセス。
http://localhost:2746/

daylightdaylight

※公式のPort-forward手順でエラーが発生したため断念

ブラウザでPodに接続しようとすると、何かエラーが出た。。。
kindも初めて使うからセットアップが足りてないのかもしれない。

$ kubectl -n argo port-forward deployment/argo-server 2746:2746
Forwarding from 127.0.0.1:2746 -> 2746
Forwarding from [::1]:2746 -> 2746
Handling connection for 2746
E1015 23:22:58.332303   16562 portforward.go:409] an error occurred forwarding 2746 -> 2746: error forwarding port 2746 to pod 75f577c96e488acd0f9ac56a25b68932fd6646fd75bbc024d7ed53117b4ea960, uid : failed to execute portforward in network namespace "/var/run/netns/cni-f6500a3f-c01e-3440-1e54-ad2236655527": read tcp4 127.0.0.1:34982->127.0.0.1:2746: read: connection reset by peer
error: lost connection to pod

クラスターとkubectlのバージョンが異なっているのが原因かもしれない。
kubernetes - Port-forward drops connection to pod after first connection - Stack Overflow

見たら確かに違った。

$ kubectl version
Client Version: v1.28.2
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.27.3

kubectlをサーバーに合わせて入れ直す。

$ asdf install kubectl 1.27.3
$ asdf global kubectl 1.27.3

再度ブラウザでアクセス。

$ kubectl -n argo port-forward deployment/argo-server 2746:2746
Forwarding from 127.0.0.1:2746 -> 2746
Forwarding from [::1]:2746 -> 2746
Handling connection for 2746
E1015 23:29:20.297314   17716 portforward.go:409] an error occurred forwarding 2746 -> 2746: error forwarding port 2746 to pod 75f577c96e488acd0f9ac56a25b68932fd6646fd75bbc024d7ed53117b4ea960, uid : failed to execute portforward in network namespace "/var/run/netns/cni-f6500a3f-c01e-3440-1e54-ad2236655527": read tcp4 127.0.0.1:52902->127.0.0.1:2746: read: connection reset by peer
error: lost connection to pod

変わらん。

daylightdaylight

Nginx Ingressでリトライ

ラクスさんのブログ元に、一回Ingressでの接続試してみる。

kindの定義ファイル作成。

cluster.yml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  kubeadmConfigPatches:
  - |
    kind: InitConfiguration
    nodeRegistration:
      kubeletExtraArgs:
        node-labels: "ingress-ready=true"
  extraPortMappings:
  - containerPort: 80
    hostPort: 80
    protocol: TCP

kindのクラスターを作り直す。

$ kind delete cluster
$ kind create cluster --config cluster.yml

kind公式のNginx Ingress設定手順通りに、Nginx Ingress Controllerセットアップ。

$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
namespace/ingress-nginx created
serviceaccount/ingress-nginx created
...
validatingwebhookconfiguration.admissionregistration.k8s.io/ingress-nginx-admission created

$ kubectl wait --namespace ingress-nginx \
  --for=condition=ready pod \
  --selector=app.kubernetes.io/component=controller \
  --timeout=90s
pod/ingress-nginx-controller-5b4476f47d-dxct2 condition met

再度Argo Workflowを入れ直す。

$ kubectl create namespace argo
$ kubectl apply -n argo -f https://github.com/argoproj/argo-workflows/releases/download/v3.5.0/install.yaml
daylightdaylight

HTTPで接続

ラクスさんのブログにある通りにマニフェストを修正する。

$ kubectl edit deployment/argo-server --namespace=argo
deployment.apps/argo-server edited

# 1. vim(デフォルトエディタ)が起動されるので、
#    template.spec.containers.argsに2項目(--secure, --auth-mode)を追加
    spec:
      containers:
      - args:
        - server
        - --secure=false # HTTPでの通信に変更
        - --auth-mode=server # ArgoWorkflowsを動かしたいだけなので認証なしモード

# 2. HTTPSと定義されている部分をHTTPで一括置換(vim)
:%s/HTTPS/HTTP/g

# 3. 保存
:wq

ブラウザでアクセス

open http://localhost

繋がった!

daylightdaylight

Workflow試してみる

kubectlからのapply方法も知りたいが、一旦公式手順のCLIで試す。

$ argo submit -n argo --watch https://raw.githubusercontent.com/argoproj/argo-workflows/master/examples/hello-world.yaml

インストール先の情報などが表示された。

さらに、何やらwatchが始まった。

STEP                  TEMPLATE  PODNAME            DURATION  MESSAGE
 ◷ hello-world-rftg8  whalesay  hello-world-rftg8  0s
Name:                hello-world-rftg8
Namespace:           argo
ServiceAccount:      unset (will run with the default ServiceAccount)
Status:              Running
Created:             Mon Oct 16 00:04:43 +0900 (1 second ago)
Started:             Mon Oct 16 00:04:43 +0900 (1 second ago)
Duration:            1 second
Progress:            0/1

完了したので、Webコンソールも見てみるとワークフローの完了が確認できる。

CLIからも確認できるよう。

$ argo list -n argo
NAME                STATUS      AGE   DURATION   PRIORITY   MESSAGE
hello-world-rftg8   Succeeded   4m    20s        0

ワークフローの実行ログも確認できた。

$ argo logs -n argo @latest
hello-world-rftg8:  _____________
hello-world-rftg8: < hello world >
hello-world-rftg8:  -------------
hello-world-rftg8:     \
hello-world-rftg8:      \
hello-world-rftg8:       \
hello-world-rftg8:                     ##        .
hello-world-rftg8:               ## ## ##       ==
hello-world-rftg8:            ## ## ## ##      ===
hello-world-rftg8:        /""""""""""""""""___/ ===
hello-world-rftg8:   ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
hello-world-rftg8:        \______ o          __/
hello-world-rftg8:         \    \        __/
hello-world-rftg8:           \____\______/
hello-world-rftg8: time="2023-10-15T15:05:00.038Z" level=info msg="sub-process exited" argo=true error="<nil>"