Documentation
¶
Index ¶
- Variables
- type MaintenanceState
- type Package
- type Service
- func (s *Service) Cleanup(ctx context.Context, keep map[string]struct{}, ignoreNamespaces ...string)
- func (s *Service) Delete(ctx context.Context, namespace, name string) error
- func (s *Service) HasMonitor(name string) bool
- func (s *Service) PauseMonitor(name string)
- func (s *Service) RemoveMonitor(name string)
- func (s *Service) Render(ctx context.Context, namespace string, pkg Package) (string, error)
- func (s *Service) ResumeMonitor(name string)
- func (s *Service) StopMonitors()
- func (s *Service) Upgrade(ctx context.Context, namespace string, pkg Package) error
Constants ¶
This section is empty.
Variables ¶
var ErrPackageNotHelm = errors.New("package not helm")
Functions ¶
This section is empty.
Types ¶
type MaintenanceState ¶ added in v1.77.0
type MaintenanceState string
MaintenanceState is the reconciliation mode requested for a package. The zero value (Managed) reconciles normally; it mirrors ModuleConfig maintenance.
const ( // Managed reconciles the package's resources normally. Managed MaintenanceState = "" // NoResourceReconciliation stops reconciling the package's resources: the Helm // release is left untouched, resource monitoring is disabled, and resources are // labeled so they can be edited by hand. NoResourceReconciliation MaintenanceState = "NoResourceReconciliation" )
type Package ¶
type Package interface {
GetName() string
GetPath() string
GetRuntimeValues() string
GetValues() addonutils.Values
// GetMaintenance reports the package's maintenance mode; the package itself
// decides whether its resources must be reconciled.
GetMaintenance() MaintenanceState
}
Package provides access to package data needed for Helm operations.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages Helm release lifecycle via nelm client. It provides upgrade, deletion, and rendering operations.
func NewService ¶
func NewService(kubeClient *klient.Client, callback drift.AbsentCallback, status *status.Service, logger *log.Logger) *Service
NewService creates a new nelm service for managing Helm releases.
func (*Service) Cleanup ¶ added in v1.76.1
func (s *Service) Cleanup(ctx context.Context, keep map[string]struct{}, ignoreNamespaces ...string)
Cleanup uninstalls releases owned by this service (carrying the managed-by annotation) whose name is not in keep. keep keys are "<namespace>/<release-name>".
func (*Service) Delete ¶
Delete uninstalls a Helm release by name. This removes all resources created by the release from the cluster.
Returns error if the release doesn't exist or deletion fails.
func (*Service) HasMonitor ¶
HasMonitor checks if a release monitor exists for the given name.
func (*Service) PauseMonitor ¶
PauseMonitor pauses resource readiness checks for a release monitor. Requires an equal number of ResumeMonitor calls to unpause.
func (*Service) RemoveMonitor ¶
RemoveMonitor stops and removes a release monitor. No-op if the monitor doesn't exist.
func (*Service) Render ¶
Render renders a Helm chart with the provided values and returns the manifests. This is useful for validating charts or previewing what will be installed.
Process:
- Verify the path contains a valid Helm chart
- Create temporary values file
- Render chart using nelm client
- Return rendered YAML manifests
Returns ErrPackageNotHelm if the path doesn't contain a valid Helm chart.
func (*Service) ResumeMonitor ¶
ResumeMonitor decrements the pause counter for a release monitor. The monitor resumes checking resources when the counter reaches zero.
func (*Service) StopMonitors ¶
func (s *Service) StopMonitors()
StopMonitors gracefully shuts down all release monitors.
func (*Service) Upgrade ¶
Upgrade installs or upgrades a Helm release for a package.
Smart upgrade logic:
- Renders chart and calculates manifest checksum
- Checks if upgrade is needed (new install, status, checksum, missing resources)
- Skips upgrade if nothing changed (optimization)
- Starts resource monitoring after successful install/upgrade
Process:
- Verify package contains a Helm chart
- Create temporary values file from package values
- Render chart to get manifests
- Calculate manifest checksum
- Check if upgrade is needed
- Install/upgrade release if needed
- Start or verify resource monitoring
Maintenance (state == NoResourceReconciliation): once the release is marked as under maintenance the upgrade is skipped and resource monitoring is dropped, so config/hook changes are not reconciled and deleted resources are not restored. Resources are stamped with the maintenance label so the deckhouse admission policy stops guarding them against manual edits.
Returns ErrPackageNotHelm if the package doesn't contain a valid Helm chart.