component

package
v1.0.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: AGPL-3.0 Imports: 41 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppsInstanceToWorkloadInstance added in v0.9.0

func AppsInstanceToWorkloadInstance(instance *appsv1alpha1.InstanceTemplate) *workloads.InstanceTemplate

func BuildComponent

func BuildComponent(cluster *appsv1alpha1.Cluster, compSpec *appsv1alpha1.ClusterComponentSpec,
	labels, annotations map[string]string) (*appsv1alpha1.Component, error)

BuildComponent builds a new Component object from cluster component spec and definition.

func BuildWorkloadFrom added in v0.9.0

func BuildWorkloadFrom(synthesizeComp *SynthesizedComponent, protoITS *workloads.InstanceSet) (*workloads.InstanceSet, error)

BuildWorkloadFrom builds a new Component object based on SynthesizedComponent.

func CompareServiceVersion added in v0.9.0

func CompareServiceVersion(required, provided string) (bool, error)

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 *appsv1alpha1.ComponentDefinition) ([]*appsv1alpha1.ComponentVersion, error)

CompatibleCompVersions4Definition returns all component versions that are compatible with specified component definition.

func ConvertSynthesizeCompRoleToInstanceSetRole added in v0.9.0

func ConvertSynthesizeCompRoleToInstanceSetRole(synthesizedComp *SynthesizedComponent) []workloads.ReplicaRole

ConvertSynthesizeCompRoleToInstanceSetRole converts the component.SynthesizedComponent.Roles to workloads.ReplicaRole.

func FullName added in v0.8.0

func FullName(clusterName, compName string) string

func GenerateAllPodNames added in v0.9.0

func GenerateAllPodNames(
	compReplicas int32,
	instances []appsv1alpha1.InstanceTemplate,
	offlineInstances []string,
	clusterName,
	fullCompName string) ([]string, error)

GenerateAllPodNames generate all pod names for a component.

func GenerateAllPodNamesToSet added in v0.9.0

func GenerateAllPodNamesToSet(
	compReplicas int32,
	instances []appsv1alpha1.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 GetClusterComponentShortNameSet added in v0.8.2

func GetClusterComponentShortNameSet(ctx context.Context, cli client.Reader, cluster *appsv1alpha1.Cluster) (sets.Set[string], error)

GetClusterComponentShortNameSet gets the component short name set of the cluster.

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 GetCompDefByName added in v0.9.0

func GetCompDefByName(ctx context.Context, cli client.Reader, compDefName string) (*appsv1alpha1.ComponentDefinition, error)

GetCompDefByName gets the component definition by component definition name.

func GetCompNCompDefByName added in v0.9.0

func GetCompNCompDefByName(ctx context.Context, cli client.Reader, namespace, fullCompName string) (*appsv1alpha1.Component, *appsv1alpha1.ComponentDefinition, error)

func GetComponentByName added in v0.9.0

func GetComponentByName(ctx context.Context, cli client.Reader, namespace, fullCompName string) (*appsv1alpha1.Component, error)

func GetConfigSpecByName

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

func GetExporter added in v0.9.0

func GetExporter(componentDef appsv1alpha1.ComponentDefinitionSpec) *common.Exporter

func GetMinReadySeconds added in v0.9.0

func GetMinReadySeconds(ctx context.Context, cli client.Client, cluster appsv1alpha1.Cluster, compName string) (minReadySeconds int32, err error)

GetMinReadySeconds gets the underlying workload's minReadySeconds of the component.

func GetReplacementMapForBuiltInEnv

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

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

func GetTemplateNameAndOrdinal added in v0.9.0

func GetTemplateNameAndOrdinal(workloadName, podName string) (string, int32, error)

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 IsGenerated added in v0.9.0

func IsGenerated(comp *appsv1alpha1.Component) bool

IsGenerated checks if the component is generated from legacy cluster definitions.

func IsHostNetworkEnabled added in v0.9.0

func IsHostNetworkEnabled(synthesizedComp *SynthesizedComponent) bool

func IsKBAgentContainer

func IsKBAgentContainer(c *corev1.Container) bool

func ListClusterComponents added in v0.8.2

func ListClusterComponents(ctx context.Context, cli client.Reader, cluster *appsv1alpha1.Cluster) ([]appsv1alpha1.Component, error)

ListClusterComponents lists the components of the cluster.

func ListOwnedPVCs

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 ListOwnedPods(ctx context.Context, cli client.Reader, namespace, clusterName, compName string,
	opts ...client.ListOption) ([]*corev1.Pod, error)

func ListOwnedPodsWithRole

func ListOwnedPodsWithRole(ctx context.Context, cli client.Reader, namespace, clusterName, compName, role string,
	opts ...client.ListOption) ([]*corev1.Pod, error)

func ListOwnedServices added in v0.9.0

func ListOwnedServices(ctx context.Context, cli client.Reader, namespace, clusterName, compName string,
	opts ...client.ListOption) ([]*corev1.Service, error)

func ListOwnedWorkloads added in v0.9.1

func ListOwnedWorkloads(ctx context.Context, cli client.Reader, namespace, clusterName, compName string) ([]*workloads.InstanceSet, error)

func PodFQDN

func PodFQDN(namespace, compName, podName string) string

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 ResolveEnvVars4LegacyCluster added in v0.8.0

func ResolveEnvVars4LegacyCluster(ctx context.Context, cli client.Reader, synthesizedComp *SynthesizedComponent, definedVars []appsv1alpha1.EnvVar) (map[string]any, []corev1.EnvVar, error)

func ResolveTemplateNEnvVars added in v0.8.0

func ResolveTemplateNEnvVars(ctx context.Context, cli client.Reader, synthesizedComp *SynthesizedComponent, definedVars []appsv1alpha1.EnvVar) (map[string]any, []corev1.EnvVar, error)

ResolveTemplateNEnvVars resolves all built-in and user-defined vars for config template and Env usage.

func ShortName added in v0.8.0

func ShortName(clusterName, compName string) (string, error)

func UpdateCompDefinitionImages4ServiceVersion added in v0.9.0

func UpdateCompDefinitionImages4ServiceVersion(ctx context.Context, cli client.Reader,
	compDef *appsv1alpha1.ComponentDefinition, serviceVersion string) error

UpdateCompDefinitionImages4ServiceVersion resolves and updates images for the component definition.

func UpdateKBAgentContainer4HostNetwork

func UpdateKBAgentContainer4HostNetwork(synthesizedComp *SynthesizedComponent)

func VarReferenceRegExp added in v0.8.0

func VarReferenceRegExp() *regexp.Regexp

Types

type SynthesizedComponent

type SynthesizedComponent struct {
	Namespace                        string            `json:"namespace,omitempty"`
	ClusterName                      string            `json:"clusterName,omitempty"`
	ClusterUID                       string            `json:"clusterUID,omitempty"`
	ClusterGeneration                string            `json:"clusterGeneration,omitempty"`
	Comp2CompDefs                    map[string]string `json:"comp2CompDefs,omitempty"` // {compName: compDefName}
	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
	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"`
	VolumeClaimTemplates             []corev1.PersistentVolumeClaimTemplate `json:"volumeClaimTemplates,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"`
	ServiceReferences                map[string]*v1alpha1.ServiceDescriptor `json:"serviceReferences,omitempty"`
	UserDefinedLabels                map[string]string
	UserDefinedAnnotations           map[string]string
	TemplateVars                     map[string]any                      `json:"templateVars,omitempty"`
	EnvVars                          []corev1.EnvVar                     `json:"envVars,omitempty"`
	EnvFromSources                   []corev1.EnvFromSource              `json:"envFromSources,omitempty"`
	Instances                        []v1alpha1.InstanceTemplate         `json:"instances,omitempty"`
	OfflineInstances                 []string                            `json:"offlineInstances,omitempty"`
	Roles                            []v1alpha1.ReplicaRole              `json:"roles,omitempty"`
	Labels                           map[string]string                   `json:"labels,omitempty"`
	Annotations                      map[string]string                   `json:"annotations,omitempty"`
	UpdateStrategy                   *v1alpha1.UpdateStrategy            `json:"updateStrategy,omitempty"`
	PodManagementPolicy              *appsv1.PodManagementPolicyType     `json:"podManagementPolicy,omitempty"`
	ParallelPodManagementConcurrency *intstr.IntOrString                 `json:"parallelPodManagementConcurrency,omitempty"`
	PodUpdatePolicy                  *workloads.PodUpdatePolicyType      `json:"podUpdatePolicy,omitempty"`
	PolicyRules                      []rbacv1.PolicyRule                 `json:"policyRules,omitempty"`
	LifecycleActions                 *v1alpha1.ComponentLifecycleActions `json:"lifecycleActions,omitempty"`
	SystemAccounts                   []v1alpha1.SystemAccount            `json:"systemAccounts,omitempty"`
	Volumes                          []v1alpha1.ComponentVolume          `json:"volumes,omitempty"`
	HostNetwork                      *v1alpha1.HostNetwork               `json:"hostNetwork,omitempty"`
	ComponentServices                []v1alpha1.ComponentService         `json:"componentServices,omitempty"`
	MinReadySeconds                  int32                               `json:"minReadySeconds,omitempty"`
	Sidecars                         []string                            `json:"sidecars,omitempty"`
	DisableExporter                  *bool                               `json:"disableExporter,omitempty"`
	Stop                             *bool

	// TODO(xingran): The following fields will be deprecated after KubeBlocks version 0.8.0
	ClusterDefName                      string   `json:"clusterDefName,omitempty"` // the name of the clusterDefinition
	EnabledLogs                         []string `json:"enabledLogs,omitempty"`
	HorizontalScaleBackupPolicyTemplate *string
}

func BuildSynthesizedComponent added in v0.8.0

func BuildSynthesizedComponent(reqCtx intctrlutil.RequestCtx,
	cli client.Reader,
	cluster *appsv1alpha1.Cluster,
	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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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