Skip to content

Commit

Permalink
feat(cli): Support ARGO_HTTP1 for HTTP/1 CLI requests. Fixes argoproj…
Browse files Browse the repository at this point in the history
…#4394 (argoproj#4416)

Signed-off-by: Alex Collins <[email protected]>
  • Loading branch information
alexec authored Nov 6, 2020
1 parent b8fb2a8 commit c31d172
Show file tree
Hide file tree
Showing 73 changed files with 1,280 additions and 317 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ test-e2e:

.PHONY: test-cli
test-cli:
$(GOTEST) -timeout 10m -count 1 --tags cli -p 1 --short ./test/e2e
$(GOTEST) -timeout 15m -count 1 --tags cli -p 1 --short ./test/e2e

.PHONY: test-e2e-cron
test-e2e-cron:
Expand Down
5 changes: 5 additions & 0 deletions cmd/argo/commands/client/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func AddAPIClientFlagsToCmd(cmd *cobra.Command) {
cmd.PersistentFlags().StringVar(&instanceID, "instanceid", os.Getenv("ARGO_INSTANCEID"), "submit with a specific controller's instance id label. Default to the ARGO_INSTANCEID environment variable.")
// "-s" like kubectl
cmd.PersistentFlags().StringVarP(&argoServerOpts.URL, "argo-server", "s", os.Getenv("ARGO_SERVER"), "API server `host:port`. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.")
cmd.PersistentFlags().StringVar(&argoServerOpts.Path, "argo-base-href", os.Getenv("ARGO_BASE_HREF"), "An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.")
cmd.PersistentFlags().BoolVar(&argoServerOpts.HTTP1, "argo-http1", os.Getenv("ARGO_HTTP1") == "true", "If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.")
// "-e" for encrypted - like zip
cmd.PersistentFlags().BoolVarP(&argoServerOpts.Secure, "secure", "e", os.Getenv("ARGO_SECURE") == "true", "Whether or not the server is using TLS with the Argo Server. Defaults to the ARGO_SECURE environment variable.")
// "-k" like curl
Expand All @@ -59,6 +61,9 @@ func NewAPIClient() (context.Context, apiclient.Client) {
}

func Namespace() string {
if overrides.Context.Namespace != "" {
return overrides.Context.Namespace
}
namespace, ok := os.LookupEnv("ARGO_NAMESPACE")
if ok {
return namespace
Expand Down
70 changes: 61 additions & 9 deletions cmd/argo/commands/root.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package commands

import (
"fmt"

"github.com/argoproj/pkg/cli"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/argoproj/argo"
"github.com/argoproj/argo/cmd/argo/commands/clustertemplate"

"github.com/argoproj/argo/cmd/argo/commands/auth"
"github.com/argoproj/argo/cmd/argo/commands/cron"
"github.com/argoproj/argo/util/help"

"github.com/argoproj/argo/cmd/argo/commands/archive"
"github.com/argoproj/argo/cmd/argo/commands/auth"
"github.com/argoproj/argo/cmd/argo/commands/client"
"github.com/argoproj/argo/cmd/argo/commands/cron"
"github.com/argoproj/argo/cmd/argo/commands/template"
)

Expand All @@ -27,9 +23,65 @@ const (
// NewCommand returns a new instance of an argo command
func NewCommand() *cobra.Command {
var command = &cobra.Command{
Use: CLIName,
Short: "argo is the command line interface to Argo",
Example: fmt.Sprintf(`If you're using the Argo Server (e.g. because you need large workflow support or workflow archive), please read %s.`, help.CLI),
Use: CLIName,
Short: "argo is the command line interface to Argo",
Long: `
You can use the CLI in the following modes:
# Kubernetes API Mode (default)
Requests are sent directly to the Kubernetes API. No Argo Server is needs. Large workflows and the workflow archive are not supported.
Use when you have direct access to the Kubernetes API, and don't need large workflow or workflow archive support.
If you're using instance ID (which is very unlikely), you'll need to set it:
ARGO_INSTANCEID=your-instanceid
# Argo Server GRPC Mode
Requests are sent to the Argo Server API via GRPC (using HTTP/2). Large workflows and the workflow archive are supported. Network load-balancers that do not support HTTP/2 are not supported.
Use if you do not have access to the Kubernetes API (e.g. you're in another cluster), and you're running the Argo Server using a network load-balancer that support HTTP/2.
To enable, set ARGO_SERVER:
ARGO_SERVER=localhost:2746 ;# The format is "host:port" - do not prefix with "http" or "https"
If you're have transport-layer security (TLS) enabled (i.e. you are running "argo server --secure" and therefore has HTTPS):
ARGO_SECURE=true
If your server is running with self-signed certificates. Do not use in production:
ARGO_INSECURE_SKIP_VERIFY=true
By default, the CLI uses your KUBECONFIG to determine default for ARGO_TOKEN and ARGO_NAMESPACE. You probably error with "no configuration has been provided". To prevent it:
KUBECONFIG=/dev/null
You will then need to set:
ARGO_NAMESPACE=argo
And:
ARGO_TOKEN='Bearer ******' ;# Should always start with "Bearer " or "Basic ".
# Argo Server HTTP1 Mode
As per GRPC mode, but uses HTTP. Can be used with ALB that does not support HTTP/2. The command "argo logs --since-time=2020...." will not work (due to time-type).
Use this when your network load-balancer does not support HTTP/2.
Use the same configuration as GRPC mode, but also set:
ARGO_HTTP1=true
If your server is behind an ingress with a path (you'll be running "argo server --basehref /...) or "BASE_HREF=/... argo server"):
ARGO_BASE_HREF=/argo
`,
Run: func(cmd *cobra.Command, args []string) {
cmd.HelpFunc()(cmd, args)
},
Expand Down
10 changes: 1 addition & 9 deletions docs/access-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,7 @@ echo $ARGO_TOKEN
Bearer ZXlKaGJHY2lPaUpTVXpJMU5pSXNJbXRwWkNJNkltS...
```

!!!NOTE
The `ARGO_TOKEN` should always start with "Bearer ".

Use that token with the CLI (you need to set `ARGO_SERVER` too):

```sh
ARGO_SERVER=http://localhost:2746
argo list
```
To that token with the CLI you need to set `ARGO_SERVER` (see `argo --help`).

Use that token in your API requests, e.g. to list workflows:

Expand Down
64 changes: 58 additions & 6 deletions docs/cli/argo.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,73 @@ argo is the command line interface to Argo

### Synopsis

argo is the command line interface to Argo

```
argo [flags]
```
You can use the CLI in the following modes:

# Kubernetes API Mode (default)

Requests are sent directly to the Kubernetes API. No Argo Server is needs. Large workflows and the workflow archive are not supported.

Use when you have direct access to the Kubernetes API, and don't need large workflow or workflow archive support.

If you're using instance ID (which is very unlikely), you'll need to set it:

ARGO_INSTANCEID=your-instanceid

# Argo Server GRPC Mode

Requests are sent to the Argo Server API via GRPC (using HTTP/2). Large workflows and the workflow archive are supported. Network load-balancers that do not support HTTP/2 are not supported.

Use if you do not have access to the Kubernetes API (e.g. you're in another cluster), and you're running the Argo Server using a network load-balancer that support HTTP/2.

To enable, set ARGO_SERVER:

ARGO_SERVER=localhost:2746 ;# The format is "host:port" - do not prefix with "http" or "https"

If you're have transport-layer security (TLS) enabled (i.e. you are running "argo server --secure" and therefore has HTTPS):

ARGO_SECURE=true

If your server is running with self-signed certificates. Do not use in production:

ARGO_INSECURE_SKIP_VERIFY=true

By default, the CLI uses your KUBECONFIG to determine default for ARGO_TOKEN and ARGO_NAMESPACE. You probably error with "no configuration has been provided". To prevent it:

KUBECONFIG=/dev/null

You will then need to set:

ARGO_NAMESPACE=argo

And:

ARGO_TOKEN='Bearer ******' ;# Should always start with "Bearer " or "Basic ".

# Argo Server HTTP1 Mode

As per GRPC mode, but uses HTTP. Can be used with ALB that does not support HTTP/2. The command "argo logs --since-time=2020...." will not work (due to time-type).

Use this when your network load-balancer does not support HTTP/2.

Use the same configuration as GRPC mode, but also set:

ARGO_HTTP1=true

If your server is behind an ingress with a path (you'll be running "argo server --basehref /...) or "BASE_HREF=/... argo server"):

ARGO_BASE_HREF=/argo

### Examples

```
If you're using the Argo Server (e.g. because you need large workflow support or workflow archive), please read https://github.com/argoproj/argo/blob/master/docs/cli.md.
argo [flags]
```

### Options

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_archive.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ argo archive [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_archive_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ argo archive delete UID... [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_archive_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ argo archive get UID [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_archive_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ argo archive list [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ argo auth [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_auth_token.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ argo auth token [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_cluster-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ argo cluster-template [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_cluster-template_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ argo cluster-template create FILE1 FILE2... [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_cluster-template_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ argo cluster-template delete WORKFLOW_TEMPLATE [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_cluster-template_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ argo cluster-template get CLUSTER WORKFLOW_TEMPLATE... [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_cluster-template_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ argo cluster-template lint FILE... [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_cluster-template_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ argo cluster-template list [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ argo completion SHELL [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_cron.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ argo cron [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_cron_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ argo cron create FILE1 FILE2... [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
2 changes: 2 additions & 0 deletions docs/cli/argo_cron_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ argo cron delete [CRON_WORKFLOW... | --all] [flags]
### Options inherited from parent commands

```
--argo-base-href string An path to use with HTTP client (e.g. due to BASE_HREF). Defaults to the ARGO_BASE_HREF environment variable.
--argo-http1 If true, use the HTTP client. Defaults to the ARGO_HTTP1 environment variable.
-s, --argo-server host:port API server host:port. e.g. localhost:2746. Defaults to the ARGO_SERVER environment variable.
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
Expand Down
Loading

0 comments on commit c31d172

Please sign in to comment.