Skip to content
Closed
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
4 changes: 4 additions & 0 deletions changelog/fragments/enable-run-bundle-cmd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
entries:
- description: >
Enable `run bundle` command and include e2e tests.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Enable `run bundle` command and include e2e tests.
Add the subcommand `operato-sdk run bundle` which allows users check their project integration with OLM via the bundle.

The e2e are not relevant to end-users

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @camilamacedo86 rephrase it. I would change her suggestion a bit:

Added the run bundle subcommand which allows users to verify their operator's bundle integrates with OLM.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be sufficient:

Suggested change
Enable `run bundle` command and include e2e tests.
Added the `run bundle` command.

kind: addition
3 changes: 2 additions & 1 deletion internal/cmd/operator-sdk/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package run
import (
"github.com/spf13/cobra"

"github.com/operator-framework/operator-sdk/internal/cmd/operator-sdk/run/bundle"
"github.com/operator-framework/operator-sdk/internal/cmd/operator-sdk/run/packagemanifests"
"github.com/operator-framework/operator-sdk/internal/olm/operator"
)
Expand All @@ -34,7 +35,7 @@ Currently only the package manifests format is supported via the 'packagemanifes

cmd.AddCommand(
// TODO(joelanford): enable bundle command when implementation is complete
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO(joelanford): enable bundle command when implementation is complete

// bundle.NewCmd(cfg),
bundle.NewCmd(cfg),
Comment thread
varshaprasad96 marked this conversation as resolved.
packagemanifests.NewCmd(cfg),
)

Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/operator-sdk/run/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ var _ = Describe("Running a run command", func() {
Expect(cmd.Long).NotTo(BeNil())

subcommands := cmd.Commands()
Expect(len(subcommands)).To(Equal(1))
Expect(subcommands[0].Use).To(Equal("packagemanifests [packagemanifests-root-dir]"))
Expect(len(subcommands)).To(Equal(2))
})
})
})
13 changes: 12 additions & 1 deletion test/e2e-ansible/e2e_ansible_olm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ var _ = Describe("Integrating ansible Projects with OLM", func() {
Expect(err).NotTo(HaveOccurred())
}

By("running the operator bundle using `run bundle` command")
runBundleCmd := exec.Command(tc.BinaryName, "run", "bundle", bundleImage, "--namespace", tc.Kubectl.Namespace)
_, err = tc.Run(runBundleCmd)
Expect(err).NotTo(HaveOccurred())

By("destroying the Operator deployed with the 'run' subcommand")
cleanupPkgManCmd := exec.Command(tc.BinaryName, "cleanup", projectName,
"--timeout", "4m")
_, err = tc.Run(cleanupPkgManCmd)
Expect(err).NotTo(HaveOccurred())

By("adding the 'packagemanifests' rule to the Makefile")
err = tc.AddPackagemanifestsTarget()
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -122,7 +133,7 @@ var _ = Describe("Integrating ansible Projects with OLM", func() {
}

By("destroying the deployed package manifests-formatted operator")
cleanupPkgManCmd := exec.Command(tc.BinaryName, "cleanup", projectName,
cleanupPkgManCmd = exec.Command(tc.BinaryName, "cleanup", projectName,
"--timeout", "4m")
_, err = tc.Run(cleanupPkgManCmd)
Expect(err).NotTo(HaveOccurred())
Expand Down
49 changes: 34 additions & 15 deletions test/e2e-go/e2e_go_olm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"encoding/json"
"os/exec"
"path/filepath"
"strings"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand All @@ -27,6 +26,10 @@ import (
testutils "github.com/operator-framework/operator-sdk/test/internal"
)

var (
runBundleImg = "quay.io/vnarsing/run-bundle-test-img:v1"
)

var _ = Describe("Integrating Go Projects with OLM", func() {
Context("with operator-sdk", func() {
const operatorVersion = "0.0.1"
Expand All @@ -44,24 +47,37 @@ var _ = Describe("Integrating Go Projects with OLM", func() {
// Turn off interactive prompts for all generation tasks.
replace := "operator-sdk generate kustomize manifests"
testutils.ReplaceInFile(filepath.Join(tc.Dir, "Makefile"), replace, replace+" --interactive=false")
err := tc.Make("bundle", "IMG="+tc.ImageName)

// Specifying stable channel.
// work around for Bug 1883377 - opm fails with FOREIGN KEY constraint when bundle default channel is empty
replace = "operator-sdk generate bundle"
testutils.ReplaceInFile(filepath.Join(tc.Dir, "Makefile"), replace, replace+" --default-channel stable --channels stable")
err := tc.Make("bundle")
Expect(err).NotTo(HaveOccurred())

By("building the operator bundle image")
// Use the existing image tag but with a "-bundle" suffix.
imageSplit := strings.SplitN(tc.ImageName, ":", 2)
bundleImage := imageSplit[0] + "-bundle"
if len(imageSplit) == 2 {
bundleImage += ":" + imageSplit[1]
}
err = tc.Make("bundle-build", "BUNDLE_IMG="+bundleImage)
err = tc.Make("bundle-build", "BUNDLE_IMG="+runBundleImg)
Expect(err).NotTo(HaveOccurred())

if isRunningOnKind() {
By("loading the bundle image into Kind cluster")
err = tc.LoadImageToKindClusterWithName(bundleImage)
Expect(err).NotTo(HaveOccurred())
}
_, err = tc.Kubectl.Command("create", "namespace", tc.Kubectl.Namespace)
Expect(err).NotTo(HaveOccurred())

// bundle image should be present in the remote repository in run bundle
// implementation.
By("push the image to a remote repository")
err = tc.Make("docker-push", "IMG="+runBundleImg)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you're reverting this change @varshaprasad96?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@estroz no, afaik the image has to be pushed otherwise run bundle can't seem to pull the code.

Expect(err).NotTo(HaveOccurred())

By("running the operator bundle using `run bundle` command")
runBundleCmd := exec.Command(tc.BinaryName, "run", "bundle", runBundleImg, "--namespace", tc.Kubectl.Namespace, "--timeout", "4m")
_, err = tc.Run(runBundleCmd)
Expect(err).NotTo(HaveOccurred())

By("destroying the Operator deployed with the 'run' subcommand")
cleanupPkgManCmd := exec.Command(tc.BinaryName, "cleanup", projectName,
"--timeout", "4m")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are running the bundle in a specific namespace. The ns that. is created for the operator (project-system).
Should not the cleanup be done with the ns as well?

_, err = tc.Run(cleanupPkgManCmd)
Expect(err).NotTo(HaveOccurred())

Comment thread
varshaprasad96 marked this conversation as resolved.
By("adding the 'packagemanifests' rule to the Makefile")
err = tc.AddPackagemanifestsTarget()
Expand Down Expand Up @@ -127,10 +143,13 @@ var _ = Describe("Integrating Go Projects with OLM", func() {
}

By("destroying the deployed package manifests-formatted operator")
cleanupPkgManCmd := exec.Command(tc.BinaryName, "cleanup", projectName,
cleanupPkgManCmd = exec.Command(tc.BinaryName, "cleanup", projectName,
"--timeout", "4m")
_, err = tc.Run(cleanupPkgManCmd)
Expect(err).NotTo(HaveOccurred())

_, err = tc.Kubectl.Command("delete", "namespace", tc.Kubectl.Namespace)
Expect(err).NotTo(HaveOccurred())
})
})
})
13 changes: 12 additions & 1 deletion test/e2e-helm/e2e_helm_olm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ var _ = Describe("Integrating Helm Projects with OLM", func() {
Expect(err).NotTo(HaveOccurred())
}

By("running the operator bundle using `run bundle` command")
runBundleCmd := exec.Command(tc.BinaryName, "run", "bundle", bundleImage, "--namespace", tc.Kubectl.Namespace)
_, err = tc.Run(runBundleCmd)
Expect(err).NotTo(HaveOccurred())

By("destroying the Operator deployed with the 'run' subcommand")
cleanupPkgManCmd := exec.Command(tc.BinaryName, "cleanup", projectName,
"--timeout", "4m")
_, err = tc.Run(cleanupPkgManCmd)
Expect(err).NotTo(HaveOccurred())

By("adding the 'packagemanifests' rule to the Makefile")
err = tc.AddPackagemanifestsTarget()
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -97,7 +108,7 @@ var _ = Describe("Integrating Helm Projects with OLM", func() {
Expect(err).NotTo(HaveOccurred())

By("destroying the deployed package manifests-formatted operator")
cleanupPkgManCmd := exec.Command(tc.BinaryName, "cleanup", projectName,
cleanupPkgManCmd = exec.Command(tc.BinaryName, "cleanup", projectName,
"--timeout", "4m")
_, err = tc.Run(cleanupPkgManCmd)
Expect(err).NotTo(HaveOccurred())
Expand Down
1 change: 1 addition & 0 deletions website/content/en/docs/cli/operator-sdk_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ Currently only the package manifests format is supported via the 'packagemanifes
### SEE ALSO

* [operator-sdk](../operator-sdk) - Development kit for building Kubernetes extensions and tools.
* [operator-sdk run bundle](../operator-sdk_run_bundle) - Deploy an Operator in the bundle format with OLM
* [operator-sdk run packagemanifests](../operator-sdk_run_packagemanifests) - Deploy an Operator in the package manifests format with OLM

36 changes: 36 additions & 0 deletions website/content/en/docs/cli/operator-sdk_run_bundle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: "operator-sdk run bundle"
---
## operator-sdk run bundle

Deploy an Operator in the bundle format with OLM

### Synopsis

Deploy an Operator in the bundle format with OLM

```
operator-sdk run bundle <bundle-image> [flags]
```

### Options

```
--index-image string index image in which to inject bundle (default "quay.io/operator-framework/upstream-opm-builder:latest")
--install-mode InstallModeValue install mode
--timeout duration install timeout (default 2m0s)
--kubeconfig string Path to the kubeconfig file to use for CLI requests.
-n, --namespace string If present, namespace scope for this CLI request
-h, --help help for bundle
```

### Options inherited from parent commands

```
--verbose Enable verbose logging
```

### SEE ALSO

* [operator-sdk run](../operator-sdk_run) - Run an Operator in a variety of environments