Documentation ¶
Index ¶
- func BuildAffinity(cluster *appsv1alpha1.Cluster, compSpec *appsv1alpha1.ClusterComponentSpec) *appsv1alpha1.Affinity
- func BuildComponent(cluster *appsv1alpha1.Cluster, ...) (*appsv1alpha1.Component, error)
- func BuildComponentDefinition(clusterDef *appsv1alpha1.ClusterDefinition, ...) (*appsv1alpha1.ComponentDefinition, error)
- func BuildPodAffinity(clusterName string, compName string, compAffinity *appsv1alpha1.Affinity) (*corev1.Affinity, error)
- func BuildPodTopologySpreadConstraints(clusterName, compName string, compAffinity *appsv1alpha1.Affinity) []corev1.TopologySpreadConstraint
- func BuildRSMFrom(cluster *appsv1alpha1.Cluster, synthesizeComp *SynthesizedComponent, ...) (*workloads.ReplicatedStateMachine, error)
- func BuildTolerations(cluster *appsv1alpha1.Cluster, compSpec *appsv1alpha1.ClusterComponentSpec) ([]corev1.Toleration, error)
- func ConvertSynthesizeCompRoleToRSMRole(synthesizedComp *SynthesizedComponent) []workloads.ReplicaRole
- func FullName(clusterName, compName string) string
- func GenServiceReferences(reqCtx intctrlutil.RequestCtx, cli roclient.ReadonlyClient, ...) (map[string]*appsv1alpha1.ServiceDescriptor, error)
- func GenServiceReferencesLegacy(reqCtx intctrlutil.RequestCtx, cli roclient.ReadonlyClient, ...) (map[string]*appsv1alpha1.ServiceDescriptor, error)
- func GetClusterName(comp *appsv1alpha1.Component) (string, error)
- func GetClusterUID(comp *appsv1alpha1.Component) (string, error)
- func GetComponentDeployMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, ...) (minReadySeconds int32, err error)
- func GetComponentPodList(ctx context.Context, cli client.Reader, cluster appsv1alpha1.Cluster, ...) (*corev1.PodList, error)
- func GetComponentPodListWithRole(ctx context.Context, cli client.Reader, cluster appsv1alpha1.Cluster, ...) (*corev1.PodList, error)
- func GetComponentStsMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, ...) (minReadySeconds int32, err error)
- func GetComponentWorkloadMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, ...) (minReadySeconds int32, err error)
- func GetConfigSpecByName(component *SynthesizedComponent, configSpec string) *appsv1alpha1.ComponentConfigSpec
- func GetEnvReplacementMapForCompConnCredential(clusterName, componentName string) map[string]string
- func GetEnvReplacementMapForConnCredential(clusterName string) map[string]string
- func GetObjectListByComponentName(ctx context.Context, cli client2.ReadonlyClient, cluster appsv1alpha1.Cluster, ...) error
- func GetReplacementMapForBuiltInEnv(clusterName, clusterUID, componentName string) map[string]string
- func IsComponentPodsWithLatestRevision(ctx context.Context, cli client.Reader, cluster *appsv1alpha1.Cluster, ...) (bool, error)
- func ListObjWithLabelsInNamespace[T generics.Object, PT generics.PObject[T], L generics.ObjList[T], ...](ctx context.Context, cli client.Reader, _ func(T, PT, L, PL), namespace string, ...) ([]PT, error)
- func ListPodOwnedByComponent(ctx context.Context, cli client.Reader, namespace string, ...) ([]*corev1.Pod, error)
- func ListRSMOwnedByComponent(ctx context.Context, cli client.Client, namespace string, ...) ([]*workloads.ReplicatedStateMachine, error)
- func ReplaceNamedVars(namedValuesMap map[string]string, targetVar string, limits int, matchAll bool) string
- func ReplaceSecretEnvVars(namedValuesMap map[string]string, envs []corev1.EnvVar) []corev1.EnvVar
- func ShortName(clusterName, compName string) (string, error)
- type MonitorConfig
- type SynthesizedComponent
- func BuildSynthesizedComponent(reqCtx intctrlutil.RequestCtx, cli client.Reader, ...) (*SynthesizedComponent, error)
- func BuildSynthesizedComponent4Generated(reqCtx intctrlutil.RequestCtx, cli client.Reader, ...) (*appsv1alpha1.ComponentDefinition, *SynthesizedComponent, error)
- func BuildSynthesizedComponentWrapper(reqCtx intctrlutil.RequestCtx, cli client.Reader, ...) (*SynthesizedComponent, error)
- func BuildSynthesizedComponentWrapper4Test(reqCtx intctrlutil.RequestCtx, cli client.Reader, ...) (*SynthesizedComponent, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAffinity ¶
func BuildAffinity(cluster *appsv1alpha1.Cluster, compSpec *appsv1alpha1.ClusterComponentSpec) *appsv1alpha1.Affinity
BuildAffinity builds affinities for components from cluster and comp spec.
func BuildComponent ¶
func BuildComponent(cluster *appsv1alpha1.Cluster, clusterCompSpec *appsv1alpha1.ClusterComponentSpec) (*appsv1alpha1.Component, error)
BuildComponent builds a new Component object from cluster component spec and definition.
func BuildComponentDefinition ¶ added in v0.8.0
func BuildComponentDefinition(clusterDef *appsv1alpha1.ClusterDefinition, clusterVer *appsv1alpha1.ClusterVersion, clusterCompSpec *appsv1alpha1.ClusterComponentSpec) (*appsv1alpha1.ComponentDefinition, error)
func BuildPodAffinity ¶
func BuildPodTopologySpreadConstraints ¶
func BuildPodTopologySpreadConstraints(clusterName, compName string, compAffinity *appsv1alpha1.Affinity) []corev1.TopologySpreadConstraint
func BuildRSMFrom ¶ added in v0.8.0
func BuildRSMFrom(cluster *appsv1alpha1.Cluster, synthesizeComp *SynthesizedComponent, protoRSM *workloads.ReplicatedStateMachine) (*workloads.ReplicatedStateMachine, error)
BuildRSMFrom builds a new Component object based on Cluster, SynthesizedComponent.
func BuildTolerations ¶
func BuildTolerations(cluster *appsv1alpha1.Cluster, compSpec *appsv1alpha1.ClusterComponentSpec) ([]corev1.Toleration, error)
BuildTolerations builds tolerations for components from cluster and comp spec.
func ConvertSynthesizeCompRoleToRSMRole ¶ added in v0.8.0
func ConvertSynthesizeCompRoleToRSMRole(synthesizedComp *SynthesizedComponent) []workloads.ReplicaRole
ConvertSynthesizeCompRoleToRSMRole converts the component.SynthesizedComponent.Roles to workloads.ReplicaRole.
func GenServiceReferences ¶ added in v0.8.0
func GenServiceReferences(reqCtx intctrlutil.RequestCtx, cli roclient.ReadonlyClient, namespace, clusterName string, compDef *appsv1alpha1.ComponentDefinition, comp *appsv1alpha1.Component) (map[string]*appsv1alpha1.ServiceDescriptor, error)
func GenServiceReferencesLegacy ¶ added in v0.8.0
func GenServiceReferencesLegacy(reqCtx intctrlutil.RequestCtx, cli roclient.ReadonlyClient, clusterDef *appsv1alpha1.ClusterDefinition, clusterVer *appsv1alpha1.ClusterVersion, cluster *appsv1alpha1.Cluster, clusterCompSpec *appsv1alpha1.ClusterComponentSpec) (map[string]*appsv1alpha1.ServiceDescriptor, error)
func GetClusterName ¶ added in v0.8.0
func GetClusterName(comp *appsv1alpha1.Component) (string, error)
func GetClusterUID ¶ added in v0.8.0
func GetClusterUID(comp *appsv1alpha1.Component) (string, error)
func GetComponentDeployMinReadySeconds ¶ added in v0.8.0
func GetComponentDeployMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, componentName string) (minReadySeconds int32, err error)
GetComponentDeployMinReadySeconds gets the deployment minReadySeconds of the component.
func GetComponentPodList ¶ added in v0.8.0
func GetComponentPodList(ctx context.Context, cli client.Reader, cluster appsv1alpha1.Cluster, componentName string) (*corev1.PodList, error)
GetComponentPodList gets the pod list by cluster and componentName
func GetComponentPodListWithRole ¶ added in v0.8.0
func GetComponentPodListWithRole(ctx context.Context, cli client.Reader, cluster appsv1alpha1.Cluster, compSpecName, role string) (*corev1.PodList, error)
GetComponentPodListWithRole gets the pod list with target role by cluster and componentName
func GetComponentStsMinReadySeconds ¶ added in v0.8.0
func GetComponentStsMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, componentName string) (minReadySeconds int32, err error)
GetComponentStsMinReadySeconds gets the statefulSet minReadySeconds of the component.
func GetComponentWorkloadMinReadySeconds ¶ added in v0.8.0
func GetComponentWorkloadMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, workloadType appsv1alpha1.WorkloadType, componentName string) (minReadySeconds int32, err error)
GetComponentWorkloadMinReadySeconds gets the workload minReadySeconds of the component.
func GetConfigSpecByName ¶
func GetConfigSpecByName(component *SynthesizedComponent, configSpec string) *appsv1alpha1.ComponentConfigSpec
func GetEnvReplacementMapForCompConnCredential ¶
GetEnvReplacementMapForCompConnCredential gets the replacement map for component connect credential
func GetEnvReplacementMapForConnCredential ¶
GetEnvReplacementMapForConnCredential gets the replacement map for connect credential
func GetObjectListByComponentName ¶ added in v0.8.0
func GetObjectListByComponentName(ctx context.Context, cli client2.ReadonlyClient, cluster appsv1alpha1.Cluster, objectList client.ObjectList, componentName string) error
GetObjectListByComponentName gets k8s workload list with component
func GetReplacementMapForBuiltInEnv ¶
func GetReplacementMapForBuiltInEnv(clusterName, clusterUID, componentName string) map[string]string
GetReplacementMapForBuiltInEnv gets the replacement map for KubeBlocks built-in environment variables.
func IsComponentPodsWithLatestRevision ¶ added in v0.8.0
func IsComponentPodsWithLatestRevision(ctx context.Context, cli client.Reader, cluster *appsv1alpha1.Cluster, rsm *workloads.ReplicatedStateMachine) (bool, error)
IsComponentPodsWithLatestRevision checks whether the underlying pod spec matches the one declared in the Cluster/Component.
func ListObjWithLabelsInNamespace ¶ added in v0.8.0
func ListPodOwnedByComponent ¶ added in v0.8.0
func ListRSMOwnedByComponent ¶ added in v0.8.0
func ListRSMOwnedByComponent(ctx context.Context, cli client.Client, namespace string, labels client.MatchingLabels) ([]*workloads.ReplicatedStateMachine, error)
func ReplaceNamedVars ¶
func ReplaceNamedVars(namedValuesMap map[string]string, targetVar string, limits int, matchAll bool) string
ReplaceNamedVars replaces the placeholder in targetVar if it is match and returns the replaced result
func ReplaceSecretEnvVars ¶
ReplaceSecretEnvVars replaces the env secret value with namedValues and returns new envs
Types ¶
type MonitorConfig ¶
type SynthesizedComponent ¶
type SynthesizedComponent struct { Namespace string `json:"namespace,omitempty"` ClusterName string `json:"clusterName,omitempty"` ClusterUID string `json:"clusterUID,omitempty"` Name string `json:"name,omitempty"` // the name of the component without clusterName prefix FullCompName string `json:"fullCompName,omitempty"` // the full name of the component with clusterName prefix CompDefName string `json:"compDefName,omitempty"` // the name of the componentDefinition Replicas int32 `json:"replicas"` PodSpec *corev1.PodSpec `json:"podSpec,omitempty"` VolumeClaimTemplates []corev1.PersistentVolumeClaimTemplate `json:"volumeClaimTemplates,omitempty"` Monitor *MonitorConfig `json:"monitor,omitempty"` EnabledLogs []string `json:"enabledLogs,omitempty"` LogConfigs []v1alpha1.LogConfig `json:"logConfigs,omitempty"` ConfigTemplates []v1alpha1.ComponentConfigSpec `json:"configTemplates,omitempty"` ScriptTemplates []v1alpha1.ComponentTemplateSpec `json:"scriptTemplates,omitempty"` TLSConfig *v1alpha1.TLSConfig `json:"tlsConfig"` ServiceAccountName string `json:"serviceAccountName,omitempty"` ComponentRefEnvs []*corev1.EnvVar `json:"componentRefEnvs,omitempty"` ServiceReferences map[string]*v1alpha1.ServiceDescriptor `json:"serviceReferences,omitempty"` // The following fields were introduced with the ComponentDefinition and Component API in KubeBlocks version 0.8.0 Roles []v1alpha1.ReplicaRole `json:"roles,omitempty"` Labels map[string]v1alpha1.BuiltInString `json:"labels,omitempty"` ConnectionCredentials []v1alpha1.ConnectionCredential `json:"connectionCredentials,omitempty"` UpdateStrategy *v1alpha1.UpdateStrategy `json:"updateStrategy,omitempty"` PolicyRules []rbacv1.PolicyRule `json:"policyRules,omitempty"` LifecycleActions *v1alpha1.ComponentLifecycleActions `json:"lifecycleActions,omitempty"` SystemAccounts []v1alpha1.SystemAccount `json:"systemAccounts,omitempty"` RoleArbitrator *v1alpha1.RoleArbitrator `json:"roleArbitrator,omitempty"` Volumes []v1alpha1.ComponentVolume `json:"volumes,omitempty"` ComponentServices []v1alpha1.Service `json:"componentServices,omitempty"` // TODO(xingran): The following fields will be deprecated after version 0.8.0 and will be replaced with a new data structure. CustomLabelSpecs []v1alpha1.CustomLabelSpec `json:"customLabelSpecs,omitempty"` // The CustomLabelSpecs will be replaced with Labels in the future. SwitchoverSpec *v1alpha1.SwitchoverSpec `json:"switchoverSpec,omitempty"` // The SwitchoverSpec will be replaced with LifecycleActions.Switchover in the future. Probes *v1alpha1.ClusterDefinitionProbes `json:"probes,omitempty"` // The Probes will be replaced with LifecycleActions.RoleProbe in the future. VolumeTypes []v1alpha1.VolumeTypeSpec `json:"volumeTypes,omitempty"` // The VolumeTypes will be replaced with Volumes in the future. VolumeProtection *v1alpha1.VolumeProtectionSpec `json:"volumeProtection,omitempty"` // The VolumeProtection will be replaced with Volumes in the future. Services []corev1.Service `json:"services,omitempty"` // The Services will be replaced with ComponentServices in the future. StatefulSetWorkload v1alpha1.StatefulSetWorkload `json:"statefulSetWorkload,omitempty"` // The StatefulSetWorkload will be replaced with UpdateStrategy in the future. // TODO(xingran): The following fields will be deprecated after KubeBlocks version 0.8.0 ClusterDefName string `json:"clusterDefName,omitempty"` // the name of the clusterDefinition ClusterCompDefName string `json:"clusterCompDefName,omitempty"` // the name of the clusterDefinition.Spec.ComponentDefs[*].Name or cluster.Spec.ComponentSpecs[*].ComponentDefRef CharacterType string `json:"characterType,omitempty"` WorkloadType v1alpha1.WorkloadType `json:"workloadType,omitempty"` StatelessSpec *v1alpha1.StatelessSetSpec `json:"statelessSpec,omitempty"` StatefulSpec *v1alpha1.StatefulSetSpec `json:"statefulSpec,omitempty"` ConsensusSpec *v1alpha1.ConsensusSetSpec `json:"consensusSpec,omitempty"` ReplicationSpec *v1alpha1.ReplicationSetSpec `json:"replicationSpec,omitempty"` RSMSpec *v1alpha1.RSMSpec `json:"rsmSpec,omitempty"` HorizontalScalePolicy *v1alpha1.HorizontalScalePolicy `json:"horizontalScalePolicy,omitempty"` // MinAvailable is used to determine whether to create a PDB (Pod Disruption Budget) object. // However, the functionality of PDB should be implemented within the RSM. Therefore, PDB objects are no longer needed in the new API, and the MinAvailable field should be deprecated. // The old MinAvailable field, which is determined based on the deprecated "workloadType" field, is also no longer applicable in the new API. MinAvailable *intstr.IntOrString `json:"minAvailable,omitempty"` }
func BuildSynthesizedComponent ¶ added in v0.8.0
func BuildSynthesizedComponent(reqCtx intctrlutil.RequestCtx, cli client.Reader, compDef *appsv1alpha1.ComponentDefinition, comp *appsv1alpha1.Component) (*SynthesizedComponent, error)
BuildSynthesizedComponent builds a new SynthesizedComponent object, which is a mixture of component-related configs from ComponentDefinition and Component.
func BuildSynthesizedComponent4Generated ¶ added in v0.8.0
func BuildSynthesizedComponent4Generated(reqCtx intctrlutil.RequestCtx, cli client.Reader, cluster *appsv1alpha1.Cluster, comp *appsv1alpha1.Component) (*appsv1alpha1.ComponentDefinition, *SynthesizedComponent, error)
BuildSynthesizedComponent4Generated builds SynthesizedComponent for generated Component which w/o ComponentDefinition.
func BuildSynthesizedComponentWrapper ¶ added in v0.8.0
func BuildSynthesizedComponentWrapper(reqCtx intctrlutil.RequestCtx, cli client.Reader, cluster *appsv1alpha1.Cluster, clusterCompSpec *appsv1alpha1.ClusterComponentSpec) (*SynthesizedComponent, error)
BuildSynthesizedComponentWrapper builds a new SynthesizedComponent object with a given ClusterComponentSpec. TODO: remove this
func BuildSynthesizedComponentWrapper4Test ¶ added in v0.8.0
func BuildSynthesizedComponentWrapper4Test(reqCtx intctrlutil.RequestCtx, cli client.Reader, clusterDef *appsv1alpha1.ClusterDefinition, clusterVer *appsv1alpha1.ClusterVersion, cluster *appsv1alpha1.Cluster, clusterCompSpec *appsv1alpha1.ClusterComponentSpec) (*SynthesizedComponent, error)
BuildSynthesizedComponentWrapper4Test builds a new SynthesizedComponent object with a given ClusterComponentSpec.