Skip to content

Commit

Permalink
Make run bundle init image choosable (#6605)
Browse files Browse the repository at this point in the history
The forced use of the image docker.io/library/busybox causes issues for
users making use of operator-sdk run bundle. Dockerhub rate limits
container image pulls. The rate limiting will cause operator-sdk run
bundle to fail once `run bundle` has been used too many times within a
time period.

This is being fixed by adding the `--decompression-image` argument to
the command. The command will still default to using the same image,
but a user can override this using the argument.

Signed-off-by: Sebastian Soto <[email protected]>
  • Loading branch information
sebsoto authored Oct 19, 2023
1 parent b9e5817 commit 46e04a1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions internal/olm/fbcutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const (
// DefaultIndexImage is the index base image used if none is specified. It contains no bundles.
// TODO(v2.0.0): pin this image tag to a specific version.
DefaultIndexImage = DefaultIndexImageBase + "latest"
// DefaultInitImage is the default image to be used in the registry init container
DefaultInitImage = "docker.io/library/busybox:1.36.0"
)

// BundleDeclcfg represents a minimal File-Based Catalog.
Expand Down
3 changes: 3 additions & 0 deletions internal/olm/operator/bundle/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func NewInstall(cfg *operator.Configuration) Install {

func (i *Install) BindFlags(fs *pflag.FlagSet) {
fs.StringVar(&i.IndexImage, "index-image", fbcutil.DefaultIndexImage, "index image in which to inject bundle")
fs.StringVar(&i.InitImage, "decompression-image", fbcutil.DefaultInitImage, "image used in an init container in "+
"the registry pod to decompress the compressed catalog contents. cat and gzip binaries are expected to exist "+
"in the PATH")
fs.Var(&i.InstallMode, "install-mode", "install mode")

// --mode is hidden so only users who know what they're doing can alter add mode.
Expand Down
5 changes: 4 additions & 1 deletion internal/olm/operator/registry/fbcindex/fbc_registry_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ type FBCRegistryPod struct { //nolint:maligned
// new version of an operator bundle when published can be added to an index image
IndexImage string

// InitImage is the image to be used in the registry init container
InitImage string

// GRPCPort is the container grpc port
GRPCPort int32

Expand Down Expand Up @@ -349,7 +352,7 @@ func (f *FBCRegistryPod) addGZIPInitContainer(containerVolumeMount []corev1.Volu
initContainerVolumeMount := append(containerVolumeMount, gzipVolumeMount...)
f.pod.Spec.InitContainers = append(f.pod.Spec.InitContainers, corev1.Container{
Name: defaultInitContainerName,
Image: "docker.io/library/busybox:1.36.0",
Image: f.InitImage,
Command: []string{
"sh",
"-c",
Expand Down
5 changes: 5 additions & 0 deletions internal/olm/operator/registry/index_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type IndexImageCatalogCreator struct {
FBCContent string
PackageName string
IndexImage string
InitImage string
BundleImage string
SecretName string
CASecretName string
Expand Down Expand Up @@ -518,12 +519,16 @@ func (c IndexImageCatalogCreator) createAnnotatedRegistry(ctx context.Context, c
if c.IndexImage == "" {
c.IndexImage = fbcutil.DefaultIndexImage
}
if c.InitImage == "" {
c.InitImage = fbcutil.DefaultInitImage
}

if c.HasFBCLabel {
// Initialize and create the FBC registry pod.
fbcRegistryPod := fbcindex.FBCRegistryPod{
BundleItems: items,
IndexImage: c.IndexImage,
InitImage: c.InitImage,
FBCContent: c.FBCContent,
SecurityContext: c.SecurityContext.String(),
}
Expand Down
1 change: 1 addition & 0 deletions website/content/en/docs/cli/operator-sdk_run_bundle.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ operator-sdk run bundle <bundle-image> [flags]

```
--ca-secret-name string Name of a generic secret containing a PEM root certificate file required to pull bundle images. This secret *must* be in the namespace that this command is configured to run in, and the file *must* be encoded under the key "cert.pem"
--decompression-image string image used in an init container in the registry pod to decompress the compressed catalog contents. cat and gzip binaries are expected to exist in the PATH (default "docker.io/library/busybox:1.36.0")
-h, --help help for bundle
--index-image string index image in which to inject bundle (default "quay.io/operator-framework/opm:latest")
--install-mode InstallModeValue install mode
Expand Down

0 comments on commit 46e04a1

Please sign in to comment.