argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.33k stars 5.26k forks source link

argocd --port-forward-namespace=argocd login not accepting parameter #5219

Open r0bj opened 3 years ago

r0bj commented 3 years ago

If you are trying to resolve an environment-specific issue or have a one-off question about the edge case that does not require a feature then please consider asking a question in argocd slack channel.

Checklist:

Describe the bug

argocd login is not accepting parameter --port-forward-namespace

To Reproduce

argocd --port-forward-namespace=argocd login
argocd --port-forward-namespace argocd login
argocd login --port-forward-namespace=argocd
argocd login --port-forward-namespace=argocd

All those commands returns argocd login usage help:

$ argocd --port-forward-namespace argocd login
Log in to Argo CD

Usage:
  argocd login SERVER [flags]

Flags:
  -h, --help              help for login
      --name string       name to use for the context
      --password string   the password of an account to authenticate
      --sso               perform SSO login
      --sso-port int      port to run local OAuth2 login application (default 8085)
      --username string   the username of an account to authenticate

Global Flags:
      --auth-token string               Authentication token
      --client-crt string               Client certificate file
      --client-crt-key string           Client certificate key file
      --config string                   Path to Argo CD config (default "/Users/rob/.argocd/config")
      --grpc-web                        Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2.
      --grpc-web-root-path string       Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2. Set web root.
  -H, --header strings                  Sets additional header to all requests made by Argo CD CLI. (Can be repeated multiple times to add multiple headers, also supports comma separated headers)
      --insecure                        Skip server certificate and domain verification
      --logformat string                Set the logging format. One of: text|json (default "text")
      --loglevel string                 Set the logging level. One of: debug|info|warn|error (default "info")
      --plaintext                       Disable TLS
      --port-forward                    Connect to a random argocd-server port using port forwarding
      --port-forward-namespace string   Namespace name which should be used for port forwarding
      --server string                   Argo CD server address
      --server-crt string               Server certificate file

Expected behavior

I'm able to login with command argocd --port-forward-namespace=argocd login

Version

argocd: v1.8.1+c2547dc.dirty
  BuildDate: 2020-12-10T04:44:20Z
  GitCommit: c2547dca95437fdbb4d1e984b0592e6b9110d37f
  GitTreeState: dirty
  GoVersion: go1.15.5
  Compiler: gc
  Platform: darwin/amd64
argocd-server: v1.8.1+c2547dc
  BuildDate: 2020-12-10T02:59:21Z
  GitCommit: c2547dca95437fdbb4d1e984b0592e6b9110d37f
  GitTreeState: clean
  GoVersion: go1.14.12
  Compiler: gc
  Platform: linux/amd64
  Ksonnet Version: v0.13.1
  Kustomize Version: v3.8.1 2020-07-16T00:58:46Z
  Helm Version: v3.4.1+gc4e7485
  Kubectl Version: v1.17.8
  Jsonnet Version: v0.17.0
MPV commented 3 years ago

Does setting ARGOCD_OPTS="--port-forward-namespace argocd" help?

r0bj commented 3 years ago

WIth using ARGOCD_OPTS="--port-forward-namespace argocd" is the same effect.

cbanek commented 3 years ago

What about doing both --port-forward and --port-forward-namespace argocd in the same command?

r0bj commented 3 years ago

Using both --port-forward and --port-forward-namespace seems working, is it the intention? If so, what would be the logic to use --port-forward-namespace without wanting to use port forward?

cbanek commented 3 years ago

Can't say it makes sense, I just know it works. I didn't do it that way, but I did get login to work for port forward, so that's how I know.

wtam2018 commented 3 years ago

From my read to the code, it looks like it is intentional because you are allowed to enable port forwarding with port-forward-namespace = empty string. In this case, the port forward namespace is default to the namespace in the client config.

r0bj commented 3 years ago

For other argocd subcommands than login it's enough to use just --port-forward-namespace=argocd. But for argocd login we need to use both --port-forward-namespace=argocd and --port-forward. It's seems quite inconsistent.

avodaqstephan commented 2 years ago

Stumbled across this today. For the login I need to have the option --port-forward in place.

argocd login --port-forward --plaintext --port-forward-namespace argocd

However, it is not necessary for listing my existing apps

argocd app list --port-forward-namespace argocd

lindhe commented 1 year ago

Also, this feels off:

$ argocd login --port-forward --port-forward-namespace argocd
Username: admin
Password:
'admin:login' logged in successfully
Context 'port-forward' updated

Note the last line: "Context 'port-forward' updated". The context got the name "port-forward". Sounds more like a side effect than the intention of the code, imo. Sounds like that piece of logic needs some looking over. :)