Skip to content

Instantly share code, notes, and snippets.

@darpr
Created September 7, 2020 19:08
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save darpr/5f85bab43c1439450364619bd84eb265 to your computer and use it in GitHub Desktop.
Save darpr/5f85bab43c1439450364619bd84eb265 to your computer and use it in GitHub Desktop.
"Argo Workflow" in `kind` Cluster

Argo in Kind

Play with "Argo Workflow" in your local kind cluster.

Prerequisites

The following instructions were tested in macOS Catalina (10.15.6), on 6 Sep 2020.

Docker Runtime

Ensure docker is installed and running.

K8s Client

Install kubectl CLI if you haven't yet.

Kind Cluster

Configure kind before creating a cluster:

$ cat ~/.kube/kind-config.yaml
# 2 node (one masters & one worker) cluster config
kind: Cluster
apiVersion: kind.sigs.k8s.io/v1alpha3
nodes:
- role: control-plane
- role: worker
  extraPortMappings:
  - containerPort: 80
    hostPort: 80
    listenAddress: "0.0.0.0"
  - containerPort: 443
    hostPort: 443
    listenAddress: "0.0.0.0"

Create kind cluster:

$ kind create cluster --name argo --config ~/.kube/kind-config.yaml

Set KUBECONFIG:

$ export KUBECONFIG="$(kind get kubeconfig-path --name="argo")"

Verify:

$ kubectl cluster-info
Kubernetes master is running at https://127.0.0.1:58386
KubeDNS is running at https://127.0.0.1:58386/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
 
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

Install Argo

Create Namespace:

$ kubectl create ns argo

In Argo, each Workflow Step is a K8s Pod. For Argo to create pods to execute the steps of a Workflow, we must create a Rolebinding to grant permission to Argo Workflow Controller to run Pods in default namespace:

$ kubectl create rolebinding default-admin --clusterrole=admin --serviceaccount=default:default

By default, Argo's Executor is docker. That doesn't work with kind clusters. Kind uses containerd, so let's configure Workflow Controller to use PNS (Process Namespace Sharing) executor:

$ kubectl create configmap -n argo workflow-controller-configmap --from-literal=config="containerRuntimeExecutor: pns"

Install Argo:

$ kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo/v2.4.3/manifests/install.yaml

Verify if all Images have been pulled and that Pods are running:

$ kcgp -n argo
NAME                                   READY   STATUS    RESTARTS   AGE
argo-ui-6b67c96956-d66m7               1/1     Running   0          69s
workflow-controller-7cf6ffb79f-d2x2w   1/1     Running   0          69s

Test Argo Workflow

Argo is a Kubernetes Custom Controller and Workflow CRD (extension of K8s API). This means that kubectl can be used to manage Workflows instead of Argo CLI:

$ kubectl create -f https://raw.githubusercontent.com/argoproj/argo/master/examples/coinflip.yaml

Port-forward:

$ kubectl port-forward -n argo svc/argo-ui 8080:80

Launch Argo UI at http://localhost:8080/.

Known Issues

If you get the following error, make sure that you change Workflow Executor specific for kind Clusters:

$ kubectl describe pod hello-world-vc727 -n argo
...
...
Events:
  Type     Reason       Age                   From                  Message
  ----     ------       ----                  ----                  -------
  Normal   Scheduled    7m51s                 default-scheduler     Successfully assigned argo/hello-world-vc727 to argo-worker
  Warning  FailedMount  98s (x11 over 7m50s)  kubelet, argo-worker  MountVolume.SetUp failed for volume "docker-sock" : hostPath type check failed: /var/run/docker.sock is not a socket file
  Warning  FailedMount  77s (x3 over 5m48s)   kubelet, argo-worker  Unable to mount volumes for pod "hello-world-vc727_argo(34a70316-afec-4754-8462-14b828e3cce5)": timeout expired waiting for volumes to attach or mount for pod "argo"/"hello-world-vc727". list of unmounted volumes=[docker-sock]. list of unattached volumes=[podmetadata docker-sock my-minio-cred default-token-xqwb5]

References

  1. Kind for local Kubernetes - https://kind.sigs.k8s.io/
  2. Argo Quick Start - https://argoproj.github.io/argo/quick-start/
  3. Someone's solution in making Argo work in MicroK8s; use similar approach for kind clusters - argoproj/argo-workflows#2557
  4. https://boxboat.com/2020/02/10/argo-workflows/
@wuhuizuo
Copy link

now can using the latest mainifest

@kemalty
Copy link

kemalty commented Jun 13, 2022

Here are a few fixes if you are running this around Jun 2022:

For File: kind-config.yaml

Change

   3   │ apiVersion: kind.sigs.k8s.io/v1alpha3 

to

   3   │ apiVersion: kind.x-k8s.io/v1alpha4

Argo Install

Instead of

kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo/v2.4.3/manifests/install.yaml

Use

kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo/v3.3.6/manifests/install.yaml                                                              

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment