 Documentation
      ¶
      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 *appsv1beta1.ReloadAction) appsv1beta1.DynamicReloadType
- func GetConfigMountPoint(configSpec appsv1alpha1.ComponentConfigSpec) string
- func GetConfigVolumeName(configSpec appsv1alpha1.ComponentConfigSpec) string
- func GetScriptsMountPoint(configSpec appsv1alpha1.ComponentConfigSpec) string
- func GetScriptsVolumeName(configSpec appsv1alpha1.ComponentConfigSpec) string
- func IsAutoReload(reload *appsv1beta1.ReloadAction) bool
- func IsSupportReload(reload *appsv1beta1.ReloadAction) bool
- func IsValidUnixSignal(sig appsv1beta1.SignalType) bool
- func NeedSharedProcessNamespace(configSpecs []ConfigSpecMeta) bool
- func ScanConfigVolume(mountPoint string) ([]string, error)
- func SetLogger(zapLogger *zap.Logger)
- func ValidateReloadOptions(reloadAction *appsv1beta1.ReloadAction, cli client.Client, ctx context.Context) error
- type ActionCallback
- type CfgManagerBuildParams
- type ConfigHandler
- func CreateCombinedHandler(config string, backupPath string) (ConfigHandler, error)
- func CreateExecHandler(command []string, mountPoint string, configMeta *ConfigSpecInfo, ...) (ConfigHandler, error)
- func CreateSignalHandler(sig appsv1beta1.SignalType, processName string, mountPoint string) (ConfigHandler, error)
- func CreateTPLScriptHandler(name, configPath string, dirs []string, backupPath string) (ConfigHandler, error)
 
- type ConfigLazyRenderedMeta
- type ConfigMapVolumeWatcher
- func (w *ConfigMapVolumeWatcher) AddFilter(filter NotifyEventFilter) *ConfigMapVolumeWatcher
- func (w *ConfigMapVolumeWatcher) AddHandler(handler WatchEventHandler) *ConfigMapVolumeWatcher
- func (w *ConfigMapVolumeWatcher) Close() error
- func (w *ConfigMapVolumeWatcher) Run() error
- func (w *ConfigMapVolumeWatcher) SetRetryCount(count int) *ConfigMapVolumeWatcher
 
- type ConfigSpecInfo
- type ConfigSpecMeta
- type DynamicParamUpdater
- type DynamicUpdater
- type NotifyEventFilter
- type PID
- type TPLScriptConfig
- type WatchEventHandler
Constants ¶
const ( KBScriptVolumePath = "/opt/kb-tools/reload" KBConfigVolumePath = "/opt/kb-tools/config" KBTOOLSScriptsPathEnv = "TOOLS_SCRIPTS_PATH" KBConfigManagerPathEnv = "TOOLS_PATH" )
const ( DefaultRetryCount = 3 DefaultSleepRetryTime = 10 )
const KBConfigSpecLazyRenderedYamlFile = "lazy-rendered-config.yaml"
    Variables ¶
This section is empty.
Functions ¶
func BuildConfigManagerContainerParams ¶
func BuildConfigManagerContainerParams(cli client.Client, ctx context.Context, managerParams *CfgManagerBuildParams, volumeDirs []corev1.VolumeMount) error
func FindVolumeMount ¶
func FindVolumeMount(volumeDirs []corev1.VolumeMount, volumeName string) *corev1.VolumeMount
func FromReloadTypeConfig ¶
func FromReloadTypeConfig(reloadAction *appsv1beta1.ReloadAction) appsv1beta1.DynamicReloadType
func GetConfigMountPoint ¶
func GetConfigMountPoint(configSpec appsv1alpha1.ComponentConfigSpec) string
func GetConfigVolumeName ¶
func GetConfigVolumeName(configSpec appsv1alpha1.ComponentConfigSpec) string
func GetScriptsMountPoint ¶
func GetScriptsMountPoint(configSpec appsv1alpha1.ComponentConfigSpec) string
func GetScriptsVolumeName ¶
func GetScriptsVolumeName(configSpec appsv1alpha1.ComponentConfigSpec) string
func IsAutoReload ¶ added in v0.8.0
func IsAutoReload(reload *appsv1beta1.ReloadAction) bool
func IsSupportReload ¶
func IsSupportReload(reload *appsv1beta1.ReloadAction) bool
func IsValidUnixSignal ¶
func IsValidUnixSignal(sig appsv1beta1.SignalType) bool
func NeedSharedProcessNamespace ¶
func NeedSharedProcessNamespace(configSpecs []ConfigSpecMeta) bool
func ScanConfigVolume ¶
func ValidateReloadOptions ¶
func ValidateReloadOptions(reloadAction *appsv1beta1.ReloadAction, cli client.Client, ctx context.Context) error
Types ¶
type ActionCallback ¶ added in v0.9.0
ActionCallback is a callback function for testcase.
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"`
	CharacterType string               `json:"characterType"`
	SecreteName   string               `json:"secreteName"`
	// add volume to pod
	ScriptVolume           []corev1.Volume
	Cluster                *appsv1alpha1.Cluster
	ConfigSpecsBuildParams []ConfigSpecMeta
	// init tools container
	ToolsContainers           []corev1.Container
	DownwardAPIVolumes        []corev1.VolumeMount
	CMConfigVolumes           []corev1.Volume
	ConfigLazyRenderedVolumes map[string]corev1.VolumeMount
	// 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
	VolumeHandle(ctx context.Context, event fsnotify.Event) error
	MountPoint() []string
}
    func CreateCombinedHandler ¶
func CreateCombinedHandler(config string, backupPath string) (ConfigHandler, error)
func CreateExecHandler ¶
func CreateExecHandler(command []string, mountPoint string, configMeta *ConfigSpecInfo, backupPath string) (ConfigHandler, error)
func CreateSignalHandler ¶
func CreateSignalHandler(sig appsv1beta1.SignalType, processName string, mountPoint string) (ConfigHandler, error)
func CreateTPLScriptHandler ¶
func CreateTPLScriptHandler(name, configPath string, dirs []string, backupPath string) (ConfigHandler, error)
type ConfigLazyRenderedMeta ¶
type ConfigLazyRenderedMeta struct {
	*appsv1alpha1.ComponentConfigSpec `json:",inline"`
	// secondary template path
	Templates       []string                     `json:"templates"`
	FormatterConfig appsv1beta1.FileFormatConfig `json:"formatterConfig"`
}
    type ConfigMapVolumeWatcher ¶
type ConfigMapVolumeWatcher struct {
	// contains filtered or unexported fields
}
    func NewVolumeWatcher ¶
func NewVolumeWatcher(volume []string, ctx context.Context, logger *zap.SugaredLogger) *ConfigMapVolumeWatcher
func (*ConfigMapVolumeWatcher) AddFilter ¶
func (w *ConfigMapVolumeWatcher) AddFilter(filter NotifyEventFilter) *ConfigMapVolumeWatcher
func (*ConfigMapVolumeWatcher) AddHandler ¶
func (w *ConfigMapVolumeWatcher) AddHandler(handler WatchEventHandler) *ConfigMapVolumeWatcher
func (*ConfigMapVolumeWatcher) Close ¶
func (w *ConfigMapVolumeWatcher) Close() error
func (*ConfigMapVolumeWatcher) Run ¶
func (w *ConfigMapVolumeWatcher) Run() error
func (*ConfigMapVolumeWatcher) SetRetryCount ¶
func (w *ConfigMapVolumeWatcher) SetRetryCount(count int) *ConfigMapVolumeWatcher
type ConfigSpecInfo ¶
type ConfigSpecInfo struct {
	*appsv1beta1.ReloadAction `json:",inline"`
	ReloadType      appsv1beta1.DynamicReloadType    `json:"reloadType"`
	ConfigSpec      appsv1alpha1.ComponentConfigSpec `json:"configSpec"`
	FormatterConfig appsv1beta1.FileFormatConfig     `json:"formatterConfig"`
	DownwardAPIOptions []appsv1beta1.DownwardAPIChangeTriggeredAction `json:"downwardAPIOptions"`
	// config volume mount path
	MountPoint string `json:"mountPoint"`
	TPLConfig  string `json:"tplConfig"`
}
    type ConfigSpecMeta ¶
type ConfigSpecMeta struct {
	ConfigSpecInfo `json:",inline"`
	ScriptConfig   []appsv1beta1.ScriptConfig
	ToolsImageSpec *appsv1beta1.ToolsSetup
}
    func FilterSupportReloadActionConfigSpecs ¶ added in v0.8.4
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 - TPLScriptType trigger or 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 []appsv1alpha1.ComponentConfigSpec, cli client.Client, ctx context.Context) ([]ConfigSpecMeta, error)
type DynamicParamUpdater ¶
type DynamicParamUpdater interface {
	ExecCommand(ctx context.Context, command string, args ...string) (string, error)
	Close()
}
    DynamicParamUpdater is designed to adapt to the dapper implementation.
func NewCommandChannel ¶
func NewCommandChannel(ctx context.Context, dataType, dsn string) (DynamicParamUpdater, error)
type DynamicUpdater ¶
type DynamicUpdater = func(ctx context.Context, configSpec string, updatedParams map[string]string) error
func OnlineUpdateParamsHandle ¶
func OnlineUpdateParamsHandle(tplScriptPath string, formatConfig *appsv1beta1.FileFormatConfig, dataType, dsn string) (DynamicUpdater, error)
type NotifyEventFilter ¶
func CreateCfgRegexFilter ¶
func CreateCfgRegexFilter(regexString string) (NotifyEventFilter, error)
func CreateValidConfigMapFilter ¶
func CreateValidConfigMapFilter() NotifyEventFilter
CreateValidConfigMapFilter processes configmap volume https://github.com/ossrs/srs/issues/1635
type TPLScriptConfig ¶
type TPLScriptConfig struct {
	Scripts   string `json:"scripts"`
	FileRegex string `json:"fileRegex"`
	DataType  string `json:"dataType"`
	DSN       string `json:"dsn"`
	FormatterConfig appsv1beta1.FileFormatConfig `json:"formatterConfig"`
}