Documentation ¶
Index ¶
- Constants
- Variables
- func Exists(path string) bool
- func JoinCluster(controlPlaneRestConfig, clusterConfig *rest.Config, opts CommandJoinOption) (err error)
- func NewCmdCordon(cmdOut io.Writer, karmadaConfig KarmadaConfig, cmdStr string) *cobra.Command
- func NewCmdGet(out io.Writer, karmadaConfig KarmadaConfig, parentCommand string) *cobra.Command
- func NewCmdJoin(cmdOut io.Writer, karmadaConfig KarmadaConfig, cmdStr string) *cobra.Command
- func NewCmdPromote(cmdOut io.Writer, karmadaConfig KarmadaConfig, parentCommand string) *cobra.Command
- func NewCmdTaint(cmdOut io.Writer, karmadaConfig KarmadaConfig, parentCommand string) *cobra.Command
- func NewCmdUncordon(cmdOut io.Writer, karmadaConfig KarmadaConfig, cmdStr string) *cobra.Command
- func NewCmdUnjoin(cmdOut io.Writer, karmadaConfig KarmadaConfig, cmdStr string) *cobra.Command
- func NewKarmadaCtlCommand(out io.Writer, cmdUse, parentCommand string) *cobra.Command
- func RunCordonOrUncordon(_ io.Writer, desired int, karmadaConfig KarmadaConfig, ...) error
- func RunJoin(cmdOut io.Writer, karmadaConfig KarmadaConfig, opts CommandJoinOption) error
- func RunPromote(_ io.Writer, karmadaConfig KarmadaConfig, opts CommandPromoteOption, ...) error
- func RunTaint(_ io.Writer, karmadaConfig KarmadaConfig, opts CommandTaintOption) error
- func RunUnjoin(cmdOut io.Writer, karmadaConfig KarmadaConfig, opts CommandUnjoinOption) error
- func UnJoinCluster(controlPlaneRestConfig, clusterConfig *rest.Config, opts CommandUnjoinOption) (err error)
- type ClusterInfo
- type CommandCordonOption
- type CommandGetOptions
- type CommandJoinOption
- type CommandPromoteOption
- type CommandTaintOption
- type CommandUnjoinOption
- type ConfigFlags
- func (f *ConfigFlags) AddFlags(flags *pflag.FlagSet)
- func (f *ConfigFlags) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
- func (f *ConfigFlags) ToRESTConfig() (*rest.Config, error)
- func (f *ConfigFlags) ToRESTMapper() (meta.RESTMapper, error)
- func (f *ConfigFlags) ToRawKubeConfigLoader() clientcmd.ClientConfig
- func (f *ConfigFlags) WithDeprecatedPasswordFlag() *ConfigFlags
- func (f *ConfigFlags) WithDiscoveryBurst(discoveryBurst int) *ConfigFlags
- type CordonHelper
- type KarmadaConfig
- type Obj
- type OtherPrint
- type RESTClientGetter
Constants ¶
const ( MODIFIED = "modified" TAINTED = "tainted" UNTAINTED = "untainted" )
Exported taint constant strings to mark the type of the current operation
Variables ¶
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.`) )
var RBInfo map[string]*OtherPrint
RBInfo resourcebinding info and print info
Functions ¶
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
NewCmdCordon defines the `cordon` command that mark cluster as unschedulable.
func NewCmdJoin ¶
NewCmdJoin defines the `join` command that registers a cluster.
func NewCmdPromote ¶ added in v1.0.0
func NewCmdPromote(cmdOut io.Writer, 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(cmdOut io.Writer, karmadaConfig KarmadaConfig, parentCommand string) *cobra.Command
NewCmdTaint defines the `taint` command that mark cluster with taints
func NewCmdUncordon ¶ added in v0.8.0
NewCmdUncordon defines the `uncordon` command that mark cluster as schedulable.
func NewCmdUnjoin ¶
NewCmdUnjoin defines the `unjoin` command that removes registration of a cluster from control plane.
func NewKarmadaCtlCommand ¶
NewKarmadaCtlCommand creates the `karmadactl` command.
func RunCordonOrUncordon ¶ added in v0.8.0
func RunCordonOrUncordon(_ io.Writer, 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(cmdOut io.Writer, karmadaConfig KarmadaConfig, opts CommandJoinOption) error
RunJoin is the implementation of the 'join' command.
func RunPromote ¶ added in v1.0.0
func RunPromote(_ io.Writer, karmadaConfig KarmadaConfig, opts CommandPromoteOption, args []string) error
RunPromote promote resources from legacy clusters
func RunTaint ¶ added in v1.0.0
func RunTaint(_ io.Writer, karmadaConfig KarmadaConfig, opts CommandTaintOption) error
RunTaint set taints for the clusters
func RunUnjoin ¶
func RunUnjoin(cmdOut io.Writer, 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 { APIEndpoint string BearerToken string CAData 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 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 Raw string 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.
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 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 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 Infos runtime.Object Mapping *meta.RESTMapping }
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.