Skip to content

Commit 33a6670

Browse files
allow overriding the system namespace for add-cluster (#667)
* allow overriding the system namespace for add-cluster * codegen
1 parent d333159 commit 33a6670

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.1.27
1+
VERSION=v0.1.28
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

cmd/commands/cluster.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ import (
4141

4242
type (
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{

docs/commands/cli-v2_cluster_add.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ cli-v2 cluster add my-runtime --context my-context
2323
--labels stringToString Set metadata labels (e.g. --label key=value) (default [])
2424
--name string Name of the cluster. If omitted, will use the context name
2525
-n, --namespace string If present, the namespace scope for this CLI request
26+
--system-namespace string Use different system namespace (default "kube-system") (default "kube-system")
2627
```
2728

2829
### Options inherited from parent commands

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cf version
2323

2424
```bash
2525
# download and extract the binary
26-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.26/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.28/cf-linux-amd64.tar.gz | tar zx
2727

2828
# move the binary to your $PATH
2929
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -36,7 +36,7 @@ cf version
3636

3737
```bash
3838
# download and extract the binary
39-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.26/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.1.28/cf-darwin-amd64.tar.gz | tar zx
4040

4141
# move the binary to your $PATH
4242
mv ./cf-darwin-amd64 /usr/local/bin/cf

0 commit comments

Comments
 (0)