Skip to content

Feat | Connect directly to argo-server and repo-server instead of port-forwarding - #461

Open
twiechert wants to merge 2 commits into
dag-andersen:mainfrom
moia-oss:feat/repo-server-address
Open

Feat | Connect directly to argo-server and repo-server instead of port-forwarding#461
twiechert wants to merge 2 commits into
dag-andersen:mainfrom
moia-oss:feat/repo-server-address

Conversation

@twiechert

Copy link
Copy Markdown
Contributor

Adds --repo-server-address for --render-method=repo-server-api: when set, the tool dials the repo server at that host:port (e.g. argocd-repo-server.argocd.svc:8081) via the existing-but-unwired NewClientWithAddress, and skips EnsurePortForward. Empty (default) = unchanged port-forward behavior, so it's backward compatible.

Motivation: running the tool in-cluster and connecting to the repo-server Service directly (kube-proxy load-balanced, survives pod churn) instead of a single-pod port-forward.

@dag-andersen

Copy link
Copy Markdown
Owner

@twiechert

Thanks for the PR. I like the direction here! We should try to avoid port-forwarding when we can, but without making the code too complicated.

I wonder if we can avoid adding a user-facing --repo-server-address flag in most cases by auto-detecting the repo-server Service address from Kubernetes labels instead. The tool already knows the Argo CD namespace, so it should be able to find the Service with labels like:

app.kubernetes.io/part-of=argocd
app.kubernetes.io/component=repo-server

and then construct something like: argocd-repo-server.<namespace>.svc:8081

I vibe coded a quick example implementation of this here, feel free to steal from it: 🚀
main...fix/repo-server-service-autodetect

No pressure to use it exactly as-is, but I think the general approach would make the in-cluster case work automatically while keeping the CLI simpler for users.

What do you think? Let me know if you have any use cases for --repo-server-address that cannot be auto-detected by labels? :)

@twiechert

Copy link
Copy Markdown
Contributor Author

Sounds good to me. Let us stick with the auto-detect option :)

@dag-andersen

Copy link
Copy Markdown
Owner

@twiechert Cool, Do you want to update you PR? or should i create a new one? :)

dag-andersen and others added 2 commits August 3, 2026 12:50
Mirrors the repo server lookup for the API server, so the server-api /
repo-server-api render methods stop port-forwarding in cluster too. Same
label convention (part-of=argocd, component=server), same fallback: outside
the cluster nothing changes.

The scheme has to be probed rather than read off the Service. argocd-server
speaks TLS unless started with --insecure, and the chart maps both the http
and the https Service port to the same container port either way, so the port
name says nothing about the actual protocol. Guessing wrong is expensive:
plain HTTP against a TLS listener blocks until the client timeout rather than
failing fast. One probe against /api/version settles it.
@twiechert
twiechert force-pushed the feat/repo-server-address branch 2 times, most recently from cf60961 to 1357a0b Compare August 3, 2026 10:58
@dag-andersen dag-andersen changed the title feat: --repo-server-address to skip the port-forward (repo-server-api) Feat | Connect directly to argo-server and repo-server instead of port-forwarding Aug 3, 2026

@dag-andersen dag-andersen left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 🚀 Thank you!

Comment thread pkg/argocd/call_api.go
_ = resp.Body.Close()
return url, nil
}
return "", fmt.Errorf("Argo CD server at %s answered neither https nor http: %w", address, lastErr)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "", fmt.Errorf("Argo CD server at %s answered neither https nor http: %w", address, lastErr)
return "", fmt.Errorf("argo CD server at %s answered neither https nor http: %w", address, lastErr)

@twiechert

@dag-andersen dag-andersen left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @twiechert! With the introduction of Argo CD 3.5, connecting directly to the server may break the tool for some users because the Argo CD Helm chart now includes NetworkPolicies that block the traffic. We need to handle this. I am thinking we should either default back to port forwarding or provide a clear warning to users so they can fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants