deployer

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultCentralWaitTimeout        = 20 * time.Minute
	DefaultSecuredClusterWaitTimeout = 20 * time.Minute

	// AdminUsername is the default admin username for StackRox Central
	AdminUsername = "admin"
)
View Source
var (
	ErrLocalImagesUnsupported          = errors.New("cluster does not support deploying with local images")
	ErrLocalImageRetrievalNotSupported = errors.New("image pre-loader does not support retrieval of images available on the cluster")
)
View Source
var AllOperatorNamespaces = []string{
	operatorNamespaceSystem,
	operatorNamespaceCentral,
	operatorNamespaceSensor,
}

AllOperatorNamespaces lists every namespace where roxie may deploy an operator.

Functions

func ParseFeatureFlags

func ParseFeatureFlags(flags []string) (map[string]bool, error)

ParseFeatureFlags parses a slice of feature flag strings and returns a map of flag names to boolean values. Supports formats: +ROX_FOO (enable), -ROX_FOO (disable), ROX_FOO=true, ROX_FOO=false, ROX_FOO (enable)

func ParseOperatorEnvVar added in v0.4.2

func ParseOperatorEnvVar(envExpr string) (string, string, error)

ParseOperatorEnvVar parses a single KEY=VALUE environment variable string. Values may contain '=' characters (only the first '=' is used as the separator).

Types

type AddOn added in v0.4.6

type AddOn interface {
	Name() string
	Priority() uint
	Deploy(ctx context.Context) error
	Teardown(ctx context.Context) error
	IsOptional() bool
}

AddOn is the resolved runtime representation of an add-on that can be deployed alongside ACS. Implementations handle type-specific install and uninstall logic (e.g. Helm charts).

type AddOnConfig added in v0.4.6

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

AddOnConfig carries runtime dependencies (logger, verbosity) needed to construct add-on instances.

type CentralAddOnDefinition added in v0.4.6

type CentralAddOnDefinition struct {
	CommonAddOnProperties `yaml:",inline"`

	StackRoxRepoHelmChart *StackRoxRepoHelmChartAddOn `yaml:"stackroxRepoHelmChart,omitempty"`
	HelmChart             *HelmChartRepoAddOn         `yaml:"helmChart,omitempty"`
}

CentralAddOnDefinition describes an add-on that can be deployed alongside Central.

type CentralConfig

type CentralConfig struct {
	// Operator allows per-component operator overrides; only used in dual-operator mode.
	Operator            OperatorInstanceConfig `yaml:"operator,omitempty"`
	Namespace           string                 `yaml:"namespace,omitempty"`
	ResourceProfile     types.ResourceProfile  `yaml:"resourceProfile,omitempty"`
	PauseReconciliation *bool                  `yaml:"pauseReconciliation,omitempty"`
	Exposure            *types.Exposure        `yaml:"exposure,omitempty"`
	DeployTimeout       time.Duration          `yaml:"deployTimeout,omitempty"`
	PortForwarding      *bool                  `yaml:"portForwarding,omitempty"`
	EarlyReadiness      *bool                  `yaml:"earlyReadiness,omitempty"`
	Spec                map[string]interface{} `yaml:"spec,omitempty"`

	AddOns          map[string]bool                   `yaml:"addOns,omitempty"`
	AvailableAddOns map[string]CentralAddOnDefinition `yaml:"availableAddOns,omitempty"`
}

CentralConfig holds deployment settings for the Central component.

func DefaultCentralConfig

func DefaultCentralConfig() CentralConfig

DefaultCentralConfig returns a CentralConfig with sensible defaults.

func NewCentralConfig added in v0.4.2

func NewCentralConfig() CentralConfig

NewCentralConfig returns an emptry CentralConfig, with deep initialization of data structures.

func (*CentralConfig) ConfigureSpec

func (c *CentralConfig) ConfigureSpec(roxieConfig *RoxieConfig) error

ConfigureSpec applies feature flags and exposure settings to the Central spec.

func (*CentralConfig) CustomResource

func (c *CentralConfig) CustomResource() (map[string]interface{}, error)

CustomResource builds an unstructured Central custom resource from this config.

func (*CentralConfig) EarlyReadinessEnabled added in v0.4.1

func (c *CentralConfig) EarlyReadinessEnabled() bool

func (*CentralConfig) EarlyReadinessSet added in v0.4.2

func (c *CentralConfig) EarlyReadinessSet() bool

func (*CentralConfig) ExposureEnabled

func (c *CentralConfig) ExposureEnabled() bool

func (*CentralConfig) ExposureSet

func (c *CentralConfig) ExposureSet() bool

func (*CentralConfig) GetExposure

func (c *CentralConfig) GetExposure() types.Exposure

func (*CentralConfig) GetWaitConfig

func (c *CentralConfig) GetWaitConfig() WaitConfig

func (*CentralConfig) PauseReconciliationEnabled added in v0.4.2

func (c *CentralConfig) PauseReconciliationEnabled() bool

func (*CentralConfig) PauseReconciliationSet added in v0.4.2

func (c *CentralConfig) PauseReconciliationSet() bool

func (*CentralConfig) PortForwardingEnabled

func (c *CentralConfig) PortForwardingEnabled() bool

func (*CentralConfig) PortForwardingSet

func (c *CentralConfig) PortForwardingSet() bool

type CommonAddOnProperties added in v0.4.6

type CommonAddOnProperties struct {
	Optional bool `yaml:"optional,omitempty"`
	Priority uint `yaml:"priority,omitempty"`
}

CommonAddOnProperties are shared fields embedded in every add-on definition.

type Config

type Config struct {
	Roxie          RoxieConfig          `yaml:"roxie,omitempty"`
	Operator       OperatorConfig       `yaml:"operator,omitempty"`
	Central        CentralConfig        `yaml:"central,omitempty"`
	SecuredCluster SecuredClusterConfig `yaml:"securedCluster,omitempty"`
}

Config is the top-level deployment configuration, combining settings for roxie itself, the operator, Central, and SecuredCluster.

func DefaultConfig added in v0.4.2

func DefaultConfig() Config

DefaultConfig returns a Config populated with default values.

func NewConfig

func NewConfig() Config

NewConfig returns a Config populated with default values.

func (*Config) CentralVersion added in v0.4.6

func (c *Config) CentralVersion() imagetag.MainTag

CentralVersion returns the main image tag for Central. Uses central.operator.version if set, otherwise falls back to operator.version.

func (*Config) DeepCopy

func (c *Config) DeepCopy() (*Config, error)

DeepCopy creates a deep-copy of the provided config using a YAML marshaling/unmarshaling roundtrip. Due the `omitempty`, this causes empty values (e.g. empty maps) from being discarded (replace with nil in the resulting copy).

func (*Config) HasMixedVersions added in v0.4.6

func (c *Config) HasMixedVersions() bool

HasMixedVersions reports whether Central and SecuredCluster use different operator versions. This is true when at least one component has a per-component operator config with a version that differs from the other component's effective version.

func (*Config) NewestOperatorInstance added in v0.4.6

func (c *Config) NewestOperatorInstance() OperatorInstanceConfig

NewestOperatorInstance returns the operator instance with the highest version. This is used to determine which bundle to use for CRD installation, since CRDs are cluster-scoped and must be at the newest version.

func (*Config) NewestOperatorVersion added in v0.4.6

func (c *Config) NewestOperatorVersion() imagetag.OperatorTag

NewestOperatorVersion returns the highest operator tag across all planned instances.

func (*Config) OperatorInstances added in v0.4.6

func (c *Config) OperatorInstances() []OperatorInstanceConfig

OperatorInstances builds the operator deployment plan for this config. When versions match, a single operator is deployed to rhacs-operator-system. When they differ, two operators are deployed with reconciler toggles.

func (*Config) SecuredClusterVersion added in v0.4.6

func (c *Config) SecuredClusterVersion() imagetag.MainTag

SecuredClusterVersion returns the main image tag for SecuredCluster. Uses securedCluster.operator.version if set, otherwise falls back to operator.version.

type Deployer

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

Deployer is the base deployer for ACS

func New

func New(log *logger.Logger) (*Deployer, error)

New creates a new Deployer instance. It verifies that the current environment contains necessary tools. It creates a temporary directory for the deployer to use during deployment, and it is the caller's responsibility to clean it up using the Cleanup() method when not used anymore.

func (*Deployer) AddOnConfiguration added in v0.4.6

func (d *Deployer) AddOnConfiguration() AddOnConfig

AddOnConfiguration builds an AddOnConfig from the deployer's runtime state.

func (*Deployer) Cleanup

func (d *Deployer) Cleanup()

Cleanup cleans up any temporary resources created by the deployer, such as temporary files.

func (*Deployer) Deploy

func (d *Deployer) Deploy(ctx context.Context, components component.Component) error

Deploy deploys the specified components to the cluster.

func (*Deployer) GetCentralDeploymentInfo

func (d *Deployer) GetCentralDeploymentInfo() types.CentralDeploymentInfo

func (*Deployer) GetContainerRuntimeSocket added in v0.4.2

func (d *Deployer) GetContainerRuntimeSocket() string

func (*Deployer) GetKubeContext added in v0.4.2

func (d *Deployer) GetKubeContext() string

func (*Deployer) GetPreLoaderForCluster added in v0.4.2

func (d *Deployer) GetPreLoaderForCluster() (ImagePreLoader, error)

GetPreLoaderForCluster returns an ImagePreLoader suited for the detected cluster type, or ErrLocalImagesUnsupported if the cluster does not support it.

func (*Deployer) PrintCentralDeploymentSummary

func (d *Deployer) PrintCentralDeploymentSummary()

func (*Deployer) PrintSecuredClusterDeploymentSummary

func (d *Deployer) PrintSecuredClusterDeploymentSummary()

TODO(#91): plenty of code in common with the central variant that should probably be extracted

func (*Deployer) ResolveEnabledAddOns added in v0.4.6

func (d *Deployer) ResolveEnabledAddOns() ([]AddOn, error)

ResolveEnabledAddOns returns the enabled add-ons sorted by descending priority (name for ties at zero).

func (*Deployer) SetConfig

func (d *Deployer) SetConfig(config Config)

func (*Deployer) SetEnvrcFile

func (d *Deployer) SetEnvrcFile(path string)

func (*Deployer) SetVerbose

func (d *Deployer) SetVerbose(verbose bool)

func (*Deployer) Teardown

func (d *Deployer) Teardown(ctx context.Context, components component.Component) error

func (*Deployer) TryTransferLocalImages added in v0.4.2

func (d *Deployer) TryTransferLocalImages(ctx context.Context, preLoader ImagePreLoader) error

TryTransferLocalImages sends locally available ACS images to the cluster via the given pre-loader, skipping images already present in the cluster.

func (*Deployer) WaitForCentral

func (d *Deployer) WaitForCentral(timeout time.Duration) bool

WaitForCentral waits for Central to be ready and responding on its endpoint Returns true if Central is ready, false if timeout occurs

type HAProxyConfig added in v0.4.4

type HAProxyConfig struct {
	Disabled *bool `yaml:"disabled"`
	BindPort int   `yaml:"bindPort"`
}

func (*HAProxyConfig) Enabled added in v0.4.4

func (c *HAProxyConfig) Enabled() bool

type HelmChartRepoAddOn added in v0.4.6

type HelmChartRepoAddOn struct {
	Repo            string `yaml:"repo,omitempty"`
	Chart           string `yaml:"chart,omitempty"`
	Version         string `yaml:"version,omitempty"`
	HelmChartValues `yaml:",inline"`
}

HelmChartRepoAddOn references a chart in a public Helm repository.

func (*HelmChartRepoAddOn) New added in v0.4.6

func (h *HelmChartRepoAddOn) New(
	addOnCfg AddOnConfig,
	commonProperties CommonAddOnProperties,
	name, namespace string) (AddOn, error)

New creates a helmAddOn that installs a chart from a public Helm repository.

type HelmChartValues added in v0.4.6

type HelmChartValues struct {
	Values     string `yaml:"values,omitempty"`
	ValuesFile string `yaml:"valuesFile,omitempty"`
	EnvSubst   bool   `yaml:"envSubst,omitempty"`
}

HelmChartValues holds inline or file-based Helm values with optional environment variable substitution.

func (*HelmChartValues) GetValues added in v0.4.6

func (h *HelmChartValues) GetValues() (map[string]any, error)

GetValues resolves the Helm values from either inline YAML or a file, applying envsubst if enabled.

type ImagePreLoader added in v0.4.2

type ImagePreLoader interface {
	SendImage(ctx context.Context, imageTag string) error
	GetImages(ctx context.Context) ([]string, error)
	Name() string
}

ImagePreLoader transfers container images into a local cluster's image store.

func NewCustomImagePreloader added in v0.4.2

func NewCustomImagePreloader(_ context.Context, log *logger.Logger, command string) ImagePreLoader

type OperatorConfig

type OperatorConfig struct {
	SkipDeployment         *bool `yaml:"skipDeployment,omitempty"`
	DeployViaOlm           *bool `yaml:"deployViaOlm,omitempty"`
	OperatorInstanceConfig `yaml:",inline"`
}

OperatorConfig is the top-level operator configuration used in single-operator mode.

func (*OperatorConfig) Configure

func (c *OperatorConfig) Configure(roxieConfig *RoxieConfig) error

Configure derives the operator version from the roxie configuration.

func (*OperatorConfig) DeployViaOlmEnabled added in v0.4.2

func (c *OperatorConfig) DeployViaOlmEnabled() bool

func (*OperatorConfig) DeployViaOlmSet added in v0.4.2

func (c *OperatorConfig) DeployViaOlmSet() bool

func (*OperatorConfig) SkipDeploymentEnabled added in v0.4.2

func (c *OperatorConfig) SkipDeploymentEnabled() bool

func (*OperatorConfig) SkipDeploymentSet added in v0.4.2

func (c *OperatorConfig) SkipDeploymentSet() bool

type OperatorDeploymentMode

type OperatorDeploymentMode bool

OperatorDeploymentMode represents how the operator is deployed

const (
	OperatorModeNonOLM OperatorDeploymentMode = false
	OperatorModeOLM    OperatorDeploymentMode = true
)

type OperatorInstanceConfig added in v0.4.6

type OperatorInstanceConfig struct {
	Version       imagetag.MainTag  `yaml:"version,omitempty"`
	EnvVars       map[string]string `yaml:"envVars,omitempty"`
	KonfluxImages *bool             `yaml:"konfluxImages,omitempty"`

	// The following fields are computed internally and are not user-configurable.
	Namespace      string `yaml:"-"`
	RoleNameSuffix string `yaml:"-"`
}

OperatorInstanceConfig describes how to deploy a single operator instance. In the common single-operator mode, the top-level OperatorConfig (which embeds this) is used directly. In mixed-operator mode, CentralConfig.Operator and SecuredClusterConfig.Operator override the top-level defaults.

func (*OperatorInstanceConfig) BundleImage added in v0.4.6

func (c *OperatorInstanceConfig) BundleImage() string

BundleImage returns the operator bundle image for this operator instance.

func (*OperatorInstanceConfig) ClusterRoleBindingName added in v0.4.6

func (c *OperatorInstanceConfig) ClusterRoleBindingName() string

ClusterRoleBindingName returns the ClusterRoleBinding name for this operator instance.

func (*OperatorInstanceConfig) ClusterRoleName added in v0.4.6

func (c *OperatorInstanceConfig) ClusterRoleName() string

ClusterRoleName returns the ClusterRole name for this operator instance.

func (*OperatorInstanceConfig) KonfluxImagesEnabled added in v0.4.6

func (c *OperatorInstanceConfig) KonfluxImagesEnabled() bool

func (*OperatorInstanceConfig) KonfluxImagesSet added in v0.4.6

func (c *OperatorInstanceConfig) KonfluxImagesSet() bool

func (*OperatorInstanceConfig) OperatorImage added in v0.4.6

func (c *OperatorInstanceConfig) OperatorImage() string

type ResourceToDelete

type ResourceToDelete struct {
	Kind      string
	Name      string
	OwnerName string
}

type RoxieConfig

type RoxieConfig struct {
	Version       imagetag.MainTag  `yaml:"version,omitempty"`
	KonfluxImages *bool             `yaml:"konfluxImages,omitempty"`
	FeatureFlags  map[string]bool   `yaml:"featureFlags,omitempty"`
	ClusterType   types.ClusterType `yaml:"clusterType,omitempty"`
	HAProxy       HAProxyConfig     `yaml:"haProxy,omitempty"`
}

RoxieConfig holds roxie-level settings such as version and feature flags.

func DefaultRoxieConfig added in v0.4.4

func DefaultRoxieConfig() RoxieConfig

func NewRoxieConfig

func NewRoxieConfig() RoxieConfig

NewRoxieConfig returns a RoxieConfig with initialized defaults.

func (*RoxieConfig) KonfluxImagesEnabled added in v0.4.2

func (c *RoxieConfig) KonfluxImagesEnabled() bool

func (*RoxieConfig) KonfluxImagesSet added in v0.4.2

func (c *RoxieConfig) KonfluxImagesSet() bool

type SecuredClusterConfig

type SecuredClusterConfig struct {
	// Operator allows per-component operator overrides; only used in dual-operator mode.
	Operator            OperatorInstanceConfig `yaml:"operator,omitempty"`
	Namespace           string                 `yaml:"namespace,omitempty"`
	ResourceProfile     types.ResourceProfile  `yaml:"resourceProfile,omitempty"`
	PauseReconciliation *bool                  `yaml:"pauseReconciliation,omitempty"`
	DeployTimeout       time.Duration          `yaml:"deployTimeout,omitempty"`
	EarlyReadiness      *bool                  `yaml:"earlyReadiness,omitempty"`
	Spec                map[string]interface{} `yaml:"spec,omitempty"`
}

SecuredClusterConfig holds deployment settings for the SecuredCluster component.

func DefaultSecuredClusterConfig

func DefaultSecuredClusterConfig() SecuredClusterConfig

DefaultSecuredClusterConfig returns a SecuredClusterConfig with sensible defaults.

func NewSecuredClusterConfig added in v0.4.2

func NewSecuredClusterConfig() SecuredClusterConfig

NewSecuredClusterConfig returns an emptry SecuredClusterConfig, with deep initialization of data structures.

func (*SecuredClusterConfig) ConfigureSpec

func (s *SecuredClusterConfig) ConfigureSpec(roxieConfig *RoxieConfig, centralConfig *CentralConfig) error

ConfigureSpec applies feature flags and the central endpoint to the SecuredCluster spec.

func (*SecuredClusterConfig) CustomResource

func (s *SecuredClusterConfig) CustomResource() (map[string]interface{}, error)

CustomResource builds an unstructured SecuredCluster custom resource from this config.

func (*SecuredClusterConfig) EarlyReadinessEnabled added in v0.4.1

func (s *SecuredClusterConfig) EarlyReadinessEnabled() bool

func (*SecuredClusterConfig) EarlyReadinessSet added in v0.4.2

func (s *SecuredClusterConfig) EarlyReadinessSet() bool

func (*SecuredClusterConfig) GetWaitConfig

func (s *SecuredClusterConfig) GetWaitConfig() WaitConfig

func (*SecuredClusterConfig) PauseReconciliationEnabled added in v0.4.2

func (s *SecuredClusterConfig) PauseReconciliationEnabled() bool

func (*SecuredClusterConfig) PauseReconciliationSet added in v0.4.2

func (s *SecuredClusterConfig) PauseReconciliationSet() bool

type StackRoxRepoHelmChartAddOn added in v0.4.6

type StackRoxRepoHelmChartAddOn struct {
	Path            string `yaml:"path,omitempty"`
	HelmChartValues `yaml:",inline"`
}

StackRoxRepoHelmChartAddOn locates a Helm chart within the stackrox repository. All paths are relative to the repository root.

func (*StackRoxRepoHelmChartAddOn) New added in v0.4.6

func (h *StackRoxRepoHelmChartAddOn) New(
	addOnCfg AddOnConfig,
	commonProperties CommonAddOnProperties,
	name, namespace string,
) (AddOn, error)

New creates a helmAddOn that installs a chart from a local stackrox repository checkout.

type WaitConfig

type WaitConfig struct {
	Namespace      string
	EarlyReadiness bool
	WaitFor        string
	Timeout        time.Duration
}

WaitConfig describes how to wait for a component to become ready.

Jump to

Keyboard shortcuts

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