Documentation
¶
Index ¶
- func RetryKubernetesOperation(operation func() error) error
- type CRDWatcher
- type Manager
- type ManagerImpl
- func (m *ManagerImpl) AddWorkload(workload common.Workload) error
- func (m *ManagerImpl) Cleanup()
- func (m *ManagerImpl) GetAllStatuses() map[string]common.WorkloadStatus
- func (m *ManagerImpl) GetAllWorkloads() map[string]common.Workload
- func (m *ManagerImpl) GetWorkload(name string) (common.Workload, bool)
- func (m *ManagerImpl) GetWorkloadManager(workloadType common.WorkloadType) WorkloadManager
- func (m *ManagerImpl) GetWorkloadManagers() (res []WorkloadManager)
- func (m *ManagerImpl) RemoveWorkload(name string) error
- func (m *ManagerImpl) StartAll(ctx context.Context) error
- func (m *ManagerImpl) StopAll(ctx context.Context) error
- type WorkloadConfig
- type WorkloadFactory
- type WorkloadManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CRDWatcher ¶
type CRDWatcher struct {
// contains filtered or unexported fields
}
CRDWatcher watches for workload CRD changes
func NewCRDWatcher ¶
func NewCRDWatcher( dynamicClient dynamic.Interface, k8sClient kubernetes.Interface, manager Manager, metrics *monitoring.ControllerMetrics, monitoringServer *monitoring.MonitoringServer, ) *CRDWatcher
NewCRDWatcher creates a new CRD watcher
func (*CRDWatcher) OnCRDAdd ¶
func (w *CRDWatcher) OnCRDAdd(obj interface{})
OnCRDAdd handles CRD addition events
func (*CRDWatcher) OnCRDDelete ¶
func (w *CRDWatcher) OnCRDDelete(obj interface{})
OnCRDDelete handles CRD deletion events
func (*CRDWatcher) OnCRDUpdate ¶
func (w *CRDWatcher) OnCRDUpdate(oldObj, newObj interface{})
OnCRDUpdate handles CRD update events
type Manager ¶
type Manager interface {
// StartAll starts all workloads
StartAll(ctx context.Context) error
// StopAll stops all workloads
StopAll(ctx context.Context) error
// AddWorkload adds a workload to the manager
AddWorkload(workload common.Workload) error
// RemoveWorkload removes a workload from the manager
RemoveWorkload(name string) error
// GetWorkload gets a workload by name
GetWorkload(name string) (common.Workload, bool)
// GetAllWorkloads gets all workloads
GetAllWorkloads() map[string]common.Workload
// GetAllStatuses gets the status of all workloads
GetAllStatuses() map[string]common.WorkloadStatus
// GetWorkloadManagers returns underlying workload managers
GetWorkloadManagers() []WorkloadManager
// GetWorkloadManager returns underlying workload manager by type
GetWorkloadManager(workloadType common.WorkloadType) WorkloadManager
// Cleanup performs cleanup when the manager is being shut down
Cleanup()
}
Manager defines the interface for managing workloads in k8-highlander. It provides methods for starting, stopping, adding, removing, and querying workloads of various types. This interface allows for different implementations of workload management while maintaining a consistent API.
func InitializeWorkloadManagers ¶
func InitializeWorkloadManagers(_ context.Context, client kubernetes.Interface, cfg *common.AppConfig, metrics *monitoring.ControllerMetrics, monitoringServer *monitoring.MonitoringServer) (Manager, error)
InitializeWorkloadManagers creates and configures all workload managers for different types of workloads (processes, cron jobs, services, persistent sets). It registers each manager with the main workload manager.
Parameters:
- ctx: Context for cancellation
- k8sClient: Kubernetes client interface
- cfg: Application configuration with workload definitions
- metrics: Metrics collector for the controller
- monitoringServer: Monitoring server for status reporting
Returns:
- workloads.Manager: Configured workload manager with all workload types registered
- error: Error if any workload manager fails to initialize
type ManagerImpl ¶
type ManagerImpl struct {
// contains filtered or unexported fields
}
ManagerImpl implements the Manager interface
func NewManager ¶
func NewManager(metrics *monitoring.ControllerMetrics, monitoringServer *monitoring.MonitoringServer) *ManagerImpl
NewManager creates a new workload manager
func (*ManagerImpl) AddWorkload ¶
func (m *ManagerImpl) AddWorkload(workload common.Workload) error
AddWorkload adds a workload to the manager
func (*ManagerImpl) Cleanup ¶
func (m *ManagerImpl) Cleanup()
Cleanup performs cleanup when the manager is being shut down
func (*ManagerImpl) GetAllStatuses ¶
func (m *ManagerImpl) GetAllStatuses() map[string]common.WorkloadStatus
GetAllStatuses gets the status of all workloads
func (*ManagerImpl) GetAllWorkloads ¶
func (m *ManagerImpl) GetAllWorkloads() map[string]common.Workload
GetAllWorkloads gets all workloads
func (*ManagerImpl) GetWorkload ¶
func (m *ManagerImpl) GetWorkload(name string) (common.Workload, bool)
GetWorkload gets a workload by name
func (*ManagerImpl) GetWorkloadManager ¶
func (m *ManagerImpl) GetWorkloadManager(workloadType common.WorkloadType) WorkloadManager
func (*ManagerImpl) GetWorkloadManagers ¶
func (m *ManagerImpl) GetWorkloadManagers() (res []WorkloadManager)
func (*ManagerImpl) RemoveWorkload ¶
func (m *ManagerImpl) RemoveWorkload(name string) error
RemoveWorkload removes a workload from the manager
type WorkloadConfig ¶
type WorkloadConfig struct {
Type common.WorkloadType `json:"type"`
Name string `json:"name"`
Config map[string]interface{} `json:"config"`
}
WorkloadConfig represents a generic workload configuration that can be used to create any type of workload. It contains the common fields needed for all workloads and a type-specific configuration map.
type WorkloadFactory ¶
type WorkloadFactory struct {
// contains filtered or unexported fields
}
WorkloadFactory creates workloads from configuration files or programmatic definitions. It handles the complexity of parsing different configuration formats and instantiating the appropriate workload implementations.
func NewWorkloadFactory ¶
func NewWorkloadFactory(configDir string, metrics *monitoring.ControllerMetrics, monitoringServer *monitoring.MonitoringServer) *WorkloadFactory
NewWorkloadFactory creates a new workload factory
func (*WorkloadFactory) CreateWorkload ¶
func (f *WorkloadFactory) CreateWorkload(config WorkloadConfig, client kubernetes.Interface) (common.Workload, error)
CreateWorkload instantiates a specific workload based on its type and configuration. It handles the conversion of generic configuration to type-specific structures and delegates to the appropriate workload constructors.
func (*WorkloadFactory) LoadWorkloadsFromConfig ¶
func (f *WorkloadFactory) LoadWorkloadsFromConfig(manager Manager, client kubernetes.Interface) error
LoadWorkloadsFromConfig scans the configuration directory for workload definition files and loads them into the provided workload manager. It supports YAML, YML, and JSON file formats.
type WorkloadManager ¶
type WorkloadManager interface {
// Start initializes the manager and starts all registered workloads.
Start(ctx context.Context) error
// Stop gracefully terminates all managed Process workloads, ensuring proper cleanup of resources.
Stop(ctx context.Context) error
// GetStatus returns the status of the manager
GetStatus() common.WorkloadStatus
// GetName returns the name of the workload
GetName() string
// GetType returns the type of the workload
GetType() common.WorkloadType
// AddWorkload adds a workload from the manager
AddWorkload(config any) error
// RemoveWorkload removes a workload from the manager
RemoveWorkload(name string) error
// GetWorkload finds a workload from the manager
GetWorkload(name string) (common.Workload, bool)
// GetWorkloadsWithCRD returns all workloads from the manager
GetWorkloadsWithCRD() []common.Workload
}
WorkloadManager defines an interface for workload specific manager.