component

package
v0.7.2-beta.23 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: AGPL-3.0 Imports: 27 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAffinity

func BuildAffinity(cluster *appsv1alpha1.Cluster, clusterCompSpec *appsv1alpha1.ClusterComponentSpec) *appsv1alpha1.Affinity

func BuildPodAffinity

func BuildPodAffinity(
	cluster *appsv1alpha1.Cluster,
	clusterOrCompAffinity *appsv1alpha1.Affinity,
	component *SynthesizedComponent,
) (*corev1.Affinity, error)

func BuildPodTopologySpreadConstraints

func BuildPodTopologySpreadConstraints(
	cluster *appsv1alpha1.Cluster,
	clusterOrCompAffinity *appsv1alpha1.Affinity,
	component *SynthesizedComponent,
) []corev1.TopologySpreadConstraint

func BuildTolerations

func BuildTolerations(cluster *appsv1alpha1.Cluster, clusterCompSpec *appsv1alpha1.ClusterComponentSpec) ([]corev1.Toleration, error)

BuildTolerations builds tolerations from config

func CheckJobSucceed added in v0.7.1

func CheckJobSucceed(ctx context.Context,
	cli client.Client,
	cluster *appsv1alpha1.Cluster,
	jobName string) error

CheckJobSucceed checks the result of job execution. Returns: - bool: whether job exist, true exist - error: any error that occurred during the handling

func CleanJobByName added in v0.7.1

func CleanJobByName(ctx context.Context,
	cli client.Client,
	cluster *appsv1alpha1.Cluster,
	jobName string) error

CleanJobByName cleans up the job task by name.

func CleanJobWithLabels added in v0.7.1

func CleanJobWithLabels(ctx context.Context,
	cli client.Client,
	cluster *appsv1alpha1.Cluster,
	matchLabels client.MatchingLabels) error

CleanJobWithLabels cleans up the job tasks with label.

func GenerateComponentEnvName

func GenerateComponentEnvName(clusterName, componentName string) string

func GenerateConnCredential

func GenerateConnCredential(clusterName string) string

func GenerateDefaultServiceDescriptorName

func GenerateDefaultServiceDescriptorName(clusterName string) string

func GetConfigSpecByName

func GetConfigSpecByName(component *SynthesizedComponent, configSpec string) *appsv1alpha1.ComponentConfigSpec

func GetEnvReplacementMapForConnCredential

func GetEnvReplacementMapForConnCredential(clusterName string) map[string]string

GetEnvReplacementMapForConnCredential gets the replacement map for connect credential

func GetJobWithLabels added in v0.7.1

func GetJobWithLabels(ctx context.Context,
	cli client.Client,
	cluster *appsv1alpha1.Cluster,
	matchLabels client.MatchingLabels) ([]batchv1.Job, error)

GetJobWithLabels gets the job list with the specified labels.

func GetReplacementMapForBuiltInEnv

func GetReplacementMapForBuiltInEnv(clusterName, clusterUID, componentName string) map[string]string

GetReplacementMapForBuiltInEnv gets the replacement map for KubeBlocks built-in environment variables.

func ReconcileCompPostStart added in v0.7.1

func ReconcileCompPostStart(ctx context.Context,
	cli client.Client,
	cluster *appsv1alpha1.Cluster,
	synthesizeComp *SynthesizedComponent,
	dag *graph.DAG) error

ReconcileCompPostStart reconciles the component-level postStart command.

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

func ReplaceSecretEnvVars(namedValuesMap map[string]string, envs []corev1.EnvVar) []corev1.EnvVar

ReplaceSecretEnvVars replaces the env secret value with namedValues and returns new envs

Types

type CloudProvider

type CloudProvider string
const (
	CloudProviderAWS     CloudProvider = "aws"
	CloudProviderGCP     CloudProvider = "gcp"
	CloudProviderAliyun  CloudProvider = "aliyun"
	CloudProviderAzure   CloudProvider = "azure"
	CloudProviderTencent CloudProvider = "tencent"
	CloudProviderUnknown CloudProvider = "unknown"
)

type MonitorConfig

type MonitorConfig struct {
	Enable     bool   `json:"enable"`
	BuiltIn    bool   `json:"builtIn"`
	ScrapePort int32  `json:"scrapePort,omitempty"`
	ScrapePath string `json:"scrapePath,omitempty"`
}

type SynthesizedComponent

type SynthesizedComponent struct {
	ClusterDefName        string                                 `json:"clusterDefName,omitempty"`
	ClusterName           string                                 `json:"clusterName,omitempty"`
	ClusterUID            string                                 `json:"clusterUID,omitempty"`
	Name                  string                                 `json:"name,omitempty"`
	CompDefName           string                                 `json:"compDefName,omitempty"`
	CharacterType         string                                 `json:"characterType,omitempty"`
	MinAvailable          *intstr.IntOrString                    `json:"minAvailable,omitempty"`
	Replicas              int32                                  `json:"replicas"`
	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"`
	PodSpec               *corev1.PodSpec                        `json:"podSpec,omitempty"`
	Services              []corev1.Service                       `json:"services,omitempty"`
	Probes                *v1alpha1.ClusterDefinitionProbes      `json:"probes,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"`
	HorizontalScalePolicy *v1alpha1.HorizontalScalePolicy        `json:"horizontalScalePolicy,omitempty"`
	TLS                   bool                                   `json:"tls"`
	Issuer                *v1alpha1.Issuer                       `json:"issuer,omitempty"`
	VolumeTypes           []v1alpha1.VolumeTypeSpec              `json:"volumeTypes,omitempty"`
	VolumeProtection      *v1alpha1.VolumeProtectionSpec         `json:"volumeProtection,omitempty"`
	CustomLabelSpecs      []v1alpha1.CustomLabelSpec             `json:"customLabelSpecs,omitempty"`
	SwitchoverSpec        *v1alpha1.SwitchoverSpec               `json:"switchoverSpec,omitempty"`
	ComponentDef          string                                 `json:"componentDef,omitempty"`
	ServiceAccountName    string                                 `json:"serviceAccountName,omitempty"`
	StatefulSetWorkload   v1alpha1.StatefulSetWorkload           `json:"statefulSetWorkload,omitempty"`
	ComponentRefEnvs      []*corev1.EnvVar                       `json:"componentRefEnvs,omitempty"`
	ServiceReferences     map[string]*v1alpha1.ServiceDescriptor `json:"serviceReferences,omitempty"`
	PostStartSpec         *v1alpha1.PostStartAction              `json:"postStartSpec,omitempty"`
}

func BuildComponent

func BuildComponent(reqCtx intctrlutil.RequestCtx,
	clsMgr *class.Manager,
	cluster *appsv1alpha1.Cluster,
	clusterDef *appsv1alpha1.ClusterDefinition,
	clusterCompDef *appsv1alpha1.ClusterComponentDefinition,
	clusterCompSpec *appsv1alpha1.ClusterComponentSpec,
	serviceReferences map[string]*appsv1alpha1.ServiceDescriptor,
	clusterCompVers ...*appsv1alpha1.ClusterComponentVersion) (*SynthesizedComponent, error)

BuildComponent generates a new Component object, which is a mixture of component-related configs from input Cluster, ClusterDef and ClusterVersion.

Jump to

Keyboard shortcuts

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