addon_operator

package
v1.3.12 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 45 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHelmMonitorKubeClientMetricLabels = map[string]string{"component": "helm_monitor"}

DefaultHelmMonitorKubeClientMetricLabels are labels that indicates go client metrics producer. Important! These labels should be consistent with similar labels in ShellOperator!

Functions

func ConvergeModulesInQueue added in v1.0.6

func ConvergeModulesInQueue(q *queue.TaskQueue) int

func ConvergeTasksInQueue added in v1.0.6

func ConvergeTasksInQueue(q *queue.TaskQueue) int

func DrainNonMainQueue added in v1.0.6

func DrainNonMainQueue(q *queue.TaskQueue)

func InitDefaultHelmResourcesManager added in v1.0.6

func InitDefaultHelmResourcesManager(ctx context.Context, metricStorage *metric_storage.MetricStorage) (helm_resources_manager.HelmResourcesManager, error)

func ModulesWithPendingModuleRun added in v1.0.6

func ModulesWithPendingModuleRun(q *queue.TaskQueue) map[string]struct{}

ModulesWithPendingModuleRun returns names of all modules in pending ModuleRun tasks. First task in queue considered not pending and is ignored.

func QueueHasPendingModuleRunTask

func QueueHasPendingModuleRunTask(q *queue.TaskQueue, moduleName string) bool

QueueHasPendingModuleRunTask returns true if queue has pending tasks with the type "ModuleRun" related to the module "moduleName".

func RemoveAdjacentConvergeModules added in v1.0.6

func RemoveAdjacentConvergeModules(q *queue.TaskQueue, afterId string)

RemoveAdjacentConvergeModules removes ConvergeModules tasks right after the task with the specified ID.

func RemoveCurrentConvergeTasks added in v1.0.6

func RemoveCurrentConvergeTasks(q *queue.TaskQueue, afterId string) bool

RemoveCurrentConvergeTasks detects if converge tasks present in the main queue after task which ID equals to 'afterID'. These tasks are drained and the method returns true.

func StartLiveTicksUpdater added in v1.0.6

func StartLiveTicksUpdater(metricStorage *metric_storage.MetricStorage)

func StartTasksQueueLengthUpdater added in v1.0.6

func StartTasksQueueLengthUpdater(metricStorage *metric_storage.MetricStorage, tqs *queue.TaskQueueSet)

Types

type AddonOperator

type AddonOperator struct {
	DebugServer *debug.Server

	// KubeConfigManager monitors changes in ConfigMap.
	KubeConfigManager *kube_config_manager.KubeConfigManager

	// ModuleManager is the module manager object, which monitors configuration
	// and variable changes.
	ModuleManager *module_manager.ModuleManager

	Helm *helm.ClientFactory

	// HelmResourcesManager monitors absent resources created for modules.
	HelmResourcesManager helm_resources_manager.HelmResourcesManager

	// converge state
	ConvergeState *converge.ConvergeState

	// Initial KubeConfig to bypass initial loading from the ConfigMap.
	InitialKubeConfig *config.KubeConfig

	// AdmissionServer handles validation and mutation admission webhooks
	AdmissionServer *AdmissionServer

	MetricStorage *metric_storage.MetricStorage

	// LeaderElector represents leaderelection client for HA mode
	LeaderElector *leaderelection.LeaderElector
	// contains filtered or unexported fields
}

AddonOperator extends ShellOperator with modules and global hooks and with a value storage.

func NewAddonOperator

func NewAddonOperator(ctx context.Context) *AddonOperator

func (*AddonOperator) Assemble added in v1.1.3

func (op *AddonOperator) Assemble(debugServer *debug.Server) (err error)

func (*AddonOperator) BootstrapMainQueue added in v1.0.6

func (op *AddonOperator) BootstrapMainQueue(tqs *queue.TaskQueueSet)

BootstrapMainQueue adds tasks to initiate Startup sequence:

- Run onStartup hooks. - Enable global schedule bindings. - Enable kubernetes bindings: run Synchronization tasks. - Purge unknown Helm releases. - Start reload all modules.

func (*AddonOperator) CheckConvergeStatus

func (op *AddonOperator) CheckConvergeStatus(t sh_task.Task)

CheckConvergeStatus detects if converge process is started and updates ConvergeState. It updates metrics on converge finish.

func (*AddonOperator) CreateAfterAllTasks added in v1.0.6

func (op *AddonOperator) CreateAfterAllTasks(logLabels map[string]string, eventDescription string) ([]sh_task.Task, error)

CreateAfterAllTasks returns tasks to run AfterAll global hooks.

func (*AddonOperator) CreateAndStartQueue added in v1.0.6

func (op *AddonOperator) CreateAndStartQueue(queueName string) bool

CreateAndStartQueue creates a named queue and starts it. It returns false is queue is already created

func (*AddonOperator) CreateAndStartQueuesForAllModuleHooks added in v1.0.6

func (op *AddonOperator) CreateAndStartQueuesForAllModuleHooks()

CreateAndStartQueuesForAllModuleHooks creates queues for all registered modules. It is safe to run this method multiple times, as it checks for existing queues.

func (*AddonOperator) CreateAndStartQueuesForGlobalHooks added in v1.0.6

func (op *AddonOperator) CreateAndStartQueuesForGlobalHooks()

CreateAndStartQueuesForGlobalHooks creates queues for all registered global hooks. It is safe to run this method multiple times, as it checks for existing queues.

func (*AddonOperator) CreateAndStartQueuesForModuleHooks added in v1.0.6

func (op *AddonOperator) CreateAndStartQueuesForModuleHooks(moduleName string)

CreateAndStartQueuesForModuleHooks creates queues for registered module hooks. It is safe to run this method multiple times, as it checks for existing queues.

func (*AddonOperator) CreateBeforeAllTasks added in v1.0.6

func (op *AddonOperator) CreateBeforeAllTasks(logLabels map[string]string, eventDescription string) []sh_task.Task

CreateBeforeAllTasks returns tasks to run BeforeAll global hooks.

func (*AddonOperator) CreateBootstrapTasks added in v1.0.6

func (op *AddonOperator) CreateBootstrapTasks(logLabels map[string]string) []sh_task.Task

func (*AddonOperator) CreateConvergeModulesTasks added in v1.0.6

func (op *AddonOperator) CreateConvergeModulesTasks(state *module_manager.ModulesState, logLabels map[string]string, eventDescription string) []sh_task.Task

CreateConvergeModulesTasks creates ModuleRun/ModuleDelete tasks based on moduleManager state.

func (*AddonOperator) CreatePurgeTasks added in v1.0.6

func (op *AddonOperator) CreatePurgeTasks(modulesToPurge []string, t sh_task.Task) []sh_task.Task

CreatePurgeTasks returns ModulePurge tasks for each unknown Helm release.

func (*AddonOperator) CreateReloadModulesTasks added in v1.0.6

func (op *AddonOperator) CreateReloadModulesTasks(moduleNames []string, logLabels map[string]string, eventDescription string) []sh_task.Task

func (*AddonOperator) DrainModuleQueues added in v1.0.3

func (op *AddonOperator) DrainModuleQueues(modName string)

func (*AddonOperator) HandleConvergeModules added in v1.0.6

func (op *AddonOperator) HandleConvergeModules(t sh_task.Task, logLabels map[string]string) (res queue.TaskResult)

HandleConvergeModules is a multi-phase task.

func (*AddonOperator) HandleDiscoverHelmReleases added in v1.0.6

func (op *AddonOperator) HandleDiscoverHelmReleases(t sh_task.Task, labels map[string]string) (res queue.TaskResult)

HandleDiscoverHelmReleases runs RefreshStateFromHelmReleases to detect modules state at start.

func (*AddonOperator) HandleGlobalHookEnableKubernetesBindings added in v1.0.6

func (op *AddonOperator) HandleGlobalHookEnableKubernetesBindings(t sh_task.Task, labels map[string]string) (res queue.TaskResult)

HandleGlobalHookEnableKubernetesBindings add Synchronization tasks.

func (*AddonOperator) HandleGlobalHookRun

func (op *AddonOperator) HandleGlobalHookRun(t sh_task.Task, labels map[string]string) (res queue.TaskResult)

func (*AddonOperator) HandleModuleDelete added in v1.0.6

func (op *AddonOperator) HandleModuleDelete(t sh_task.Task, labels map[string]string) (status queue.TaskStatus)

HandleModuleDelete deletes helm release for known module.

func (*AddonOperator) HandleModuleHookRun

func (op *AddonOperator) HandleModuleHookRun(t sh_task.Task, labels map[string]string) (res queue.TaskResult)

func (*AddonOperator) HandleModulePurge added in v1.0.6

func (op *AddonOperator) HandleModulePurge(t sh_task.Task, labels map[string]string) (status queue.TaskStatus)

HandleModulePurge run helm purge for unknown module.

func (*AddonOperator) HandleModuleRun

func (op *AddonOperator) HandleModuleRun(t sh_task.Task, labels map[string]string) (res queue.TaskResult)

HandleModuleRun starts a module by executing module hooks and installing a Helm chart.

Execution sequence: - Run onStartup hooks. - Queue kubernetes hooks as Synchronization tasks. - Wait until Synchronization tasks are done to fill all snapshots. - Enable kubernetes events. - Enable schedule events. - Run beforeHelm hooks - Run Helm to install or upgrade a module's chart. - Run afterHelm hooks.

ModuleRun is restarted if hook or chart is failed. After first HandleModuleRun success, no onStartup and kubernetes.Synchronization tasks will run.

func (*AddonOperator) InitModuleManager

func (op *AddonOperator) InitModuleManager() error

InitModuleManager initialize KubeConfigManager and ModuleManager, reads values from ConfigMap for the first time and sets handlers for kubernetes and schedule events.

func (*AddonOperator) IsStartupConvergeDone added in v1.0.5

func (op *AddonOperator) IsStartupConvergeDone() bool

func (*AddonOperator) KubeClient added in v1.3.0

func (op *AddonOperator) KubeClient() *client.Client

KubeClient returns default common kubernetes client initialized by shell-operator

func (*AddonOperator) RegisterDebugGlobalRoutes added in v1.1.3

func (op *AddonOperator) RegisterDebugGlobalRoutes(dbgSrv *debug.Server)

func (*AddonOperator) RegisterDebugModuleRoutes added in v1.1.3

func (op *AddonOperator) RegisterDebugModuleRoutes(dbgSrv *debug.Server)

func (*AddonOperator) RegisterDiscoveryRoute added in v1.3.4

func (op *AddonOperator) RegisterDiscoveryRoute(dbgSrv *debug.Server)

func (*AddonOperator) RegisterManagerEventsHandlers added in v1.0.6

func (op *AddonOperator) RegisterManagerEventsHandlers()

func (*AddonOperator) Setup added in v1.3.0

func (op *AddonOperator) Setup() error

func (*AddonOperator) SetupKubeConfigManager added in v1.3.0

func (op *AddonOperator) SetupKubeConfigManager(bk backend.ConfigHandler)

SetupKubeConfigManager sets manager, which reads configuration for Modules from a cluster

func (*AddonOperator) SetupModuleManager added in v1.1.3

func (op *AddonOperator) SetupModuleManager(modulesDir string, globalHooksDir string, tempDir string)

func (*AddonOperator) Start

func (op *AddonOperator) Start() error

Start runs all managers, event and queue handlers.

func (*AddonOperator) StartAPIServer added in v1.3.9

func (op *AddonOperator) StartAPIServer()

func (*AddonOperator) StartModuleManagerEventHandler

func (op *AddonOperator) StartModuleManagerEventHandler()

func (*AddonOperator) Stop

func (op *AddonOperator) Stop()

func (*AddonOperator) TaskHandler

func (op *AddonOperator) TaskHandler(t sh_task.Task) queue.TaskResult

TaskHandler handles tasks in queue.

func (*AddonOperator) UpdateFirstConvergeStatus added in v1.0.6

func (op *AddonOperator) UpdateFirstConvergeStatus(convergeTasks int)

UpdateFirstConvergeStatus checks first converge status and prints log messages if first converge is in progress.

func (*AddonOperator) UpdateWaitInQueueMetric

func (op *AddonOperator) UpdateWaitInQueueMetric(t sh_task.Task)

UpdateWaitInQueueMetric increases task_wait_in_queue_seconds_total counter for the task type. TODO pass queue name from handler, not from task

func (*AddonOperator) WithLeaderElector added in v1.3.9

func (op *AddonOperator) WithLeaderElector(config *leaderelection.LeaderElectionConfig) error

type AdmissionServer added in v1.1.4

type AdmissionServer struct {
	// contains filtered or unexported fields
}

func NewAdmissionServer added in v1.1.4

func NewAdmissionServer(listenPort, certsDir string) *AdmissionServer

func (*AdmissionServer) RegisterHandler added in v1.1.4

func (as *AdmissionServer) RegisterHandler(route string, handler http.Handler)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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