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.
feat(controller): HTTP Template and Agent support feature (argoproj#5750
- Loading branch information
1 parent
20efb52
commit b16a0a0
Showing
47 changed files
with
7,435 additions
and
6,048 deletions.
There are no files selected for viewing
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,63 @@ | ||
package commands | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"k8s.io/client-go/kubernetes" | ||
restclient "k8s.io/client-go/rest" | ||
|
||
"github.com/argoproj/argo-workflows/v3" | ||
workflow "github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned" | ||
"github.com/argoproj/argo-workflows/v3/util/logs" | ||
"github.com/argoproj/argo-workflows/v3/workflow/common" | ||
"github.com/argoproj/argo-workflows/v3/workflow/executor" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewAgentCommand() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "agent", | ||
SilenceUsage: true, // this prevents confusing usage message being printed on error | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return initAgentExecutor().Agent(context.Background()) | ||
}, | ||
} | ||
} | ||
|
||
func initAgentExecutor() *executor.AgentExecutor { | ||
version := argo.GetVersion() | ||
log.WithFields(log.Fields{"version": version.Version}).Info("Starting Workflow Executor") | ||
config, err := clientConfig.ClientConfig() | ||
checkErr(err) | ||
|
||
config = restclient.AddUserAgent(config, fmt.Sprintf("argo-workflows/%s argo-executor/%s", version.Version, "agent Executor")) | ||
|
||
logs.AddK8SLogTransportWrapper(config) // lets log all request as we should typically do < 5 per pod, so this is will show up problems | ||
|
||
namespace, _, err := clientConfig.Namespace() | ||
checkErr(err) | ||
|
||
clientSet, err := kubernetes.NewForConfig(config) | ||
checkErr(err) | ||
|
||
restClient := clientSet.RESTClient() | ||
|
||
workflowName, ok := os.LookupEnv(common.EnvVarWorkflowName) | ||
if !ok { | ||
log.Fatalf("Unable to determine workflow name from environment variable %s", common.EnvVarWorkflowName) | ||
} | ||
agentExecutor := executor.AgentExecutor{ | ||
ClientSet: clientSet, | ||
RESTClient: restClient, | ||
Namespace: namespace, | ||
WorkflowName: workflowName, | ||
WorkflowInterface: workflow.NewForConfigOrDie(config), | ||
CompleteTask: make(map[string]struct{}), | ||
} | ||
return &agentExecutor | ||
|
||
} |
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,34 @@ | ||
# HTTP Template | ||
|
||
> v3.2 and after | ||
`HTTP Template` is a type of template which can execute the HTTP Requests. | ||
|
||
### Agent Architecture | ||
V3.2 introduced `Agent` architecture to execute the multiple HTTPTemplates in single pod which improve a performance and resource utilization. | ||
`WorkflowTaskSet` CRD is introduced to exchange the data between Controller and Agent. | ||
Agent pod named <workflowname-agent> and WorkflowTaskSet name as WorkflowName. | ||
|
||
```yaml | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: http-template- | ||
spec: | ||
entrypoint: main | ||
templates: | ||
- name: main | ||
steps: | ||
- - name: good | ||
template: http | ||
arguments: | ||
parameters: [{name: url, value: "https://raw.githubusercontent.com/argoproj/argo-workflows/4e450e250168e6b4d51a126b784e90b11a0162bc/pkg/apis/workflow/v1alpha1/generated.swagger.json"}] | ||
- name: http | ||
inputs: | ||
parameters: | ||
- name: url | ||
http: | ||
# url: http:https://dummy.restapiexample.com/api/v1/employees | ||
url: "{{inputs.parameters.url}}" | ||
|
||
``` |
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,36 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: http-template- | ||
labels: | ||
workflows.argoproj.io/test: "true" | ||
annotations: | ||
workflows.argoproj.io/description: | | ||
Http template will demostrate http template functionality | ||
workflows.argoproj.io/version: '>= 3.2.0' | ||
workflows.argoproj.io/verify.py: | | ||
assert status["phase"] == "Succeeded" | ||
spec: | ||
entrypoint: main | ||
templates: | ||
- name: main | ||
steps: | ||
- - name: good | ||
template: http | ||
arguments: | ||
parameters: [{name: url, value: "https://raw.githubusercontent.com/argoproj/argo-workflows/4e450e250168e6b4d51a126b784e90b11a0162bc/pkg/apis/workflow/v1alpha1/generated.swagger.json"}] | ||
- name: bad | ||
template: http | ||
continueOn: | ||
failed: true | ||
arguments: | ||
parameters: [{name: url, value: "http:https://openlibrary.org/people/george08/nofound.json"}] | ||
|
||
- name: http | ||
inputs: | ||
parameters: | ||
- name: url | ||
http: | ||
# url: http:https://dummy.restapiexample.com/api/v1/employees | ||
url: "{{inputs.parameters.url}}" | ||
|
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.