 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- func BuildComponent(cluster *appsv1.Cluster, compSpec *appsv1.ClusterComponentSpec, ...) (*appsv1.Component, error)
- func BuildReplicasStatus(running, proto *workloads.InstanceSet)
- func CompareServiceVersion(required, provided string) (bool, error)
- func CompatibleCompVersions4Definition(ctx context.Context, cli client.Reader, compDef *appsv1.ComponentDefinition) ([]*appsv1.ComponentVersion, error)
- func DefNameMatched(defName, defNamePattern string) bool
- func DeleteReplicasStatus(its *workloads.InstanceSet, replicas []string, f func(status ReplicaStatus)) error
- func FullName(clusterName, compName string) string
- func GenerateAllPodNames(compReplicas int32, instances []appsv1.InstanceTemplate, ...) ([]string, error)
- func GenerateAllPodNamesToSet(compReplicas int32, instances []appsv1.InstanceTemplate, ...) (map[string]string, error)
- func GetClusterName(comp *appsv1.Component) (string, error)
- func GetClusterUID(comp *appsv1.Component) (string, error)
- func GetCompDefByName(ctx context.Context, cli client.Reader, compDefName string) (*appsv1.ComponentDefinition, error)
- func GetCompNCompDefByName(ctx context.Context, cli client.Reader, namespace, fullCompName string) (*appsv1.Component, *appsv1.ComponentDefinition, error)
- func GetComponentAvailablePolicy(compDef *appsv1.ComponentDefinition) appsv1.ComponentAvailable
- func GetComponentByName(ctx context.Context, cli client.Reader, namespace, fullCompName string) (*appsv1.Component, error)
- func GetComponentNameFromObj(obj client.Object) string
- func GetExporter(componentDef appsv1.ComponentDefinitionSpec) *common.Exporter
- func GetMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1.Cluster, ...) (minReadySeconds int32, err error)
- func GetReplicasStatusFunc(its *workloads.InstanceSet, f func(ReplicaStatus) bool) ([]string, error)
- func GetTemplateNameAndOrdinal(workloadName, podName string) (string, int32, error)
- func InjectEnvVars(synthesizedComp *SynthesizedComponent, envVars []corev1.EnvVar, ...)
- func InjectEnvVars4Containers(synthesizedComp *SynthesizedComponent, envVars []corev1.EnvVar, ...)
- func IsHostNetworkEnabled(synthesizedComp *SynthesizedComponent) bool
- func IsKBAgentContainer(c *corev1.Container) bool
- func ListOwnedPVCs(ctx context.Context, cli client.Reader, ...) ([]*corev1.PersistentVolumeClaim, error)
- func ListOwnedPods(ctx context.Context, cli client.Reader, ...) ([]*corev1.Pod, error)
- func ListOwnedPodsWithRole(ctx context.Context, cli client.Reader, ...) ([]*corev1.Pod, error)
- func ListOwnedServices(ctx context.Context, cli client.Reader, ...) ([]*corev1.Service, error)
- func ListOwnedWorkloads(ctx context.Context, cli client.Reader, ...) ([]*workloads.InstanceSet, error)
- func NewReplicaTask(compName, uid string, source *corev1.Pod, replicas []string) (map[string]string, error)
- func NewReplicasStatus(its *workloads.InstanceSet, replicas []string, ...) error
- func PrefixOrRegexMatched(defName, defNamePattern string) bool
- func ResolveTemplateNEnvVars(ctx context.Context, cli client.Reader, synthesizedComp *SynthesizedComponent, ...) (map[string]any, []corev1.EnvVar, error)
- func ShortName(clusterName, compName string) (string, error)
- func StatusReplicasStatus(its *workloads.InstanceSet, replicas []string, ...) error
- func UDFReconfigureActionName(tpl SynthesizedFileTemplate) string
- func UpdateCompDefinitionImages4ServiceVersion(ctx context.Context, cli client.Reader, compDef *appsv1.ComponentDefinition, ...) error
- func UpdateKBAgentContainer4HostNetwork(synthesizedComp *SynthesizedComponent)
- func UpdateReplicasStatusFunc(its *workloads.InstanceSet, f func(status *ReplicasStatus) error) error
- func ValidateDefNameRegexp(defNamePattern string) error
- func VarReferenceRegExp() *regexp.Regexp
- type AvailableEventHandler
- type KBAgentTaskEventHandler
- type ReplicaStatus
- type ReplicasStatus
- type SynthesizedComponent
- type SynthesizedFileTemplate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildComponent ¶
func BuildComponent(cluster *appsv1.Cluster, compSpec *appsv1.ClusterComponentSpec, labels, annotations map[string]string) (*appsv1.Component, error)
BuildComponent builds a new Component object from cluster component spec and definition.
func BuildReplicasStatus ¶ added in v1.0.0
func BuildReplicasStatus(running, proto *workloads.InstanceSet)
func CompareServiceVersion ¶ added in v0.9.0
CompareServiceVersion compares whether two service version have the same major, minor and patch version.
func CompatibleCompVersions4Definition ¶ added in v0.9.0
func CompatibleCompVersions4Definition(ctx context.Context, cli client.Reader, compDef *appsv1.ComponentDefinition) ([]*appsv1.ComponentVersion, error)
CompatibleCompVersions4Definition returns all component versions that are compatible with specified component definition.
func DefNameMatched ¶ added in v1.0.0
func DeleteReplicasStatus ¶ added in v1.0.0
func DeleteReplicasStatus(its *workloads.InstanceSet, replicas []string, f func(status ReplicaStatus)) error
func GenerateAllPodNames ¶ added in v0.9.0
func GenerateAllPodNames( compReplicas int32, instances []appsv1.InstanceTemplate, offlineInstances []string, fullCompName string) ([]string, error)
GenerateAllPodNames generate all pod names for a component.
func GenerateAllPodNamesToSet ¶ added in v0.9.0
func GenerateAllPodNamesToSet( compReplicas int32, instances []appsv1.InstanceTemplate, offlineInstances []string, clusterName, fullCompName string) (map[string]string, error)
GenerateAllPodNamesToSet generate all pod names for a component and return a set which key is the pod name and value is a template name.
func GetCompDefByName ¶ added in v0.9.0
func GetCompDefByName(ctx context.Context, cli client.Reader, compDefName string) (*appsv1.ComponentDefinition, error)
GetCompDefByName gets the component definition by component definition name.
func GetCompNCompDefByName ¶ added in v0.9.0
func GetComponentAvailablePolicy ¶ added in v1.0.0
func GetComponentAvailablePolicy(compDef *appsv1.ComponentDefinition) appsv1.ComponentAvailable
func GetComponentByName ¶ added in v0.9.0
func GetComponentNameFromObj ¶ added in v1.0.0
GetComponentNameFromObj gets the component name from the k8s object.
func GetExporter ¶ added in v0.9.0
func GetExporter(componentDef appsv1.ComponentDefinitionSpec) *common.Exporter
func GetMinReadySeconds ¶ added in v0.9.0
func GetMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1.Cluster, compName string) (minReadySeconds int32, err error)
GetMinReadySeconds gets the underlying workload's minReadySeconds of the component.
func GetReplicasStatusFunc ¶ added in v1.0.0
func GetReplicasStatusFunc(its *workloads.InstanceSet, f func(ReplicaStatus) bool) ([]string, error)
func GetTemplateNameAndOrdinal ¶ added in v0.9.0
func InjectEnvVars ¶ added in v0.8.0
func InjectEnvVars(synthesizedComp *SynthesizedComponent, envVars []corev1.EnvVar, envFromSources []corev1.EnvFromSource)
func InjectEnvVars4Containers ¶ added in v0.8.0
func InjectEnvVars4Containers(synthesizedComp *SynthesizedComponent, envVars []corev1.EnvVar, envFromSources []corev1.EnvFromSource, filter func(container *corev1.Container) bool)
func IsHostNetworkEnabled ¶ added in v0.9.0
func IsHostNetworkEnabled(synthesizedComp *SynthesizedComponent) bool
func IsKBAgentContainer ¶ added in v1.0.0
func ListOwnedPVCs ¶ added in v1.0.0
func ListOwnedPVCs(ctx context.Context, cli client.Reader, namespace, clusterName, compName string, opts ...client.ListOption) ([]*corev1.PersistentVolumeClaim, error)
func ListOwnedPods ¶ added in v0.9.0
func ListOwnedPodsWithRole ¶ added in v1.0.0
func ListOwnedServices ¶ added in v0.9.0
func ListOwnedWorkloads ¶ added in v0.9.1
func NewReplicaTask ¶ added in v1.0.0
func NewReplicasStatus ¶ added in v1.0.0
func NewReplicasStatus(its *workloads.InstanceSet, replicas []string, hasMemberJoin, hasDataAction bool) error
func PrefixOrRegexMatched ¶ added in v1.0.0
func ResolveTemplateNEnvVars ¶ added in v0.8.0
func ResolveTemplateNEnvVars(ctx context.Context, cli client.Reader, synthesizedComp *SynthesizedComponent, definedVars []appsv1.EnvVar) (map[string]any, []corev1.EnvVar, error)
ResolveTemplateNEnvVars resolves all built-in and user-defined vars for config template and Env usage.
func StatusReplicasStatus ¶ added in v1.0.0
func StatusReplicasStatus(its *workloads.InstanceSet, replicas []string, hasMemberJoin, hasDataAction bool) error
func UDFReconfigureActionName ¶ added in v1.0.0
func UDFReconfigureActionName(tpl SynthesizedFileTemplate) string
func UpdateCompDefinitionImages4ServiceVersion ¶ added in v0.9.0
func UpdateCompDefinitionImages4ServiceVersion(ctx context.Context, cli client.Reader, compDef *appsv1.ComponentDefinition, serviceVersion string) error
UpdateCompDefinitionImages4ServiceVersion resolves and updates images for the component definition.
func UpdateKBAgentContainer4HostNetwork ¶ added in v1.0.0
func UpdateKBAgentContainer4HostNetwork(synthesizedComp *SynthesizedComponent)
func UpdateReplicasStatusFunc ¶ added in v1.0.0
func UpdateReplicasStatusFunc(its *workloads.InstanceSet, f func(status *ReplicasStatus) error) error
func ValidateDefNameRegexp ¶ added in v1.0.0
func VarReferenceRegExp ¶ added in v0.8.0
Types ¶
type AvailableEventHandler ¶ added in v1.0.0
type AvailableEventHandler struct{}
    func (*AvailableEventHandler) Handle ¶ added in v1.0.0
func (h *AvailableEventHandler) Handle(cli client.Client, reqCtx intctrlutil.RequestCtx, recorder record.EventRecorder, event *corev1.Event) error
type KBAgentTaskEventHandler ¶ added in v1.0.0
type KBAgentTaskEventHandler struct{}
    func (*KBAgentTaskEventHandler) Handle ¶ added in v1.0.0
func (h *KBAgentTaskEventHandler) Handle(cli client.Client, reqCtx intctrlutil.RequestCtx, recorder record.EventRecorder, event *corev1.Event) error
type ReplicaStatus ¶ added in v1.0.0
type ReplicaStatus struct {
	Name              string     `json:"name"`
	Generation        string     `json:"generation"`
	CreationTimestamp time.Time  `json:"creationTimestamp"`
	DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"`
	Message           string     `json:"message,omitempty"`
	Provisioned       bool       `json:"provisioned,omitempty"`
	DataLoaded        *bool      `json:"dataLoaded,omitempty"`
	MemberJoined      *bool      `json:"memberJoined,omitempty"`
	Reconfigured      *string    `json:"reconfigured,omitempty"` // TODO: component status
}
    type ReplicasStatus ¶ added in v1.0.0
type ReplicasStatus struct {
	Replicas int32           `json:"replicas"`
	Status   []ReplicaStatus `json:"status"`
}
    type SynthesizedComponent ¶
type SynthesizedComponent struct {
	Namespace                        string            `json:"namespace,omitempty"`
	ClusterName                      string            `json:"clusterName,omitempty"`
	ClusterUID                       string            `json:"clusterUID,omitempty"`
	Comp2CompDefs                    map[string]string `json:"comp2CompDefs,omitempty"`   // {compName: compDefName}
	CompDef2CompCnt                  map[string]int32  `json:"compDef2CompCnt,omitempty"` // {compDefName: expected comp cnt}
	Name                             string            `json:"name,omitempty"`            // the name of the component w/o clusterName prefix
	FullCompName                     string            `json:"fullCompName,omitempty"`    // the full name of the component w/ clusterName prefix
	Generation                       string
	CompDefName                      string `json:"compDefName,omitempty"` // the name of the componentDefinition
	ServiceKind                      string
	ServiceVersion                   string                                 `json:"serviceVersion,omitempty"`
	Replicas                         int32                                  `json:"replicas"`
	Resources                        corev1.ResourceRequirements            `json:"resources,omitempty"`
	PodSpec                          *corev1.PodSpec                        `json:"podSpec,omitempty"`
	SidecarVars                      []kbappsv1.EnvVar                      // vars defined by sidecars
	VolumeClaimTemplates             []corev1.PersistentVolumeClaimTemplate `json:"volumeClaimTemplates,omitempty"`
	PVCRetentionPolicy               kbappsv1.PersistentVolumeClaimRetentionPolicy
	LogConfigs                       []kbappsv1.LogConfig `json:"logConfigs,omitempty"`
	FileTemplates                    []SynthesizedFileTemplate
	ConfigTemplates                  []kbappsv1.ComponentTemplateSpec       `json:"configTemplates,omitempty"`
	TLSConfig                        *kbappsv1.TLSConfig                    `json:"tlsConfig"`
	ServiceAccountName               string                                 `json:"serviceAccountName,omitempty"`
	ServiceReferences                map[string]*kbappsv1.ServiceDescriptor `json:"serviceReferences,omitempty"`
	Labels                           map[string]string                      `json:"labels,omitempty"`
	StaticLabels                     map[string]string                      // labels defined by the component definition
	DynamicLabels                    map[string]string                      // labels defined by the cluster and component API
	Annotations                      map[string]string                      `json:"annotations,omitempty"`
	StaticAnnotations                map[string]string                      // annotations defined by the component definition
	DynamicAnnotations               map[string]string                      // annotations defined by the cluster and component API
	TemplateVars                     map[string]any                         `json:"templateVars,omitempty"`
	EnvVars                          []corev1.EnvVar                        `json:"envVars,omitempty"`
	EnvFromSources                   []corev1.EnvFromSource                 `json:"envFromSources,omitempty"`
	Instances                        []kbappsv1.InstanceTemplate            `json:"instances,omitempty"`
	OfflineInstances                 []string                               `json:"offlineInstances,omitempty"`
	Roles                            []kbappsv1.ReplicaRole                 `json:"roles,omitempty"`
	PodManagementPolicy              *appsv1.PodManagementPolicyType        `json:"podManagementPolicy,omitempty"`
	ParallelPodManagementConcurrency *intstr.IntOrString                    `json:"parallelPodManagementConcurrency,omitempty"`
	PodUpdatePolicy                  *kbappsv1.PodUpdatePolicyType          `json:"podUpdatePolicy,omitempty"`
	UpdateStrategy                   *kbappsv1.UpdateStrategy               `json:"updateStrategy,omitempty"`
	InstanceUpdateStrategy           *kbappsv1.InstanceUpdateStrategy       `json:"instanceUpdateStrategy,omitempty"`
	PolicyRules                      []rbacv1.PolicyRule                    `json:"policyRules,omitempty"`
	LifecycleActions                 *kbappsv1.ComponentLifecycleActions    `json:"lifecycleActions,omitempty"`
	SystemAccounts                   []kbappsv1.SystemAccount               `json:"systemAccounts,omitempty"`
	Volumes                          []kbappsv1.ComponentVolume             `json:"volumes,omitempty"`
	HostNetwork                      *kbappsv1.HostNetwork                  `json:"hostNetwork,omitempty"`
	ComponentServices                []kbappsv1.ComponentService            `json:"componentServices,omitempty"`
	MinReadySeconds                  int32                                  `json:"minReadySeconds,omitempty"`
	DisableExporter                  *bool                                  `json:"disableExporter,omitempty"`
	Stop                             *bool
}
    func BuildSynthesizedComponent ¶ added in v0.8.0
func BuildSynthesizedComponent(ctx context.Context, cli client.Reader, compDef *appsv1.ComponentDefinition, comp *appsv1.Component) (*SynthesizedComponent, error)
BuildSynthesizedComponent builds a new SynthesizedComponent object, which is a mixture of component-related configs from ComponentDefinition and Component. TODO: remove @ctx & @cli