Documentation
¶
Index ¶
- Constants
- func BuildConfigManagerContainerParams(cli client.Client, ctx context.Context, managerParams *CfgManagerBuildParams) error
- func FindVolumeMount(volumeDirs []corev1.VolumeMount, volumeName string) *corev1.VolumeMount
- func FromReloadTypeConfig(reloadAction *parametersv1alpha1.ReloadAction) parametersv1alpha1.DynamicReloadType
- func GetScriptsVolumeName(configSpec appsv1.ComponentFileTemplate) string
- func IsAutoReload(reload *parametersv1alpha1.ReloadAction) bool
- func IsSupportReload(reload *parametersv1alpha1.ReloadAction) bool
- func NeedRestart(paramsDefs map[string]*parametersv1alpha1.ParametersDefinition, ...) bool
- func SetLogger(zapLogger *zap.Logger)
- func ValidateReloadOptions(reloadAction *parametersv1alpha1.ReloadAction, cli client.Client, ...) error
- type CfgManagerBuildParams
- type ConfigHandler
- type ConfigSpecInfo
- type ConfigSpecMeta
Constants ¶
const ( KBScriptVolumePath = "/opt/kb-tools/reload" KBTOOLSScriptsPathEnv = "TOOLS_SCRIPTS_PATH" KBConfigManagerPathEnv = "TOOLS_PATH" )
Variables ¶
This section is empty.
Functions ¶
func FindVolumeMount ¶
func FindVolumeMount(volumeDirs []corev1.VolumeMount, volumeName string) *corev1.VolumeMount
func FromReloadTypeConfig ¶
func FromReloadTypeConfig(reloadAction *parametersv1alpha1.ReloadAction) parametersv1alpha1.DynamicReloadType
func GetScriptsVolumeName ¶
func GetScriptsVolumeName(configSpec appsv1.ComponentFileTemplate) string
func IsAutoReload ¶
func IsAutoReload(reload *parametersv1alpha1.ReloadAction) bool
func IsSupportReload ¶
func IsSupportReload(reload *parametersv1alpha1.ReloadAction) bool
func NeedRestart ¶
func NeedRestart(paramsDefs map[string]*parametersv1alpha1.ParametersDefinition, patch *core.ConfigPatchInfo) bool
func ValidateReloadOptions ¶
func ValidateReloadOptions(reloadAction *parametersv1alpha1.ReloadAction, cli client.Client, ctx context.Context) error
Types ¶
type CfgManagerBuildParams ¶
type CfgManagerBuildParams struct {
ManagerName string `json:"name"`
Image string `json:"sidecarImage"`
Args []string `json:"args"`
Envs []corev1.EnvVar `json:"envs"`
Volumes []corev1.VolumeMount `json:"volumes"`
ComponentName string `json:"componentName"`
SecreteName string `json:"secreteName"` // TODO(v1.0): conn-credential
// add volume to pod
ScriptVolume []corev1.Volume
Cluster *appsv1.Cluster
ConfigSpecsBuildParams []ConfigSpecMeta
// init tools container
ToolsContainers []corev1.Container
CMConfigVolumes []corev1.Volume
// support custom config manager sidecar
ConfigManagerReloadPath string `json:"configManagerReloadPath"`
// support host network
ContainerPort int32 `json:"containerPort"`
}
CfgManagerBuildParams is the params for building config manager sidecar
type ConfigHandler ¶
type ConfigHandler interface {
OnlineUpdate(ctx context.Context, name string, updatedParams map[string]string) error
}
func CreateCombinedHandler ¶
func CreateCombinedHandler(config string) (ConfigHandler, error)
type ConfigSpecInfo ¶
type ConfigSpecInfo struct {
*parametersv1alpha1.ReloadAction `json:",inline"`
ReloadType parametersv1alpha1.DynamicReloadType `json:"reloadType"`
ConfigSpec appsv1.ComponentFileTemplate `json:"configSpec"`
ConfigFile string `json:"configFile"`
}
type ConfigSpecMeta ¶
type ConfigSpecMeta struct {
ConfigSpecInfo `json:",inline"`
ScriptConfig []parametersv1alpha1.ScriptConfig
ToolsImageSpec *parametersv1alpha1.ToolsSetup
}
func FilterSupportReloadActionConfigSpecs ¶
func FilterSupportReloadActionConfigSpecs(metas []ConfigSpecMeta, volumes []corev1.VolumeMount) []ConfigSpecMeta
FilterSupportReloadActionConfigSpecs filters the provided ConfigSpecMeta slices based on the reload action type and volume mount configuration. It handles two types of updates to ConfigMaps:
1. Async mode: KubeBlocks controller is responsible for updating the ConfigMap, while kubelet synchronizes the ConfigMap to volumes. The config-manager detects configuration changes using fsnotify and executes the reload action. This requires volume mounting the ConfigMap. However, in async mode, if the volume mount is a subpath, kubelet does not synchronize the ConfigMap content to the container (see kubernetes/kubernetes#50345). As a result, the config-manager cannot detect configuration changes and does not support dynamic parameter updates for such configurations. Therefore, async-type ConfigSpecs with subpath volume mounts need to be removed.
2. Sync mode: For sync mode (regardless of the reload action type - ShellType trigger), the controller directly watches the ConfigMap changes and actively invokes the reload action.
Both async and sync types need to pass the ConfigSpecs to the config-manager.
The check logic is an OR condition: either it is the first type (sync mode) or the second type (async) with a non-subpath volume mount configuration.
func GetSupportReloadConfigSpecs ¶
func GetSupportReloadConfigSpecs(configSpecs []appsv1.ComponentFileTemplate, configDescs []parametersv1alpha1.ComponentConfigDescription, paramsDefs []*parametersv1alpha1.ParametersDefinition) ([]ConfigSpecMeta, error)