Skip to content

feat: Add create-namespace flag to vcluster platform add cluster command #2672

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

Merged
merged 4 commits into from
Apr 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions cmd/vclusterctl/cmd/platform/add/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type ClusterCmd struct {
Log log.Logger
*flags.GlobalFlags
Namespace string
CreateNamespace bool
ServiceAccount string
DisplayName string
Context string
Expand Down Expand Up @@ -82,6 +83,7 @@ vcluster platform add cluster my-cluster
}

c.Flags().StringVar(&cmd.Namespace, "namespace", clihelper.DefaultPlatformNamespace, "The namespace to generate the service account in. The namespace will be created if it does not exist")
c.Flags().BoolVar(&cmd.CreateNamespace, "create-namespace", true, "If true the namespace will be created if it does not exist")
c.Flags().StringVar(&cmd.ServiceAccount, "service-account", "loft-admin", "The service account name to create")
c.Flags().StringVar(&cmd.DisplayName, "display-name", "", "The display name to show in the UI for this cluster")
c.Flags().BoolVar(&cmd.Wait, "wait", false, "If true, will wait until the cluster is initialized")
Expand Down Expand Up @@ -170,12 +172,14 @@ func (cmd *ClusterCmd) Run(ctx context.Context, args []string) error {
if os.Getenv("DEVELOPMENT") == "true" {
helmArgs = []string{
"upgrade", "--install", "loft", cmp.Or(os.Getenv("DEVELOPMENT_CHART_DIR"), "./chart"),
"--create-namespace",
"--namespace", namespace,
"--set", "agentOnly=true",
"--set", "image=" + cmp.Or(os.Getenv("DEVELOPMENT_IMAGE"), "ghcr.io/loft-sh/enterprise:release-test"),
"--set", "env.AGENT_IMAGE=" + cmp.Or(os.Getenv("AGENT_IMAGE"), os.Getenv("DEVELOPMENT_IMAGE"), "ghcr.io/loft-sh/enterprise:release-test"),
}
if cmd.CreateNamespace {
helmArgs = append(helmArgs, "--create-namespace")
}
} else {
if cmd.HelmChartPath != "" {
helmArgs = append(helmArgs, cmd.HelmChartPath)
Expand All @@ -191,8 +195,12 @@ func (cmd *ClusterCmd) Run(ctx context.Context, args []string) error {
helmArgs = append(helmArgs, "--version", cmd.HelmChartVersion)
}

if cmd.CreateNamespace {
helmArgs = append(helmArgs, "--create-namespace")
}

// general arguments
helmArgs = append(helmArgs, "--install", "--create-namespace", "--namespace", cmd.Namespace, "--set", "agentOnly=true")
helmArgs = append(helmArgs, "--install", "--namespace", cmd.Namespace, "--set", "agentOnly=true")
}

for _, set := range cmd.HelmSet {
Expand Down
Loading