command

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CephCmd = &cobra.Command{
	Use:                "ceph",
	Short:              "call a 'ceph' CLI command with arbitrary args",
	DisableFlagParsing: true,
	Args:               cobra.MinimumNArgs(1),
	PreRun: func(cmd *cobra.Command, args []string) {
		verifyOperatorPodIsRunning(cmd.Context(), clientSets)
	},
	Run: func(cmd *cobra.Command, args []string) {
		logging.Info("running 'ceph' command with args: %v", args)
		if args[0] == "daemon" {
			if len(args) < 2 {
				logging.Fatal(fmt.Errorf("too few arguments to run the 'ceph daemon' command"))
			}
			cephDaemonNameAndID := splitCephDaemonNameAndID(args[1])
			_, err := exec.RunCommandInLabeledPod(cmd.Context(), clientSets, fmt.Sprintf("%s=%s", cephDaemonNameAndID[0], cephDaemonNameAndID[1]), cephDaemonNameAndID[0], cmd.Use, args, cephClusterNamespace, false)
			if err != nil {
				logging.Fatal(err)
			}

		} else {
			_, err := exec.RunCommandInOperatorPod(cmd.Context(), clientSets, cmd.Use, args, operatorNamespace, cephClusterNamespace, false)
			if err != nil {
				logging.Fatal(err)
			}
		}
	},
}

CephCmd represents the ceph command

View Source
var DestroyClusterCmd = &cobra.Command{
	Use:   "destroy-cluster",
	Short: "delete ALL data in the Rook cluster and all Rook CRs",

	Run: func(cmd *cobra.Command, args []string) {
		ctx := cmd.Context()
		var answer string
		logging.Warning(destroyClusterQuestion, cephClusterNamespace)
		fmt.Scanf("%s", &answer)
		err := mons.PromptToContinueOrCancel(destroyClusterAnswer, answer)
		if err != nil {
			logging.Fatal(fmt.Errorf("the response %q to confirm the cluster deletion", destroyClusterAnswer))
		}

		logging.Info("proceeding")
		clientsets := getClientsets(ctx)
		crds.DeleteCustomResources(ctx, clientsets, clientsets.Kube, cephClusterNamespace)
	},
}

DestroyClusterCmd represents the command for destroy cluster

View Source
var DrCmd = &cobra.Command{
	Use:                "dr",
	Short:              "Calls subcommand health",
	DisableFlagParsing: true,
	Args:               cobra.ExactArgs(1),
	PreRun: func(cmd *cobra.Command, args []string) {
		verifyOperatorPodIsRunning(cmd.Context(), clientSets)
	},
}
View Source
var FlattenRBDPVCCmd = &cobra.Command{
	Use:   "flatten-rbd-pvc",
	Short: "Flatten the RBD image corresponding to the target RBD PVC",
	Long: `Flatten the RBD image corresponding to the target RBD PVC.
The target RBD PVC must be a cloned image and must be created by ceph-csi.
This command removes the corresponding temporary cloned image[1]
if the target PVC was cloned from another PVC.

[1]: https://github.com/ceph/ceph-csi/blob/devel/docs/design/proposals/rbd-snap-clone.md`,
	Args: cobra.ExactArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		flatten_rbd_pvc.FlattenRBDPVC(cmd.Context(), clientSets, operatorNamespace, cephClusterNamespace, namespace, args[0], allowInUse)
	},
}

FlattenRBDPVCCmd represents the rook commands

View Source
var Health = &cobra.Command{
	Use:                "health",
	Short:              "check health of the cluster and common configuration issues",
	DisableFlagParsing: true,
	Args:               cobra.NoArgs,
	PreRun: func(cmd *cobra.Command, args []string) {
		verifyOperatorPodIsRunning(cmd.Context(), clientSets)
	},
	Run: func(cmd *cobra.Command, _ []string) {
		health.Health(cmd.Context(), clientSets, operatorNamespace, cephClusterNamespace)
	},
}
View Source
var MaintenanceCmd = &cobra.Command{
	Use:                "maintenance",
	Short:              "Perform maintenance operation on mons and OSDs deployment by scaling it down and creating a maintenance deployment.",
	DisableFlagParsing: true,
	Args:               cobra.ExactArgs(1),
	PreRun: func(cmd *cobra.Command, args []string) {
		verifyOperatorPodIsRunning(cmd.Context(), clientSets)
	},
}

MaintenanceCmd represents the operator commands

View Source
var MonCmd = &cobra.Command{
	Use:                "mons",
	Short:              "Output mon endpoints",
	DisableFlagParsing: true,
	Args:               cobra.MaximumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			fmt.Println(mons.GetMonEndpoint(cmd.Context(), clientSets.Kube, cephClusterNamespace))
		}
	},
}

MonCmd represents the mons command

View Source
var OperatorCmd = &cobra.Command{
	Use:                "operator",
	Short:              "Calls subcommands like `restart`  and `set <key> <value>` to update  rook-ceph-operator-config configmap",
	DisableFlagParsing: true,
	Args:               cobra.ExactArgs(1),
}

OperatorCmd represents the operator commands

View Source
var RadosCmd = &cobra.Command{
	Use:                "rados",
	Short:              "call a 'rados' CLI command with arbitrary args",
	DisableFlagParsing: true,
	Args:               cobra.MinimumNArgs(1),
	PreRun: func(cmd *cobra.Command, args []string) {
		verifyOperatorPodIsRunning(cmd.Context(), clientSets)
	},
	Run: func(cmd *cobra.Command, args []string) {
		logging.Info("running 'rados' command with args: %v", args)
		_, err := exec.RunCommandInOperatorPod(cmd.Context(), clientSets, cmd.Use, args, operatorNamespace, cephClusterNamespace, false)
		if err != nil {
			logging.Fatal(err)
		}
	},
}

RadosCmd represents the rados command

View Source
var RadosgwCmd = &cobra.Command{
	Use:                "radosgw-admin",
	Short:              "call a 'radosgw-admin' CLI command",
	DisableFlagParsing: true,
	Args:               cobra.MinimumNArgs(1),
	PreRun: func(cmd *cobra.Command, args []string) {
		verifyOperatorPodIsRunning(cmd.Context(), clientSets)
	},
	Run: func(cmd *cobra.Command, args []string) {
		logging.Info("running 'radosgw-admin' command with args: %v", args)
		_, err := exec.RunCommandInOperatorPod(cmd.Context(), clientSets, cmd.Use, args, operatorNamespace, cephClusterNamespace, false)
		if err != nil {
			logging.Fatal(err)
		}
	},
}

RadosgwCmd represents the radosgw command

View Source
var RbdCmd = &cobra.Command{
	Use:                "rbd",
	Short:              "call a 'rbd' CLI command with arbitrary args",
	DisableFlagParsing: true,
	Args:               cobra.MinimumNArgs(1),
	PreRun: func(cmd *cobra.Command, args []string) {
		verifyOperatorPodIsRunning(cmd.Context(), clientSets)
	},
	Run: func(cmd *cobra.Command, args []string) {
		_, err := exec.RunCommandInOperatorPod(cmd.Context(), clientSets, cmd.Use, args, operatorNamespace, cephClusterNamespace, false)
		if err != nil {
			logging.Fatal(err)
		}
	},
}

RbdCmd represents the rbd command

View Source
var RestoreCmd = &cobra.Command{
	Use:     "restore-deleted",
	Short:   "Restores a CR that was accidentally deleted and is still in terminating state.",
	Args:    cobra.RangeArgs(1, 2),
	Example: "kubectl rook-ceph restore-deleted <CRD> [CR_Name]",
	PreRun: func(cmd *cobra.Command, args []string) {
		verifyOperatorPodIsRunning(cmd.Context(), clientSets)
	},
	Run: func(cmd *cobra.Command, args []string) {
		restore.RestoreCrd(cmd.Context(), clientSets, operatorNamespace, cephClusterNamespace, args)
	},
}

RestoreCmd represents the restore commands

View Source
var RestoreQuorum = &cobra.Command{
	Use:                "restore-quorum",
	Short:              "When quorum is lost, restore quorum to the remaining healthy mon",
	DisableFlagParsing: true,
	Args:               cobra.ExactArgs(1),
	Example:            "kubectl rook-ceph mons restore-quorum <Mon_ID>",
	Run: func(cmd *cobra.Command, args []string) {
		mons.RestoreQuorum(cmd.Context(), clientSets, operatorNamespace, cephClusterNamespace, args[0])
	},
}

RestoreQuorum represents the mons command

View Source
var RookCmd = &cobra.Command{
	Use:   "rook",
	Short: "Calls subcommands like `version`, `purge-osd, status` and etc.",
	Args:  cobra.ExactArgs(1),
}

RookCmd represents the rook commands

View Source
var RootCmd = &cobra.Command{
	Use:              "rook-ceph",
	Short:            "kubectl rook-ceph provides common management and troubleshooting tools for Ceph.",
	Args:             cobra.MinimumNArgs(1),
	TraverseChildren: true,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		if cephClusterNamespace != "" && operatorNamespace == "" {
			operatorNamespace = cephClusterNamespace
		}
		clientSets = getClientsets(cmd.Context())
		preValidationCheck(cmd.Context(), clientSets)
	},
}

rookCmd represents the rook command

View Source
var SubvolumeCmd = &cobra.Command{
	Use:   "subvolume",
	Short: "manages stale subvolumes",
	PreRun: func(cmd *cobra.Command, args []string) {
		verifyOperatorPodIsRunning(cmd.Context(), clientSets)
	},
	Args: cobra.ExactArgs(1),
}

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL