> For the complete documentation index, see [llms.txt](https://docs.hackerspot.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackerspot.net/cheatsheets/cloud-tools/argo.md).

# Argo

## **Installation**

**Install Argo CLI:**

```bash
brew install argoproj/tap/argo
```

**Install Argo Workflows in Kubernetes:**

```bash
kubectl create namespace argo
kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo-workflows/stable/manifests/install.yaml
```

## **Access the Argo UI**

**Port-forward the Argo UI:**

```bash
kubectl -n argo port-forward deployment/argo-server 2746:2746
```

**Access UI:** Open a browser and go to `http://localhost:2746`.

## **Submit a Workflow**

**Create a simple workflow YAML (hello-world.yaml):**

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: hello-world-
spec:
  entrypoint: whalesay
  templates:
  - name: whalesay
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["hello world"]
```

**Submit the workflow:**

```bash
argo submit hello-world.yaml
```

## **Monitor Workflows**

**List workflows:**

```bash
argo list
```

**Get workflow details:**

```bash
argo get <workflow-name>
```

**Watch workflow logs:**

```bash
argo logs -w <workflow-name>
```

**Watch the progress of a workflow:**

```bash
argo watch <workflow-name>
```

## **Workflow Lifecycle Management**

**Suspend a running workflow:**

```bash
argo suspend <workflow-name>
```

**Resume a suspended workflow:**

```bash
argo resume <workflow-name>
```

**Terminate a running workflow:**

```bash
argo terminate <workflow-name>
```

**Retry a failed workflow:**

```bash
argo retry <workflow-name>
```

## **Create Workflow Templates**

**Define a template (workflow-template.yaml):**

```yaml
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: hello-world-template
spec:
  entrypoint: whalesay
  templates:
  - name: whalesay
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["hello world from template"]
```

**Create the template:**

```bash
kubectl apply -f workflow-template.yaml
```

**Submit a workflow using the template:**

```bash
argo submit --from workflowtemplate/hello-world-template
```

## **Using Parameters in Workflows**

**Define a parameterized workflow (params-workflow\.yaml):**

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: hello-world-param-
spec:
  entrypoint: whalesay
  arguments:
    parameters:
    - name: message
      value: "hello world"
  templates:
  - name: whalesay
    inputs:
      parameters:
      - name: message
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["{{inputs.parameters.message}}"]
```

**Submit with parameters:**

```bash
argo submit params-workflow.yaml -p message="hello Argo"
```

## **Artifacts and Outputs**

**Define a workflow with artifacts (artifacts-workflow\.yaml):**

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: artifacts-
spec:
  entrypoint: whalesay
  templates:
  - name: whalesay
    container:
      image: docker/whalesay
      command: [cowsay]
      args: ["hello world"]
    outputs:
      artifacts:
      - name: message
        path: /tmp/message
```

## **DAG and Steps**

**Define a DAG workflow (dag-workflow\.yaml):**

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: dag-diamond-
spec:
  entrypoint: diamond
  templates:
  - name: diamond
    dag:
      tasks:
      - name: A
        template: echo
        arguments:
          parameters: [{name: message, value: "A"}]
      - name: B
        dependencies: [A]
        template: echo
        arguments:
          parameters: [{name: message, value: "B"}]
      - name: C
        dependencies: [A]
        template: echo
        arguments:
          parameters: [{name: message, value: "C"}]
      - name: D
        dependencies: [B, C]
        template: echo
        arguments:
          parameters: [{name: message, value: "D"}]
  - name: echo
    inputs:
      parameters:
      - name: message
    container:
      image: alpine:3.7
      command: [sh, -c]
      args: ["echo {{inputs.parameters.message}}"]
```

**Submit the DAG workflow:**

```bash
argo submit dag-workflow.yaml
```

## **Clean Up**

**Delete a workflow:**

```bash
argo delete <workflow-name>
```

**Delete all workflows:**

```bash
argo delete --all
```

**Useful Commands**

* **View Argo version:**

  ```bash
  argo version
  ```
* **Get the status of a workflow:**

  ```bash
  argo get <workflow-name>
  ```
* **Resume a suspended workflow:**

  ```bash
  argo resume <workflow-name>
  ```

This cheat sheet should help you start with Argo Workflows in a Kubernetes environment. For more detailed information, refer to the Argo Workflows documentation.
