forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation for resource templates and resource wait/fail conditions
- Loading branch information
Showing
13 changed files
with
419 additions
and
93 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package commands | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/argoproj/argo/workflow/common" | ||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
RootCmd.AddCommand(resourceCmd) | ||
} | ||
|
||
var resourceCmd = &cobra.Command{ | ||
Use: "resource (get|create|apply|delete) MANIFEST", | ||
Short: "update a resource and wait for resource conditions", | ||
Run: execResource, | ||
} | ||
|
||
func execResource(cmd *cobra.Command, args []string) { | ||
if len(args) != 1 { | ||
cmd.HelpFunc()(cmd, args) | ||
os.Exit(1) | ||
} | ||
|
||
wfExecutor := initExecutor() | ||
err := wfExecutor.StageFiles() | ||
if err != nil { | ||
_ = wfExecutor.AddAnnotation(common.AnnotationKeyNodeMessage, err.Error()) | ||
log.Fatalf("Error staing resource: %+v", err) | ||
} | ||
resourceName, err := wfExecutor.ExecResource(args[0], common.ExecutorResourceManifestPath) | ||
if err != nil { | ||
_ = wfExecutor.AddAnnotation(common.AnnotationKeyNodeMessage, err.Error()) | ||
log.Fatalf("Error running %s resource: %+v", args[0], err) | ||
} | ||
err = wfExecutor.WaitResource(resourceName) | ||
if err != nil { | ||
_ = wfExecutor.AddAnnotation(common.AnnotationKeyNodeMessage, err.Error()) | ||
log.Fatalf("Error waiting for resource %s: %+v", resourceName, err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# This example demonstrates the 'resource' template type, which provides a | ||
# convenient way to create/update/delete any type of kubernetes resources | ||
# in a workflow. The resource template type accepts any k8s manifest | ||
# (including CRDs) and can perform any kubectl action against it (e.g. create, | ||
# apply, delete, patch). | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: k8s-jobs- | ||
spec: | ||
entrypoint: pi-tmpl | ||
templates: | ||
- name: pi-tmpl | ||
resource: | ||
action: create | ||
# successCondition and failureCondition are expressions which are evaluated | ||
# upon every update of the resource. If failureCondition is ever evaluated | ||
# to true, the step is considered failed. Likewise, if successCondition is | ||
# ever evaluated to true the step is considered successful. It uses 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, see: | ||
# https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ | ||
successCondition: status.succeeded > 0 | ||
failureCondition: status.failed > 3 | ||
manifest: | | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
generateName: pi-job- | ||
spec: | ||
template: | ||
metadata: | ||
name: pi | ||
spec: | ||
containers: | ||
- name: pi | ||
image: perl | ||
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] | ||
restartPolicy: Never | ||
backoffLimit: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.