-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Enhance ArgoCD CLI: Dynamic Repo Server Retrieval with --core and --refresh Flags #17613
Changes from 15 commits
87bc574
4987796
29b0e7a
3b060b4
5319368
f67255d
69713b1
ec4b22a
dde9a3e
eb41e7c
22e28e2
2610292
6049c22
4c30993
58a7e28
4b1ccee
fdba5b1
d051cab
39e5371
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ import ( | |
"github.com/redis/go-redis/v9" | ||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/pflag" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/util/runtime" | ||
"k8s.io/client-go/kubernetes" | ||
cache2 "k8s.io/client-go/tools/cache" | ||
|
@@ -115,14 +116,27 @@ type forwardRepoClientset struct { | |
repoClientset repoapiclient.Clientset | ||
err error | ||
repoServerName string | ||
kubeClientset kubernetes.Interface | ||
} | ||
|
||
func (c *forwardRepoClientset) NewRepoServerClient() (io.Closer, repoapiclient.RepoServerServiceClient, error) { | ||
c.init.Do(func() { | ||
overrides := clientcmd.ConfigOverrides{ | ||
CurrentContext: c.context, | ||
} | ||
repoServerPodLabelSelector := common.LabelKeyAppName + "=" + c.repoServerName | ||
repoServerName := c.repoServerName | ||
repoServererviceLabelSelector := common.LabelKeyComponentRepoServer + "=" + common.LabelValueComponentRepoServer | ||
repoServerServices, err := c.kubeClientset.CoreV1().Services(c.namespace).List(context.Background(), v1.ListOptions{LabelSelector: repoServererviceLabelSelector}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of deriving the argocd instance name from the services, can we not apply the label There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @anandf, I will update the implementation and add the labels "app.kubernetes.io/component=repo-server" to repo-server replica pods in the manifest There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switching to |
||
if err != nil { | ||
c.err = err | ||
return | ||
} | ||
if len(repoServerServices.Items) > 0 { | ||
if repoServerServicelabel, ok := repoServerServices.Items[0].Labels[common.LabelKeyAppName]; ok && repoServerServicelabel != "" { | ||
repoServerName = repoServerServicelabel | ||
} | ||
} | ||
repoServerPodLabelSelector := common.LabelKeyAppName + "=" + repoServerName | ||
repoServerPort, err := kubeutil.PortForward(8081, c.namespace, &overrides, repoServerPodLabelSelector) | ||
if err != nil { | ||
c.err = err | ||
|
@@ -237,7 +251,7 @@ func MaybeStartLocalServer(ctx context.Context, clientOpts *apiclient.ClientOpti | |
KubeClientset: kubeClientset, | ||
Insecure: true, | ||
ListenHost: *address, | ||
RepoClientset: &forwardRepoClientset{namespace: namespace, context: ctxStr, repoServerName: clientOpts.RepoServerName}, | ||
RepoClientset: &forwardRepoClientset{namespace: namespace, context: ctxStr, repoServerName: clientOpts.RepoServerName, kubeClientset: kubeClientset}, | ||
EnableProxyExtension: false, | ||
}) | ||
srv.Init(ctx) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
repoServerServiceLabelSelector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @ishitasequeira, Updating the same.