@@ -41,15 +41,16 @@ import (
4141
4242type (
4343 ClusterAddOptions struct {
44- runtimeName string
45- clusterName string
46- kubeContext string
47- kubeconfig string
48- annotations map [string ]string
49- labels map [string ]string
50- tag string
51- dryRun bool
52- kubeFactory kube.Factory
44+ runtimeName string
45+ clusterName string
46+ kubeContext string
47+ kubeconfig string
48+ systemNamespace string
49+ annotations map [string ]string
50+ labels map [string ]string
51+ tag string
52+ dryRun bool
53+ kubeFactory kube.Factory
5354 }
5455
5556 ClusterRemoveOptions struct {
@@ -137,6 +138,7 @@ func newClusterAddCommand() *cobra.Command {
137138 }
138139
139140 cmd .Flags ().StringVar (& opts .clusterName , "name" , "" , "Name of the cluster. If omitted, will use the context name" )
141+ cmd .Flags ().StringVar (& opts .systemNamespace , "system-namespace" , "kube-system" , "Use different system namespace (default \" kube-system\" )" )
140142 cmd .Flags ().StringToStringVar (& opts .annotations , "annotations" , nil , "Set metadata annotations (e.g. --annotation key=value)" )
141143 cmd .Flags ().StringToStringVar (& opts .labels , "labels" , nil , "Set metadata labels (e.g. --label key=value)" )
142144 cmd .Flags ().BoolVar (& opts .dryRun , "dry-run" , false , "" )
@@ -197,7 +199,7 @@ func runClusterAdd(ctx context.Context, opts *ClusterAddOptions) error {
197199
198200 jobName := strings .TrimSuffix (store .Get ().AddClusterJobName , "-" ) + nameSuffix
199201
200- err = kubeutil .WaitForJob (ctx , opts .kubeFactory , "kube-system" , jobName )
202+ err = kubeutil .WaitForJob (ctx , opts .kubeFactory , opts . systemNamespace , jobName )
201203 if err != nil {
202204 return err
203205 }
@@ -305,6 +307,13 @@ func createAddClusterManifests(opts *ClusterAddOptions, ingressUrl, server, csdp
305307 }
306308
307309 k := & kusttypes.Kustomization {
310+ Namespace : opts .systemNamespace ,
311+ Patches : []kusttypes.Patch {{
312+ Patch : fmt .Sprintf ("[{\" op\" : \" replace\" , \" path\" : \" /subjects/0/namespace\" , \" value\" : \" %s\" }]" , opts .systemNamespace ),
313+ Target : & kusttypes.Selector {
314+ ResId : resid.ResId {Gvk : clusterRoleBindinGVK , Name : "argocd-manager-role-binding" },
315+ },
316+ }},
308317 ConfigMapGenerator : []kusttypes.ConfigMapArgs {
309318 {
310319 GeneratorArgs : kusttypes.GeneratorArgs {
0 commit comments