Documentation
¶
Overview ¶
Package k8s contains the cobra cmd implementation for the k8s management
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CleanCmd = &cobra.Command{ Use: "clean [env-name]", Short: "Clean the data of an environment.", Long: `Clean the data of an environment without redeploying. After clean all custom data populated in the environment will be lost. This action is irreversible.`, Args: cobra.ExactArgs(1), ValidArgsFunction: validArgsFunction, Run: func(cmd *cobra.Command, args []string) { name := args[0] if !cleanForce { display.Warn("This will permanently delete all data in environment '%s'. This action cannot be undone.", name) confirmed, err := common.Confirm("Are you sure you want to continue? (y/n):") if err != nil { display.Error("Failed to read confirmation: %v", err) os.Exit(1) } if !confirmed { display.Info("Clean operation cancelled.") return } } kube, err := k8score.Clean(k8score.CleanOpts{ Name: name, }) if err != nil { display.Error("%v", err) os.Exit(1) } display.Urls(kube.GuiUrl, kube.ApiUrl, kube.BackofficeUrl, fmt.Sprintf("epos-opensource k8s clean %s", name)) }, }
View Source
var DeleteCmd = &cobra.Command{ Use: "delete [env-name...]", Short: "Removes K8s environments and all their namespaces.", Long: "Deletes the K8s environments by removing the namespaces and all of their associated resources. This action is irreversible.", Args: cobra.MinimumNArgs(1), ValidArgsFunction: validArgsFunction, Run: func(cmd *cobra.Command, args []string) { name := args[0:] if !deleteForce { envList := strings.Join(name, ", ") display.Warn("This will permanently delete the following environment(s): %s", envList) display.Warn("All namespaces and associated resources will be removed. This action cannot be undone.") confirmed, err := common.Confirm("Are you sure you want to continue? (y/n):") if err != nil { display.Error("Failed to read confirmation: %v", err) os.Exit(1) } if !confirmed { display.Info("Delete operation cancelled.") return } } err := k8score.Delete(k8score.DeleteOpts{ Name: name, }) if err != nil { display.Error("%v", err) os.Exit(1) } }, }
View Source
var DeployCmd = &cobra.Command{ Use: "deploy [env-name]", Short: "Create and deploy a new K8s environment in a dedicated namespace.", Long: `Sets up a new K8s environment in a fresh namespace, applying all required manifests and configuration. Fails if the namespace already exists. NOTE: to execute the deploy it will try to use port-forwarding to the cluster. If that fails it will retry using the external api.`, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { name := args[0] protocol := "http" if secure { protocol = "https" } k, err := k8score.Deploy(k8score.DeployOpts{ EnvFile: envFile, ManifestDir: manifestsDir, Path: path, Name: name, Context: context, Protocol: protocol, CustomHost: host, TLSEnabled: tlsManifest, }) if err != nil { display.Error("%v", err) os.Exit(1) } display.Urls(k.GuiUrl, k.ApiUrl, k.BackofficeUrl, fmt.Sprintf("epos-opensource k8s deploy %s", name)) }, }
View Source
var ExportCmd = &cobra.Command{ Use: "export [path]", Short: "Export default environment files and manifests.", Long: "Copies the default .env file and all embedded K8s manifest files to the specified directory for manual inspection or customization.", Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { path := args[0] err := k8score.Export(k8score.ExportOpts{ Path: path, }) if err != nil { display.Error("%v", err) os.Exit(1) } }, }
View Source
var ListCmd = &cobra.Command{ Use: "list", Short: "List installed K8s environments.", Run: func(cmd *cobra.Command, args []string) { kubeEnvs, err := db.GetAllK8s() if err != nil { return } display.K8sList(kubeEnvs, "Installed K8s environments") }, }
View Source
var PopulateCmd = &cobra.Command{ Use: "populate [env-name] [ttl-paths...]", Short: "Ingest TTL files or example data into an environment.", Long: `Populate an existing environment with all *.ttl files found in the specified directories (recursively), or ingest the files directly if individual file paths are provided. Multiple directories and/or files can be provided and will be processed in order. NOTE: To execute the population it will try to use port-forwarding to the cluster. If that fails it will retry using the external API.`, ValidArgsFunction: validArgsFunction, Args: func(cmd *cobra.Command, args []string) error { if populateExamples { if len(args) < 1 { display.Error("requires environment name when using --example") return fmt.Errorf("requires environment name when using --example") } return nil } if len(args) < 2 { display.Error("requires environment name and at least one TTL path (or use --example flag)") return fmt.Errorf("requires environment name and at least one TTL path (or use --example flag)") } return nil }, Run: func(cmd *cobra.Command, args []string) { name := args[0] ttlPaths := args[1:] k, err := k8score.Populate(k8score.PopulateOpts{ TTLDirs: ttlPaths, Name: name, Parallel: parallel, PopulateExamples: populateExamples, }) if err != nil { display.Error("%v", err) os.Exit(1) } display.Urls(k.GuiUrl, k.ApiUrl, k.BackofficeUrl, fmt.Sprintf("epos-opensource k8s populate %s", name)) }, }
View Source
var UpdateCmd = &cobra.Command{ Use: "update [env-name]", Short: "Update and redeploy an existing K8s environment.", Long: "Recreates the specified environment with updated configuration or manifests. Optionally deletes and recreates the namespace if --force is used. Ensures rollback if the update fails.", Args: cobra.ExactArgs(1), ValidArgsFunction: validArgsFunction, Run: func(cmd *cobra.Command, args []string) { name := args[0] k, err := k8score.Update(k8score.UpdateOpts{ EnvFile: envFile, ManifestDir: manifestsDir, Name: name, Force: force, CustomHost: host, Reset: reset, }) if err != nil { display.Error("%v", err) os.Exit(1) } display.Urls(k.GuiUrl, k.ApiUrl, k.BackofficeUrl, fmt.Sprintf("epos-opensource k8s update %s", name)) }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.