Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - Variables
 - func AddComponentRow(tbl *printer.TablePrinter, objs *ClusterObjects, opt *PrinterOptions) [][]interface{}
 - func AddEventRow(tbl *printer.TablePrinter, objs *ClusterObjects, opt *PrinterOptions) [][]interface{}
 - func AddInstanceRow(tbl *printer.TablePrinter, objs *ClusterObjects, opt *PrinterOptions) [][]interface{}
 - func AddLabelRow(tbl *printer.TablePrinter, objs *ClusterObjects, opt *PrinterOptions) [][]interface{}
 - func BuildShardingComponentName(shardingCompName, componentName string) string
 - func BuildStorageClass(storages []StorageInfo) string
 - func BuildStorageSize(storages []StorageInfo) string
 - func ClearCharts(c ClusterType)
 - func CompatibleComponentDefs(compDefs []string, compDef string) bool
 - func ComponentNameLabelKey(cluster *kbappsv1.Cluster, compName string) string
 - func FindClusterComp(cluster *kbappsv1.Cluster, compDefName string) *kbappsv1.ClusterComponentSpec
 - func GenerateClusterName(dynamic dynamic.Interface, namespace string) (string, error)
 - func GenerateName() string
 - func GetChartCacheFiles() []fs.DirEntry
 - func GetClusterByName(dynamic dynamic.Interface, name string, namespace string) (*kbappsv1.Cluster, error)
 - func GetClusterDefByName(dynamic dynamic.Interface, name string) (*kbappsv1.ClusterDefinition, error)
 - func GetCompSpecAndCheckSharding(cluster *kbappsv1.Cluster, componentName string) (*kbappsv1.ClusterComponentSpec, bool)
 - func GetComponentEndpoints(nodes []*corev1.Node, svcList *corev1.ServiceList, compName string) ([]string, []string)
 - func GetComponentServices(svcList *corev1.ServiceList, compName string) ([]*corev1.Service, []*corev1.Service)
 - func GetComponentSpec(cluster *kbappsv1.Cluster, compName string) *kbappsv1.ClusterComponentSpec
 - func GetConfigConstraintByName(dynamic dynamic.Interface, name string) (*appsv1beta1.ConfigConstraint, error)
 - func GetConfigMapByName(dynamic dynamic.Interface, namespace, name string) (*corev1.ConfigMap, error)
 - func GetDefaultCompName(cd *appsv1alpha1.ClusterDefinition) (string, error)
 - func GetDefaultServiceRef(cd *appsv1alpha1.ClusterDefinition) (string, error)
 - func GetEndpointsFromNode(node *corev1.Node) (string, string)
 - func GetExternalAddr(svc *corev1.Service) string
 - func GetManifests(c *chart.Chart, skipSchemaValidation bool, namespace, name, kubeVersion string, ...) (map[string]string, error)
 - func GetPodClusterName(pod *corev1.Pod) string
 - func GetPodComponentName(pod *corev1.Pod) string
 - func GetReadyNodeForNodePort(client *kubernetes.Clientset) (*corev1.Node, error)
 - func GetServiceRefs(cd *appsv1alpha1.ClusterDefinition) []string
 - func IsBuiltinCharts(clusterType ClusterType) bool
 - func IsShardingComponent(cluster *kbappsv1.Cluster, compName string) bool
 - func ListShardingComponents(dynamic dynamic.Interface, clusterName, clusterNamespace, componentName string) ([]*appsv1alpha1.Component, error)
 - func RegisterCMD(c clusterConfig, configPath string)
 - func ValidateClusterVersionByComponentDef(dynamic dynamic.Interface, compDefs []string, cv string) error
 - func ValidateValues(c *ChartInfo, values map[string]interface{}) error
 - type ChartInfo
 - type ClusterInfo
 - type ClusterObjects
 - type ClusterType
 - type CompInfo
 - type ComponentInfo
 - type ComponentPair
 - type GetOptions
 - type InstanceInfo
 - type ObjectsGetter
 - type PrintType
 - type Printer
 - type PrinterOptions
 - type SchemaPropName
 - type StorageInfo
 - type TypeInstance
 - type TypeNeed
 
Constants ¶
const ( NoNeed = iota Need Maybe )
const (
	ComponentNameEmpty = ""
)
    const ConditionsError = "ConditionsError"
    ConditionsError cluster displays this status on list cmd when the status of ApplyResources or ProvisioningStarted condition is "False".
Variables ¶
var CacheFiles []fs.DirEntry
    var CliChartsCacheDir string
    CliChartsCacheDir is $HOME/.kbcli/charts by default
var CliClusterChartConfig string
    CliClusterChartConfig is $HOME/.kbcli/cluster_types by default
var ClusterTypeCharts = map[ClusterType]chartLoader{}
    ClusterTypeCharts is the map of the cluster type and the chart config ClusterType is the type of the cluster, the ClusterType t will be used as sub command name, chartLoader is the interface for the chart config, implement this interface to register cluster type.
var GlobalClusterChartConfig clusterConfig
    GlobalClusterChartConfig is kbcli global cluster chart config reference to CliClusterChartConfig
Functions ¶
func AddComponentRow ¶
func AddComponentRow(tbl *printer.TablePrinter, objs *ClusterObjects, opt *PrinterOptions) [][]interface{}
func AddEventRow ¶
func AddEventRow(tbl *printer.TablePrinter, objs *ClusterObjects, opt *PrinterOptions) [][]interface{}
func AddInstanceRow ¶
func AddInstanceRow(tbl *printer.TablePrinter, objs *ClusterObjects, opt *PrinterOptions) [][]interface{}
func AddLabelRow ¶
func AddLabelRow(tbl *printer.TablePrinter, objs *ClusterObjects, opt *PrinterOptions) [][]interface{}
func BuildShardingComponentName ¶ added in v1.0.0
func BuildStorageClass ¶
func BuildStorageClass(storages []StorageInfo) string
func BuildStorageSize ¶
func BuildStorageSize(storages []StorageInfo) string
func ClearCharts ¶
func ClearCharts(c ClusterType)
func CompatibleComponentDefs ¶ added in v1.0.0
func ComponentNameLabelKey ¶ added in v1.0.0
func FindClusterComp ¶
func FindClusterComp(cluster *kbappsv1.Cluster, compDefName string) *kbappsv1.ClusterComponentSpec
FindClusterComp finds component in cluster object based on the component definition name
func GenerateClusterName ¶ added in v1.0.0
func GenerateName ¶
func GenerateName() string
func GetChartCacheFiles ¶
func GetClusterByName ¶
func GetClusterDefByName ¶
func GetCompSpecAndCheckSharding ¶ added in v1.0.0
func GetComponentEndpoints ¶
func GetComponentEndpoints(nodes []*corev1.Node, svcList *corev1.ServiceList, compName string) ([]string, []string)
GetComponentEndpoints gets component internal and external endpoints
func GetComponentServices ¶
func GetComponentServices(svcList *corev1.ServiceList, compName string) ([]*corev1.Service, []*corev1.Service)
GetComponentServices gets component services
func GetComponentSpec ¶ added in v1.0.0
func GetComponentSpec(cluster *kbappsv1.Cluster, compName string) *kbappsv1.ClusterComponentSpec
func GetConfigConstraintByName ¶
func GetConfigConstraintByName(dynamic dynamic.Interface, name string) (*appsv1beta1.ConfigConstraint, error)
func GetConfigMapByName ¶
func GetDefaultCompName ¶
func GetDefaultCompName(cd *appsv1alpha1.ClusterDefinition) (string, error)
func GetDefaultServiceRef ¶
func GetDefaultServiceRef(cd *appsv1alpha1.ClusterDefinition) (string, error)
GetDefaultServiceRef will return the ServiceRefDeclarations in cluster-definition when the cluster-definition contains only one ServiceRefDeclaration
func GetEndpointsFromNode ¶ added in v1.0.0
func GetExternalAddr ¶
GetExternalAddr gets external IP from service annotation
func GetManifests ¶
func GetManifests(c *chart.Chart, skipSchemaValidation bool, namespace, name, kubeVersion string, values map[string]interface{}) (map[string]string, error)
GetManifests gets the cluster manifests
func GetPodClusterName ¶
func GetPodComponentName ¶
func GetReadyNodeForNodePort ¶ added in v1.0.0
func GetReadyNodeForNodePort(client *kubernetes.Clientset) (*corev1.Node, error)
func GetServiceRefs ¶
func GetServiceRefs(cd *appsv1alpha1.ClusterDefinition) []string
func IsBuiltinCharts ¶ added in v0.7.3
func IsBuiltinCharts(clusterType ClusterType) bool
func IsShardingComponent ¶ added in v1.0.0
func ListShardingComponents ¶ added in v1.0.0
func RegisterCMD ¶
func RegisterCMD(c clusterConfig, configPath string)
RegisterCMD will register all cluster type instances in the config c and auto clear the register failed instances and rewrite config
func ValidateClusterVersionByComponentDef ¶ added in v0.7.3
func ValidateValues ¶
ValidateValues validates the given values against the schema.
Types ¶
type ChartInfo ¶
type ChartInfo struct {
	// Schema is the cluster parent helm chart schema, used to render the command flag
	Schema *spec.Schema
	// SubSchema is the sub chart schema, used to render the command flag
	SubSchema *spec.Schema
	// SubChartName is the name (alias if exists) of the sub chart
	SubChartName string
	// ClusterDef is the cluster definition
	ClusterDef string
	// ComponentDef refer cluster component.spec[x].ComponentDef
	ComponentDef []string
	// Chart is the cluster helm chart object
	Chart *chart.Chart
	// Alias is the alias of the cluster chart, will be used as the command alias
	Alias string
}
    func BuildChartInfo ¶
func BuildChartInfo(t ClusterType) (*ChartInfo, error)
func (*ChartInfo) BuildClusterSchema ¶ added in v0.7.3
BuildClusterSchema build the schema for the given cluster chart.
type ClusterInfo ¶
type ClusterInfo struct {
	Name              string `json:"name,omitempty"`
	Namespace         string `json:"namespace,omitempty"`
	ClusterVersion    string `json:"clusterVersion,omitempty"`
	TerminationPolicy string `json:"terminationPolicy,omitempty"`
	ClusterDefinition string `json:"clusterDefinition,omitempty"`
	Status            string `json:"status,omitempty"`
	InternalEP        string `json:"internalEP,omitempty"`
	ExternalEP        string `json:"externalEP,omitempty"`
	CreatedTime       string `json:"age,omitempty"`
	Labels            string `json:"labels,omitempty"`
}
    type ClusterObjects ¶
type ClusterObjects struct {
	Cluster    *kbappsv1.Cluster
	ClusterDef *kbappsv1.ClusterDefinition
	Pods       *corev1.PodList
	Services   *corev1.ServiceList
	Secrets    *corev1.SecretList
	PVCs       *corev1.PersistentVolumeClaimList
	Nodes      []*corev1.Node
	ConfigMaps *corev1.ConfigMapList
	Events     *corev1.EventList
	BackupPolicies  []dpv1alpha1.BackupPolicy
	BackupSchedules []dpv1alpha1.BackupSchedule
	Backups         []dpv1alpha1.Backup
	// 0.8 API
	CompDefs   []*appsv1alpha1.ComponentDefinition
	Components []*appsv1alpha1.Component
}
    func FakeClusterObjs ¶
func FakeClusterObjs() *ClusterObjects
func NewClusterObjects ¶
func NewClusterObjects() *ClusterObjects
func (*ClusterObjects) GetClusterInfo ¶
func (o *ClusterObjects) GetClusterInfo() *ClusterInfo
func (*ClusterObjects) GetComponentInfo ¶
func (o *ClusterObjects) GetComponentInfo() []*ComponentInfo
func (*ClusterObjects) GetInstanceInfo ¶
func (o *ClusterObjects) GetInstanceInfo() []*InstanceInfo
type ClusterType ¶
type ClusterType string
func SupportedTypes ¶
func SupportedTypes() []ClusterType
func (ClusterType) String ¶
func (t ClusterType) String() string
type CompInfo ¶
type CompInfo struct {
	Component       *kbappsv1.ClusterComponentSpec
	ComponentStatus *kbappsv1.ClusterComponentStatus
	ComponentDef    *appsv1alpha1.ClusterComponentDefinition
}
    type ComponentInfo ¶
type ComponentInfo struct {
	// component name in cluster.spec
	Name                 string `json:"name,omitempty"`
	InstanceTemplateName string `json:"instanceTemplateName,omitempty"`
	NameSpace            string `json:"nameSpace,omitempty"`
	ComponentDef         string `json:"type,omitempty"`
	Cluster              string `json:"cluster,omitempty"`
	Status               string `json:"status,omitempty"`
	Replicas             string `json:"replicas,omitempty"`
	CPU                  string `json:"cpu,omitempty"`
	Memory               string `json:"memory,omitempty"`
	Image                string `json:"image,omitempty"`
	Storage              []StorageInfo
}
    type ComponentPair ¶ added in v1.0.0
type ComponentPair struct {
	// a unique name identifier for component object,
	// and labeled with "apps.kubeblocks.io/component-name"
	ComponentName    string
	ComponentDefName string
	ShardingName     string
}
    func GetClusterComponentPairs ¶ added in v1.0.0
func GetShardingComponentPairs ¶ added in v1.0.0
func GetShardingComponentPairs(dynamicClient dynamic.Interface, cluster *kbappsv1.Cluster, shardingSpec kbappsv1.ClusterSharding) ([]ComponentPair, error)
type GetOptions ¶
type InstanceInfo ¶
type InstanceInfo struct {
	Name           string `json:"name,omitempty"`
	Namespace      string `json:"namespace,omitempty"`
	Cluster        string `json:"cluster,omitempty"`
	Component      string `json:"component,omitempty"`
	Status         string `json:"status,omitempty"`
	Role           string `json:"role,omitempty"`
	AccessMode     string `json:"accessMode,omitempty"`
	AZ             string `json:"az,omitempty"`
	Region         string `json:"region,omitempty"`
	CPU            string `json:"cpu,omitempty"`
	Memory         string `json:"memory,omitempty"`
	Storage        []StorageInfo
	Node           string `json:"node,omitempty"`
	CreatedTime    string `json:"age,omitempty"`
	ServiceVersion string `json:"serviceVersion,omitempty"`
}
    func GetSimpleInstanceInfos ¶
func GetSimpleInstanceInfos(dynamic dynamic.Interface, name, namespace string) []*InstanceInfo
GetSimpleInstanceInfos returns simple instance info that only contains instance name and role, the default instance should be the first element in the returned array.
func GetSimpleInstanceInfosForComponent ¶
func GetSimpleInstanceInfosForComponent(dynamic dynamic.Interface, name, componentName, namespace string) []*InstanceInfo
GetSimpleInstanceInfosForComponent returns simple instance info that only contains instance name and role for a component
type ObjectsGetter ¶
type ObjectsGetter struct {
	Client    clientset.Interface
	Dynamic   dynamic.Interface
	Name      string
	Namespace string
	GetOptions
}
    func (*ObjectsGetter) Get ¶
func (o *ObjectsGetter) Get() (*ClusterObjects, error)
Get all kubernetes objects belonging to the database cluster
type Printer ¶
type Printer struct {
	// contains filtered or unexported fields
}
    Printer prints cluster info
func NewPrinter ¶
func NewPrinter(out io.Writer, printType PrintType, opt *PrinterOptions) *Printer
func (*Printer) AddRow ¶
func (p *Printer) AddRow(objs *ClusterObjects)
func (*Printer) GetterOptions ¶
func (p *Printer) GetterOptions() GetOptions
type PrinterOptions ¶
type SchemaPropName ¶
type SchemaPropName string
const (
	VersionSchemaProp SchemaPropName = "version"
)
    the common schema property name
func (SchemaPropName) String ¶
func (s SchemaPropName) String() string
type StorageInfo ¶
type TypeInstance ¶
type TypeInstance struct {
	Name  ClusterType `yaml:"name"`
	URL   string      `yaml:"helmChartUrl"`
	Alias string      `yaml:"alias"`
	// chartName is the filename cached locally
	ChartName string `yaml:"chartName"`
}
    TypeInstance reference to a cluster type instance in config and implement the cluster.chartLoader interface
func (*TypeInstance) PatchNewClusterType ¶ added in v1.0.0
func (h *TypeInstance) PatchNewClusterType() error
func (*TypeInstance) PreCheck ¶
func (h *TypeInstance) PreCheck() error
PreCheck is used by `cluster register` command
func (*TypeInstance) ValidateChartSchema ¶ added in v1.0.0
func (h *TypeInstance) ValidateChartSchema() (bool, error)