Argo workflow

Learning Argo

Install argo cli

brew install argo

➜  ~ argo version
argo: latest+f97bef5.dirty
  BuildDate: 2021-01-13T01:54:18Z
  GitCommit: f97bef5d00361f3d1cbb8574f7f6adf632673008
  GitTreeState: dirty
  GitTag: v2.12.4
  GoVersion: go1.15.6
  Compiler: gc
  Platform: darwin/amd64

Argo commands

Before you start. set up the kubernetes environments

  • connect vpn
  • set up kubernetes
➜  ~ kubectx -c
gke_onec-co_us-west2-c_onec-dev
➜  ~ kubectx
docker-desktop
gke_onec-co-prod_us-west2-c_onec-prod
gke_onec-co_us-west2-c_onec-dev
gke_onec-co_us-west2-c_onec-staging
  • set up namespace
➜  ~ kubens
argo
argo-events
built-object-service
custom-metrics
datamon-ci
➜  ~ kubens -c
built-object-service
  • Examples
argo list -n seismic-workflows --running
argo get -n seismic-workflows seismic-pipeline-xxxx
argo logs -n seismic-workflows -w seismic-pipeline-xxxx -f

argo submit hello-world.yaml    # submit a workflow spec to Kubernetes
argo list                       # list current workflows
argo get hello-world-xxx        # get info about a specific workflow
argo logs hello-world-xxx       # print the logs from a workflow
argo delete hello-world-xxx     # delete workflow

argo submit arguments-parameters.yaml -p message="goodbye world"
argo submit arguments-parameters.yaml --parameter-file params.yaml

How I work

# 01. check environment
✔ kubectx -c
gke_onec-co_us-west2-c_onec-dev
✔ kubens -c
built-object-service

# 02. make run.sh file
argo submit -n built-object-service workflows/database_seeder/database_seeder.yaml \
  -f workflows/database_seeder/database_seeder.parameters.dev.yaml

# 03. submit the job
✔ ./run.sh
Name:                built-object-database-seeder-gfknv
Namespace:           built-object-service
ServiceAccount:      default
Status:              Pending
Created:             Mon Jan 25 23:45:22 -0800 (now)
Progress:
Parameters:
  docker-image-tag:  v0.1.0-29-g931c8dc

# 04. the job is submitted
✔ argo list
NAME                                 STATUS    AGE   DURATION   PRIORITY
built-object-database-seeder-gfknv   Running   42s   42s        0

# 05. get the information of the job
argo get built-object-database-seeder-gfknv
Name:                built-object-database-seeder-gfknv
Namespace:           built-object-service
ServiceAccount:      default
Status:              Running
Created:             Mon Jan 25 23:45:22 -0800 (1 minute ago)
Started:             Mon Jan 25 23:45:22 -0800 (1 minute ago)
Duration:            1 minute 10 seconds
Progress:
Parameters:
  docker-image-tag:  v0.1.0-29-g931c8dc

STEP                                   TEMPLATE           PODNAME                             DURATION  MESSAGE
 ● built-object-database-seeder-gfknv  write-to-database  built-object-database-seeder-gfknv  1m

# now it's kubernetes job so I can check it with kubectl commands
✔ k get po
NAME                                    READY   STATUS    RESTARTS   AGE
built-object-database-seeder-gfknv      2/3     Error     0          87s
built-object-service-79c45fbcf6-76qvb   2/2     Running   0          3d7h

# check what went wrong
✔ k describe po built-object-database-seeder-gfknv
Name:         built-object-database-seeder-gfknv
Namespace:    built-object-service
Priority:     0
Node:         gke-onec-dev-exposure-development-de0bf40e-vqtg/10.0.0.113
Start Time:   Mon, 25 Jan 2021 23:45:22 -0800
Labels:       workflows.argoproj.io/completed=false
              workflows.argoproj.io/workflow=built-object-database-seeder-gfknv
Annotations:  cni.projectcalico.org/podIP: 10.60.33.10/32
              workflows.argoproj.io/node-name: built-object-database-seeder-gfknv
              workflows.argoproj.io/template:
                {"name":"write-to-database","arguments":{},"inputs":{},"outputs":{},"metadata":{},"container":{"name":"","image":"gcr.io/onec-co/built-obj...
Status:       Running
IP:           10.60.33.10
IPs:
  IP:           10.60.33.10
Controlled By:  Workflow/built-object-database-seeder-gfknv
Containers:
  wait:
    Container ID:  docker://531594564f91ab2ed0b12911fa2831c91666704aa432f8f94472b358728e84bd
    Image:         gcr.io/onec-co/argoexec:v2.11.6-dev
    Image ID:      docker-pullable://gcr.io/onec-co/[email protected]:69c6e4676f063327999b0d9e1150de2f663d5d935bc275447109c0cb44edf5c5
    Port:          <none>
    Host Port:     <none>
    Command:
      argoexec
      wait
    State:          Terminated
      Reason:       Error
      Message:      Failed to establish pod watch: timed out waiting for the condition
      Exit Code:    1
      Started:      Mon, 25 Jan 2021 23:45:23 -0800
      Finished:     Mon, 25 Jan 2021 23:45:45 -0800
    Ready:          False
    Restart Count:  0
    Environment:
      ARGO_POD_NAME:  built-object-database-seeder-gfknv (v1:metadata.name)
    Mounts:
      /argo/podmetadata from podmetadata (rw)
      /argo/secret/flood-gcs-credentials from flood-gcs-credentials (ro)
      /var/run/docker.sock from docker-sock (ro)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-2zml7 (ro)
  main:
    Container ID:  docker://31cf60b1308621c9c9544d60fe080965a3317bea7e8c3d7b42f3345f68c97b0f
    Image:         gcr.io/onec-co/built-object-service:v0.1.0-29-g931c8dc
    Image ID:      docker-pullable://gcr.io/onec-co/[email protected]:dd4117cd7363f4912e5bee4d71f293b98886e85be27dc8f351e708eadc56bc13
    Port:          <none>
    Host Port:     <none>
    Command:
      flask
    Args:
      run
    State:          Running
      Started:      Mon, 25 Jan 2021 23:45:23 -0800
    Ready:          True
    Restart Count:  0
    Environment:
      DATABASE_HOST:      localhost
      DATABASE_NAME:      built-object-service
      DATABASE_USER:      oneconcern
      DATABASE_PASSWORD:  <set to the key 'PG_PASSWORD' in secret 'built-object-service-pg-creds'>  Optional: false
      DATABASE_PORT:      5432
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-2zml7 (ro)
  cloudsql-proxy:
    Container ID:  docker://f86ff0a17d4d09eccf1bbc70b41ce3b079a7ed2dcf8a08680324502ab3c30607
    Image:         gcr.io/onec-co/cloudsql-proxy-argo:1.11_param
    Image ID:      docker-pullable://gcr.io/onec-co/[email protected]:98f313480c8c1c4da4d8fe944899fd11bc08f437f6b5204b3f54e95c738ff4ca
    Port:          <none>
    Host Port:     <none>
    Command:
      bash
      /run-proxy.sh
      built-object-service
    State:          Running
      Started:      Mon, 25 Jan 2021 23:45:23 -0800
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /secrets/cloudsql from cloud-sql-google-creds (ro)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-2zml7 (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  podmetadata:
    Type:  DownwardAPI (a volume populated by information about the pod)
    Items:
      metadata.annotations -> annotations
  docker-sock:
    Type:          HostPath (bare host directory volume)
    Path:          /var/run/docker.sock
    HostPathType:  Socket
  cloud-sql-google-creds:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  built-object-service-cloud-sql-google-creds
    Optional:    false
  flood-gcs-credentials:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  flood-gcs-credentials
    Optional:    false
  default-token-2zml7:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-2zml7
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
                 role=exposure-development:NoSchedule
Events:
  Type    Reason     Age    From               Message
  ----    ------     ----   ----               -------
  Normal  Scheduled  2m42s  default-scheduler  Successfully assigned built-object-service/built-object-database-seeder-gfknv to gke-onec-dev-exposure-development-de0bf40e-vqtg
  Normal  Pulled     2m42s  kubelet            Container image "gcr.io/onec-co/argoexec:v2.11.6-dev" already present on machine
  Normal  Created    2m42s  kubelet            Created container wait
  Normal  Started    2m41s  kubelet            Started container wait
  Normal  Pulled     2m41s  kubelet            Container image "gcr.io/onec-co/built-object-service:v0.1.0-29-g931c8dc" already present on machine
  Normal  Created    2m41s  kubelet            Created container main
  Normal  Started    2m41s  kubelet            Started container main
  Normal  Pulled     2m41s  kubelet            Container image "gcr.io/onec-co/cloudsql-proxy-argo:1.11_param" already present on machine
  Normal  Created    2m41s  kubelet            Created container cloudsql-proxy
  Normal  Started    2m41s  kubelet            Started container cloudsql-proxy

Argo workflow

Argo

argoproj/argo

Introducing Argo - A Container-Native Workflow Engine for Kubernetes

* job scheduler, closly tied to kubernetes
* define workflow and run
* https://blog.argoproj.io/introducing-argo-a-container-native-workflow-engine-for-kubernetes-55c0b4b76fac
* seismic-resilliences/worklflows/bridges/workflow.yaml
* pods gets created
* argo cli: argo submit
* https://argoproj.github.io/argo/
* https://github.com/argoproj/argo-events
* trigger workflow based on the condition
* listen to pub/sub and run the workflow
* listen to pub/sub, git commit, any trigger
* flood-launchpad-kc-configmap -> internally to

Hello world of argo pipeline

apiVersion: argoproj.io/v1alpha1
kind: Workflow                  # new type of k8s spec
metadata:
  generateName: hello-world-    # name of the workflow spec
spec:
  entrypoint: whalesay          # invoke the whalesay template
  templates:
  - name: whalesay              # name of the template
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["hello world"]

Snippets

kubectl logs -n dev zenrin-builiding-import-wbcgq-3063778619
kubectl -n argo get svc
kubectl -n argo port-forward svc/argo-server 30443:443
kubectl -n argo port-forward svc/argo-server 30443:
argo submit -n built-object-service workflows/imputation/zenrin/zenrin.yaml -f workflow/imputation/zenrin/zenrin.parameters.japan.dev.yaml
argo watch -n 
COMMENTS
Related Post
Firewalld commands
Sops