From 220e9972f89f7168607781a6db8e45d66f6a5ae5 Mon Sep 17 00:00:00 2001 From: googs1025 Date: Mon, 1 Jul 2024 14:39:26 +0800 Subject: [PATCH] docs: add argo workflow example for jobset --- examples/argo-workflow/rbac.yaml | 88 ++++++++++++++++++++++++++++ examples/argo-workflow/workflow.yaml | 61 +++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 examples/argo-workflow/rbac.yaml create mode 100644 examples/argo-workflow/workflow.yaml diff --git a/examples/argo-workflow/rbac.yaml b/examples/argo-workflow/rbac.yaml new file mode 100644 index 00000000..6158bb27 --- /dev/null +++ b/examples/argo-workflow/rbac.yaml @@ -0,0 +1,88 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: argo-jobset + namespace: argo +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: argo-jobset-role + namespace: argo +rules: + - apiGroups: + - batch + resources: + - jobs + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - batch + resources: + - jobs/status + verbs: + - get + - patch + - update + - apiGroups: + - "" + resources: + - pods + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - jobset.x-k8s.io + resources: + - jobsets + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - jobset.x-k8s.io + resources: + - jobsets/finalizers + verbs: + - update + - apiGroups: + - jobset.x-k8s.io + resources: + - jobsets/status + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: argo-jobset-binding + namespace: argo +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: argo-jobset-role +subjects: + - kind: ServiceAccount + name: argo-jobset + namespace: argo \ No newline at end of file diff --git a/examples/argo-workflow/workflow.yaml b/examples/argo-workflow/workflow.yaml new file mode 100644 index 00000000..649dda6a --- /dev/null +++ b/examples/argo-workflow/workflow.yaml @@ -0,0 +1,61 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + namespace: argo + generateName: argo-workflow-jobset- +spec: + serviceAccountName: argo-jobset + entrypoint: jobset-example + templates: + - name: jobset-example + resource: # indicates that this is a resource template + # can be any kubectl action (e.g. create, delete, apply, patch) + action: create + # The successCondition and failureCondition are optional expressions. + # If failureCondition is true, the step is considered failed. + # If successCondition is true, the step is considered successful. + # They use kubernetes label selection syntax and can be applied against any field + # of the resource (not just labels). Multiple AND conditions can be represented by comma + # delimited expressions. + # For more details: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ + successCondition: status.terminalState == Completed + failureCondition: status.terminalState == Failed + # put your kubernetes spec here + manifest: | + apiVersion: jobset.x-k8s.io/v1alpha2 + kind: JobSet + metadata: + name: paralleljobs + namespace: argo + spec: + replicatedJobs: + - name: workers + template: + spec: + parallelism: 4 + completions: 4 + backoffLimit: 0 + template: + spec: + containers: + - name: sleep + image: busybox + command: + - sleep + args: + - 100s + - name: driver + template: + spec: + parallelism: 1 + completions: 1 + backoffLimit: 0 + template: + spec: + containers: + - name: sleep + image: busybox + command: + - sleep + args: + - 100s \ No newline at end of file