karmadactl

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2022 License: Apache-2.0 Imports: 77 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MODIFIED  = "modified"
	TAINTED   = "tainted"
	UNTAINTED = "untainted"
)

Exported taint constant strings to mark the type of the current operation

Variables

View Source
var (

	// ErrEmptyConfig is the error message to be displayed if the configuration info is missing or incomplete
	ErrEmptyConfig = clientcmd.NewEmptyConfigError(
		`Missing or incomplete configuration info.  Please point to an existing, complete config file:
  1. Via the command-line flag --kubeconfig
  2. Via the KUBECONFIG environment variable
  3. In your home directory as ~/.kube/config

To view or setup config directly use the 'config' command.`)
)
View Source
var RBInfo map[string]*OtherPrint

RBInfo resourcebinding info and print info

Functions

func Exists added in v0.10.0

func Exists(path string) bool

Exists determine if path exists

func JoinCluster added in v0.8.0

func JoinCluster(controlPlaneRestConfig, clusterConfig *rest.Config, opts CommandJoinOption) (err error)

JoinCluster join the cluster into karmada.

func NewCmdCordon added in v0.8.0

func NewCmdCordon(karmadaConfig KarmadaConfig, parentCommand string) *cobra.Command

NewCmdCordon defines the `cordon` command that mark cluster as unschedulable.

func NewCmdDeInit added in v1.2.0

func NewCmdDeInit(parentCommand string) *cobra.Command

NewCmdDeInit removes Karmada from Kubernetes

func NewCmdDescribe added in v1.2.0

func NewCmdDescribe(karmadaConfig KarmadaConfig, parentCommand string) *cobra.Command

NewCmdDescribe new describe command.

func NewCmdExec added in v1.2.0

func NewCmdExec(karmadaConfig KarmadaConfig, parentCommand string) *cobra.Command

NewCmdExec new exec command.

func NewCmdGet added in v0.10.0

func NewCmdGet(karmadaConfig KarmadaConfig, parentCommand string) *cobra.Command

NewCmdGet New get command

func NewCmdJoin

func NewCmdJoin(karmadaConfig KarmadaConfig, parentCommand string) *cobra.Command

NewCmdJoin defines the `join` command that registers a cluster.

func NewCmdLogs added in v1.2.0

func NewCmdLogs(karmadaConfig KarmadaConfig, parentCommand string) *cobra.Command

NewCmdLogs new logs command.

func NewCmdPromote added in v1.0.0

func NewCmdPromote(karmadaConfig KarmadaConfig, parentCommand string) *cobra.Command

NewCmdPromote defines the `promote` command that promote resources from legacy clusters

func NewCmdTaint added in v1.0.0

func NewCmdTaint(karmadaConfig KarmadaConfig, parentCommand string) *cobra.Command

NewCmdTaint defines the `taint` command that mark cluster with taints

func NewCmdUncordon added in v0.8.0

func NewCmdUncordon(karmadaConfig KarmadaConfig, parentCommand string) *cobra.Command

NewCmdUncordon defines the `uncordon` command that mark cluster as schedulable.

func NewCmdUnjoin

func NewCmdUnjoin(karmadaConfig KarmadaConfig, parentCommand string) *cobra.Command

NewCmdUnjoin defines the `unjoin` command that removes registration of a cluster from control plane.

func NewKarmadaCtlCommand

func NewKarmadaCtlCommand(cmdUse, parentCommand string) *cobra.Command

NewKarmadaCtlCommand creates the `karmadactl` command.

func RunCordonOrUncordon added in v0.8.0

func RunCordonOrUncordon(desired int, karmadaConfig KarmadaConfig, opts CommandCordonOption) error

RunCordonOrUncordon exec marks the cluster unschedulable or schedulable according to desired. if true cordon cluster otherwise uncordon cluster.

func RunJoin

func RunJoin(karmadaConfig KarmadaConfig, opts CommandJoinOption) error

RunJoin is the implementation of the 'join' command.

func RunPromote added in v1.0.0

func RunPromote(karmadaConfig KarmadaConfig, opts CommandPromoteOption, args []string) error

RunPromote promote resources from legacy clusters

func RunTaint added in v1.0.0

func RunTaint(karmadaConfig KarmadaConfig, opts CommandTaintOption) error

RunTaint set taints for the clusters

func RunUnjoin

func RunUnjoin(karmadaConfig KarmadaConfig, opts CommandUnjoinOption) error

RunUnjoin is the implementation of the 'unjoin' command.

func UnJoinCluster added in v0.8.0

func UnJoinCluster(controlPlaneRestConfig, clusterConfig *rest.Config, opts CommandUnjoinOption) (err error)

UnJoinCluster unJoin the cluster from karmada.

Types

type ClusterInfo added in v0.10.0

type ClusterInfo struct {
	KubeConfig string
	Context    string

	APIEndpoint     string
	ClusterSyncMode clusterv1alpha1.ClusterSyncMode
}

ClusterInfo Information about the member in the karmada cluster.

type CommandCordonOption added in v0.8.0

type CommandCordonOption struct {
	// global flags
	options.GlobalCommandOptions

	// ClusterName is the cluster's name that we are going to join with.
	ClusterName string
}

CommandCordonOption holds all command options for cordon and uncordon

func (*CommandCordonOption) Complete added in v0.8.0

func (o *CommandCordonOption) Complete(args []string) error

Complete ensures that options are valid and marshals them if necessary.

type CommandDeInitOption added in v1.2.0

type CommandDeInitOption struct {
	// KubeConfig holds host cluster KUBECONFIG file path.
	KubeConfig string
	Context    string
	Namespace  string

	// DryRun tells if run the command in dry-run mode, without making any server requests.
	DryRun bool

	KubeClientSet *kubernetes.Clientset
}

CommandDeInitOption options for deinit.

func (*CommandDeInitOption) Complete added in v1.2.0

func (o *CommandDeInitOption) Complete() error

Complete the conditions required to be able to run deinit.

func (*CommandDeInitOption) Run added in v1.2.0

func (o *CommandDeInitOption) Run() error

Run start delete

type CommandDescribeOptions added in v1.2.0

type CommandDescribeOptions struct {
	// global flags
	options.GlobalCommandOptions

	Cluster   string
	CmdParent string
	Selector  string
	Namespace string

	Describer  func(*meta.RESTMapping) (describe.ResourceDescriber, error)
	NewBuilder func() *resource.Builder

	BuilderArgs []string

	EnforceNamespace bool
	AllNamespaces    bool

	DescriberSettings *describe.DescriberSettings
	FilenameOptions   *resource.FilenameOptions

	genericclioptions.IOStreams
}

CommandDescribeOptions contains the input to the describe command.

func (*CommandDescribeOptions) Complete added in v1.2.0

func (o *CommandDescribeOptions) Complete(karmadaConfig KarmadaConfig, cmd *cobra.Command, args []string) error

Complete ensures that options are valid and marshals them if necessary

func (*CommandDescribeOptions) Run added in v1.2.0

func (o *CommandDescribeOptions) Run() error

Run describe information of resources

type CommandGetOptions added in v0.10.0

type CommandGetOptions struct {
	// global flags
	options.GlobalCommandOptions

	// ClusterNamespace holds the namespace name where the member cluster objects are stored.
	ClusterNamespace string

	Clusters []string

	PrintFlags             *get.PrintFlags
	ToPrinter              func(*meta.RESTMapping, *bool, bool, bool) (printers.ResourcePrinterFunc, error)
	IsHumanReadablePrinter bool

	CmdParent string

	resource.FilenameOptions

	Watch     bool
	WatchOnly bool
	ChunkSize int64

	OutputWatchEvents bool

	LabelSelector     string
	FieldSelector     string
	AllNamespaces     bool
	Namespace         string
	ExplicitNamespace bool

	ServerPrint bool

	NoHeaders      bool
	Sort           bool
	IgnoreNotFound bool
	Export         bool

	genericclioptions.IOStreams
}

CommandGetOptions contains the input to the get command.

func NewCommandGetOptions added in v0.10.0

func NewCommandGetOptions(parent string, streams genericclioptions.IOStreams) *CommandGetOptions

NewCommandGetOptions returns a GetOptions with default chunk size 500.

func (*CommandGetOptions) Complete added in v0.10.0

func (g *CommandGetOptions) Complete(cmd *cobra.Command, args []string) error

Complete takes the command arguments and infers any remaining options.

func (*CommandGetOptions) Run added in v0.10.0

func (g *CommandGetOptions) Run(karmadaConfig KarmadaConfig, cmd *cobra.Command, args []string) error

Run performs the get operation.

func (*CommandGetOptions) Validate added in v1.2.0

func (g *CommandGetOptions) Validate(cmd *cobra.Command) error

Validate checks the set of flags provided by the user.

type CommandJoinOption

type CommandJoinOption struct {
	options.GlobalCommandOptions

	// ClusterNamespace holds the namespace name where the member cluster objects are stored.
	ClusterNamespace string

	// ClusterName is the cluster's name that we are going to join with.
	ClusterName string

	// ClusterContext is the cluster's context that we are going to join with.
	ClusterContext string

	// ClusterKubeConfig is the cluster's kubeconfig path.
	ClusterKubeConfig string

	// ClusterProvider is the cluster's provider.
	ClusterProvider string
}

CommandJoinOption holds all command options.

func (*CommandJoinOption) AddFlags

func (j *CommandJoinOption) AddFlags(flags *pflag.FlagSet)

AddFlags adds flags to the specified FlagSet.

func (*CommandJoinOption) Complete

func (j *CommandJoinOption) Complete(args []string) error

Complete ensures that options are valid and marshals them if necessary.

func (*CommandJoinOption) Validate added in v0.3.0

func (j *CommandJoinOption) Validate() error

Validate checks option and return a slice of found errs.

type CommandLogsOptions added in v1.2.0

type CommandLogsOptions struct {
	// global flags
	options.GlobalCommandOptions

	Cluster       string
	Namespace     string
	ResourceArg   string
	AllContainers bool
	Options       runtime.Object
	Resources     []string

	ConsumeRequestFn func(rest.ResponseWrapper, io.Writer) error

	// PodLogOptions
	SinceTime                    string
	Since                        time.Duration
	Follow                       bool
	Previous                     bool
	Timestamps                   bool
	IgnoreLogErrors              bool
	LimitBytes                   int64
	Tail                         int64
	Container                    string
	InsecureSkipTLSVerifyBackend bool

	// whether or not a container name was given via --container
	ContainerNameSpecified bool
	Selector               string
	MaxFollowConcurrency   int
	Prefix                 bool

	Object           runtime.Object
	GetPodTimeout    time.Duration
	RESTClientGetter genericclioptions.RESTClientGetter
	LogsForObject    polymorphichelpers.LogsForObjectFunc

	genericclioptions.IOStreams

	TailSpecified bool
	// contains filtered or unexported fields
}

CommandLogsOptions contains the input to the logs command.

func NewCommandLogsOptions added in v1.2.0

func NewCommandLogsOptions(streams genericclioptions.IOStreams, allContainers bool) *CommandLogsOptions

NewCommandLogsOptions returns a LogsOptions.

func (*CommandLogsOptions) AddFlags added in v1.2.0

func (o *CommandLogsOptions) AddFlags(cmd *cobra.Command)

AddFlags adds flags to the specified FlagSet.

func (*CommandLogsOptions) Complete added in v1.2.0

func (o *CommandLogsOptions) Complete(karmadaConfig KarmadaConfig, cmd *cobra.Command, args []string) error

Complete ensures that options are valid and marshals them if necessary

func (*CommandLogsOptions) Run added in v1.2.0

func (o *CommandLogsOptions) Run() error

Run retrieves a pod log

func (*CommandLogsOptions) Validate added in v1.2.0

func (o *CommandLogsOptions) Validate() error

Validate checks to the LogsOptions to see if there is sufficient information run the command

type CommandPromoteOption added in v1.0.0

type CommandPromoteOption struct {
	options.GlobalCommandOptions

	// Cluster is the name of legacy cluster
	Cluster string

	// ClusterNamespace holds the namespace name where the member cluster objects are stored.
	ClusterNamespace string

	// Namespace is the namespace of legacy resource
	Namespace string

	// ClusterContext is the cluster's context that we are going to join with.
	ClusterContext string

	// ClusterKubeConfig is the cluster's kubeconfig path.
	ClusterKubeConfig string

	resource.FilenameOptions

	JSONYamlPrintFlags *genericclioptions.JSONYamlPrintFlags
	OutputFormat       string
	Printer            func(*meta.RESTMapping, *bool, bool, bool) (printers.ResourcePrinterFunc, error)
	TemplateFlags      *genericclioptions.KubeTemplatePrintFlags
	// contains filtered or unexported fields
}

CommandPromoteOption holds all command options for promote

func (*CommandPromoteOption) AddFlags added in v1.0.0

func (o *CommandPromoteOption) AddFlags(flags *pflag.FlagSet)

AddFlags adds flags to the specified FlagSet.

func (*CommandPromoteOption) Complete added in v1.0.0

func (o *CommandPromoteOption) Complete(args []string) error

Complete ensures that options are valid and marshals them if necessary

func (*CommandPromoteOption) Validate added in v1.0.0

func (o *CommandPromoteOption) Validate() error

Validate checks to the PromoteOptions to see if there is sufficient information run the command

type CommandTaintOption added in v1.0.0

type CommandTaintOption struct {
	options.GlobalCommandOptions
	// contains filtered or unexported fields
}

CommandTaintOption holds all command options for taint

func (*CommandTaintOption) AddFlags added in v1.0.0

func (o *CommandTaintOption) AddFlags(flags *pflag.FlagSet)

AddFlags adds flags to the specified FlagSet.

func (*CommandTaintOption) Complete added in v1.0.0

func (o *CommandTaintOption) Complete(args []string) error

Complete ensures that options are valid and marshals them if necessary

func (*CommandTaintOption) Validate added in v1.0.0

func (o *CommandTaintOption) Validate() error

Validate checks to the TaintOptions to see if there is sufficient information run the command

type CommandUnjoinOption

type CommandUnjoinOption struct {
	options.GlobalCommandOptions

	// ClusterNamespace holds the namespace name where the member cluster objects are stored.
	ClusterNamespace string

	// ClusterName is the cluster's name that we are going to join with.
	ClusterName string

	// ClusterContext is the cluster's context that we are going to join with.
	ClusterContext string

	// ClusterKubeConfig is the cluster's kubeconfig path.
	ClusterKubeConfig string

	// Wait tells maximum command execution time
	Wait time.Duration
	// contains filtered or unexported fields
}

CommandUnjoinOption holds all command options.

func (*CommandUnjoinOption) AddFlags

func (j *CommandUnjoinOption) AddFlags(flags *pflag.FlagSet)

AddFlags adds flags to the specified FlagSet.

func (*CommandUnjoinOption) Complete

func (j *CommandUnjoinOption) Complete(args []string) error

Complete ensures that options are valid and marshals them if necessary.

func (*CommandUnjoinOption) Validate added in v0.10.0

func (j *CommandUnjoinOption) Validate() error

Validate ensures that command unjoin options are valid.

type ConfigFlags added in v0.10.0

type ConfigFlags struct {
	CaBundle *string

	CacheDir   *string
	KubeConfig *string

	// config flags
	ClusterName      *string
	AuthInfoName     *string
	Context          *string
	Namespace        *string
	APIServer        *string
	TLSServerName    *string
	Insecure         *bool
	CertFile         *string
	KeyFile          *string
	CAFile           *string
	BearerToken      *string
	Impersonate      *string
	ImpersonateGroup *[]string
	Username         *string
	Password         *string
	Timeout          *string
	// If non-nil, wrap config function can transform the Config
	// before it is returned in ToRESTConfig function.
	WrapConfigFn func(*rest.Config) *rest.Config
	// contains filtered or unexported fields
}

ConfigFlags composes the set of values necessary for obtaining a REST client config

func NewConfigFlags added in v0.10.0

func NewConfigFlags(usePersistentConfig bool) *ConfigFlags

NewConfigFlags returns ConfigFlags with default values set

func (*ConfigFlags) AddFlags added in v0.10.0

func (f *ConfigFlags) AddFlags(flags *pflag.FlagSet)

AddFlags binds client configuration flags to a given flagset

func (*ConfigFlags) ToDiscoveryClient added in v0.10.0

func (f *ConfigFlags) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)

ToDiscoveryClient implements RESTClientGetter. Expects the AddFlags method to have been called. Returns a CachedDiscoveryInterface using a computed RESTConfig.

func (*ConfigFlags) ToRESTConfig added in v0.10.0

func (f *ConfigFlags) ToRESTConfig() (*rest.Config, error)

ToRESTConfig implements RESTClientGetter. Returns a REST client configuration based on a provided path to a .kubeconfig file, loading rules, and config flag overrides. Expects the AddFlags method to have been called. If WrapConfigFn is non-nil this function can transform config before return.

func (*ConfigFlags) ToRESTMapper added in v0.10.0

func (f *ConfigFlags) ToRESTMapper() (meta.RESTMapper, error)

ToRESTMapper returns a mapper.

func (*ConfigFlags) ToRawKubeConfigLoader added in v0.10.0

func (f *ConfigFlags) ToRawKubeConfigLoader() clientcmd.ClientConfig

ToRawKubeConfigLoader binds config flag values to config overrides Returns an interactive clientConfig if the password flag is enabled, or a non-interactive clientConfig otherwise.

func (*ConfigFlags) WithDeprecatedPasswordFlag added in v0.10.0

func (f *ConfigFlags) WithDeprecatedPasswordFlag() *ConfigFlags

WithDeprecatedPasswordFlag enables the username and password config flags

func (*ConfigFlags) WithDiscoveryBurst added in v0.10.0

func (f *ConfigFlags) WithDiscoveryBurst(discoveryBurst int) *ConfigFlags

WithDiscoveryBurst sets the RESTClient burst for discovery.

type CordonHelper added in v0.8.0

type CordonHelper struct {
	// contains filtered or unexported fields
}

CordonHelper wraps functionality to cordon/uncordon cluster

func NewCordonHelper added in v0.8.0

func NewCordonHelper(cluster *clusterv1alpha1.Cluster) *CordonHelper

NewCordonHelper returns a new CordonHelper that help execute the cordon and uncordon commands

func (*CordonHelper) PatchOrReplace added in v0.8.0

func (c *CordonHelper) PatchOrReplace(controlPlaneClient *karmadaclientset.Clientset) error

PatchOrReplace uses given karmada clientset to update the cluster unschedulable scheduler, either by patching or updating the given cluster object; it may return error if the object cannot be encoded as JSON, or if either patch or update calls fail; it will also return error whenever creating a patch has failed

func (*CordonHelper) UpdateIfRequired added in v0.8.0

func (c *CordonHelper) UpdateIfRequired(desired int) bool

UpdateIfRequired returns true if unscheduler taint isn't already set, or false when no change is needed

type DefaultRemoteExecutor added in v1.2.0

type DefaultRemoteExecutor struct{}

DefaultRemoteExecutor is the standard implementation of remote command execution

func (*DefaultRemoteExecutor) Execute added in v1.2.0

func (*DefaultRemoteExecutor) Execute(method string, url *url.URL, config *restclient.Config, stdin io.Reader, stdout, stderr io.Writer, tty bool, terminalSizeQueue remotecommand.TerminalSizeQueue) error

Execute implement RemoteExecutor interface

type ExecOptions added in v1.2.0

type ExecOptions struct {
	// global flags
	options.GlobalCommandOptions

	resource.FilenameOptions

	ResourceName     string
	Command          []string
	EnforceNamespace bool

	Builder         func() *resource.Builder
	ExecutablePodFn polymorphichelpers.AttachablePodForObjectFunc

	Pod           *corev1.Pod
	Executor      RemoteExecutor
	PodClient     coreclient.PodsGetter
	GetPodTimeout time.Duration
	Config        *restclient.Config
	// contains filtered or unexported fields
}

ExecOptions declare the arguments accepted by the Exec command

func (*ExecOptions) Complete added in v1.2.0

func (p *ExecOptions) Complete(karmadaConfig KarmadaConfig, cmd *cobra.Command, argsIn []string, argsLenAtDash int) error

Complete verifies command line arguments and loads data from the command environment

func (*ExecOptions) Run added in v1.2.0

func (p *ExecOptions) Run() error

Run executes a validated remote execution against a pod.

func (*ExecOptions) Validate added in v1.2.0

func (p *ExecOptions) Validate(cmd *cobra.Command) error

Validate checks that the provided exec options are specified.

type KarmadaConfig

type KarmadaConfig interface {
	// GetRestConfig used to get a cluster's rest config.
	GetRestConfig(context, kubeconfigPath string) (*rest.Config, error)

	// GetClientConfig returns a ClientConfig from kubeconfigPath.
	// If kubeconfigPath is empty, will search KUBECONFIG from default path.
	// If context is not empty, the returned ClientConfig's current-context is the input context.
	GetClientConfig(context, kubeconfigPath string) clientcmd.ClientConfig
}

KarmadaConfig provides a rest config based on the filesystem kubeconfig (via pathOptions) and context in order to talk to the control plane and the joining kubernetes cluster.

func NewKarmadaConfig

func NewKarmadaConfig(pathOptions *clientcmd.PathOptions) KarmadaConfig

NewKarmadaConfig creates a karmadaConfig for `karmadactl` commands.

type Obj added in v0.10.0

type Obj struct {
	Cluster string
	Info    *resource.Info
}

Obj cluster info

type OtherPrint added in v0.10.0

type OtherPrint struct {
	Applied interface{}
}

OtherPrint applied is used in the display column

type RESTClientGetter added in v0.10.0

type RESTClientGetter interface {
	// ToRESTConfig returns restconfig
	ToRESTConfig() (*rest.Config, error)
	// ToDiscoveryClient returns discovery client
	ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
	// ToRESTMapper returns a restmapper
	ToRESTMapper() (meta.RESTMapper, error)
	// ToRawKubeConfigLoader return kubeconfig loader as-is
	ToRawKubeConfigLoader() clientcmd.ClientConfig
}

RESTClientGetter is an interface that the ConfigFlags describe to provide an easier way to mock for commands and eliminate the direct coupling to a struct type. Users may wish to duplicate this type in their own packages as per the golang type overlapping.

type RemoteExecutor added in v1.2.0

type RemoteExecutor interface {
	Execute(method string, url *url.URL, config *restclient.Config, stdin io.Reader, stdout, stderr io.Writer, tty bool, terminalSizeQueue remotecommand.TerminalSizeQueue) error
}

RemoteExecutor defines the interface accepted by the Exec command - provided for test stubbing

type WatchObj added in v1.2.0

type WatchObj struct {
	Cluster string
	// contains filtered or unexported fields
}

WatchObj is a obj that is watched

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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