@@ -41,15 +41,16 @@ import (
41
41
42
42
type (
43
43
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
53
54
}
54
55
55
56
ClusterRemoveOptions struct {
@@ -137,6 +138,7 @@ func newClusterAddCommand() *cobra.Command {
137
138
}
138
139
139
140
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\" )" )
140
142
cmd .Flags ().StringToStringVar (& opts .annotations , "annotations" , nil , "Set metadata annotations (e.g. --annotation key=value)" )
141
143
cmd .Flags ().StringToStringVar (& opts .labels , "labels" , nil , "Set metadata labels (e.g. --label key=value)" )
142
144
cmd .Flags ().BoolVar (& opts .dryRun , "dry-run" , false , "" )
@@ -197,7 +199,7 @@ func runClusterAdd(ctx context.Context, opts *ClusterAddOptions) error {
197
199
198
200
jobName := strings .TrimSuffix (store .Get ().AddClusterJobName , "-" ) + nameSuffix
199
201
200
- err = kubeutil .WaitForJob (ctx , opts .kubeFactory , "kube-system" , jobName )
202
+ err = kubeutil .WaitForJob (ctx , opts .kubeFactory , opts . systemNamespace , jobName )
201
203
if err != nil {
202
204
return err
203
205
}
@@ -305,6 +307,13 @@ func createAddClusterManifests(opts *ClusterAddOptions, ingressUrl, server, csdp
305
307
}
306
308
307
309
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
+ }},
308
317
ConfigMapGenerator : []kusttypes.ConfigMapArgs {
309
318
{
310
319
GeneratorArgs : kusttypes.GeneratorArgs {
0 commit comments