Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import (
)

var (
sharedNamespace = "stackrox"
sharedNamespace = "stackrox"
imagePreLoadCommand string
)

func newDeployCmd(settings *deployer.Config) *cobra.Command {
Expand All @@ -51,6 +52,8 @@ Examples:
cmd.Flags().StringVar(&shell, "shell", "", "Shell to spawn after Central deployment")

cmd.Flags().StringVar(&envrc, "envrc", "", "Write environment to file instead of spawning sub-shell")
cmd.Flags().StringVar(&imagePreLoadCommand, "image-preload-command", "",
"Use custom command for pre-loading images to local cluster. Image can be referenced as $IMAGE.")

registerFlag(cmd, settings, "olm", "Deploy operator via OLM (requires OLM installed)",
withNoOptDefVal("true"),
Expand Down Expand Up @@ -321,6 +324,35 @@ func runDeploy(cmd *cobra.Command, args []string) error {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Minute)
defer cancel()

// If we are deploying to a local cluster and the images exist locally, then we transfer them
// to the local cluster.
if deploySettings.Roxie.ClusterType.IsLocal() && !deploySettings.Roxie.KonfluxImages {
var preLoader deployer.ImagePreLoader
if imagePreLoadCommand != "" {
preLoader = deployer.NewCustomImagePreloader(ctx, log, imagePreLoadCommand)
} else {
preLoader, err = d.GetPreLoaderForCluster()
if err != nil && !errors.Is(err, deployer.ErrLocalImagesUnsupported) {
return fmt.Errorf("obtaining image preloader for cluster: %w", err)
}
// ErrLocalImagesUnsupported indicates that roxie does not contain preloading
// support for the respective cluster type. If preloading is required (because
// the images do not exist on the remote registry), the user needs to take care
// of the preloading.
}
if preLoader == nil {
log.Warningf("Image preloading not supported for cluster %s.", d.GetKubeContext())
log.Warningf("Use --image-preload-command for specifying custom image preloading mechanism.")
} else {
log.Dimf("Using image pre-loader %q", preLoader.Name())

if err := d.TryTransferLocalImages(ctx, preLoader); err != nil {
// Best effort, keep running.
log.Warningf("Transferring images to local cluster failed: %v", err)
}
}
}

if components.IncludesCentral() {
d.PrintCentralDeploymentSummary()
}
Expand Down Expand Up @@ -366,6 +398,9 @@ func configureConfig(log *logger.Logger, components component.Component, deployS
deploySettings.Roxie.ClusterType = clusterType
}
clusterType := deploySettings.Roxie.ClusterType
centralDeployLocally := components.IncludesCentral() && clusterType.IsLocal()
sensorDeployLocally := components.IncludesSensor() && clusterType.IsLocal()

defaults, err := clusterdefaults.ApplyClusterDefaults(deploySettings)
if err != nil {
return err
Expand All @@ -381,11 +416,18 @@ func configureConfig(log *logger.Logger, components component.Component, deployS
log.Dimf("Selecting resource profile %v for Central", profile)
deploySettings.Central.ResourceProfile = profile
}
if centralDeployLocally && deploySettings.Central.ResourceProfile == types.ResourceProfileAcsDefaults {
log.Warning("You are deploying Central to a local cluster, it is recommended to specify a resource profile (or --resources=auto)")
}

if deploySettings.SecuredCluster.ResourceProfile == types.ResourceProfileAuto {
profile := clusterdefaults.ResolveAutoResourceProfile(clusterType)
log.Dimf("Selecting resource profile %v for SecuredCluster", profile)
deploySettings.SecuredCluster.ResourceProfile = profile
}
if sensorDeployLocally && deploySettings.SecuredCluster.ResourceProfile == types.ResourceProfileAcsDefaults {
log.Warning("You are deploying SecuredCluster to a local cluster, it is recommended to specify a resource profile (or --resources=auto)")
}

// We need to do this regardless of whether the operator is deployed or not, because
// this includes the transformation of StackRox main image tags to semver compatible versions,
Expand Down
38 changes: 33 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,44 @@ require (
dario.cat/mergo v1.0.2
github.com/fatih/color v1.19.0
github.com/google/go-containerregistry v0.21.5
github.com/moby/moby/client v0.4.0
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/stretchr/testify v1.11.1
golang.org/x/term v0.42.0
golang.org/x/term v0.43.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/apimachinery v0.35.3
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4
)

require github.com/moby/moby/api v1.54.1 // indirect

require (
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/errdefs v1.0.0 // indirect
github.com/containerd/errdefs/pkg v0.3.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker v28.5.2+incompatible
github.com/docker/go-connections v0.6.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/sys/atomicwriter v0.1.0 // indirect
github.com/morikuni/aec v1.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
go.opentelemetry.io/otel v1.44.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.44.0 // indirect
go.opentelemetry.io/otel/metric v1.44.0 // indirect
go.opentelemetry.io/otel/sdk v1.44.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.44.0 // indirect
go.opentelemetry.io/otel/trace v1.44.0 // indirect
)

require (
github.com/Masterminds/semver/v3 v3.5.0
github.com/containerd/stargz-snapshotter/estargz v0.18.2 // indirect
Expand All @@ -38,12 +67,11 @@ require (
github.com/vbatts/tar-split v0.12.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/net v0.55.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.43.0 // indirect
golang.org/x/text v0.35.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.37.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gotest.tools/v3 v3.5.2 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
Expand Down
Loading
Loading