argoproj / argo-cd

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

argocd login error 'too many colons in address' or 'unknown port' #10884

Open bygui86 opened 2 years ago

bygui86 commented 2 years ago

Checklist:

Describe the bug

argocd login <URL> doesn't work anymore. I have ArgoCD exposed on internet, so I tried with the specific URL and through "kubectl port-foward" but nothing works.

To Reproduce

Using the ArgoCD external URL:

$ argocd login https://abc.def
FATA[0000] dial tcp: address tcp///abc.def: unknown port

Using port forwarding:

# terminal 1
$ kubectl port-forward svc/argocd-server -n argocd 8080:443
Forwarding from 127.0.0.1:8080 -> 8080
Forwarding from [::1]:8080 -> 8080

# terminal 2
$ argocd login https://localhost:8080
FATA[0000] dial tcp: address https://localhost:8080: too many colons in address

I tried also the flag --port-forward-namespace argocd but without success.

Expected behavior

argocd login working as expected with ArgoCD exposed over internet or reachable through "kubectl port-forward".

Screenshots

No relevant screenshots.

Version

argocd: v2.4.14+029be59.dirty
  BuildDate: 2022-10-05T19:03:58Z
  GitCommit: 029be590bfd5003d65ddabb4d4cb8a31bff29c18
  GitTreeState: dirty
  GoVersion: go1.19.2
  Compiler: gc
  Platform: darwin/arm64
FATA[0000] Argo CD server address unspecified

Logs

No relevant logs.

crenshaw-dev commented 2 years ago

@bygui86 try dropping the https://.

Even if that fixes it, I think this error deserves an issue. It's not at all clear what the user should do.

bygui86 commented 2 years ago

@crenshaw-dev it worked with the external link, thanks a lot!! Sorry but in the doc it's mentioned the port-forward and the example says to use https://localhost:8080. Anyway the error message is not clear at all :(

crenshaw-dev commented 2 years ago

@bygui86 you bet!

Can you point to the place in docs where we're adding the https://? Just did a quick search and didn't see it.

bygui86 commented 2 years ago

@crenshaw-dev of course.

In the section Port forwarding of the Getting started guide, it's mentioned

The API server can then be accessed using https://localhost:8080

In the section Login Using The CLI right below, it's mentioned the command to login with argocd CLI

argocd login

But there is no further info (or example) about possible values of ARGOCD_SERVER.

And the note right next to it says

The CLI environment must be able to communicate with the Argo CD API server. If it isn't directly accessible as described above in step 3, you can tell the CLI to access it using port forwarding through one of these mechanisms: 1) add --port-forward-namespace argocd flag to every CLI command; or 2) set ARGOCD_OPTS environment variable: export ARGOCD_OPTS='--port-forward-namespace argocd'.

To be honest those sections are quite confused, not giving enough and proper info.

xtreme-sameer-vohra commented 1 year ago

Ran into the same issue as well. This doesn't resolve the problem but a workaround folks can use until this is addressed in the docs is argocd login --insecure localhost:8080

crenshaw-dev commented 1 year ago

I'd be happy to review a docs PR.

I'd also love to see a PR modifying the CLI to detect if a schema is specified and then throw a more friendly error.

markzporter commented 1 year ago

Maybe this is a separate bug but the CLI also doesn't seem to be able to parse an address that uses both a port and a route.

$ argocd login --insecure localhost:6080/argocd
FATA[0000] dial tcp: address tcp/6080/argocd: unknown port

As such, the following workaround doesn't work for me:

Ran into the same issue as well. This doesn't resolve the problem but a workaround folks can use until this is addressed in the docs is argocd login --insecure localhost:8080

My workaround was to use the portforwarding arguments:

argocd login --username user --password $ARGOCD_PW --port-forward --plaintext --port-forward-namespace argocd