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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions changelog/fragments/inject-operator-image-olm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
entries:
- description: >
Added `IMG` argument to `bundle` make rule that accepts an operator image tag. This tag will be inserted
into the manager's deployment manifest when `make bundle IMG=<tag>` is run.
kind: change
breaking: true
migration:
header: Update your Makefile's `bundle` recipe to inject an operator image tag.
body: >
Make the following update to your Makefile's `bundle` recipe, which will allow you to set `make bundle IMG=<tag>`:

```make
bundle: ...
operator-sdk generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) # Add this line
...
```
2 changes: 2 additions & 0 deletions internal/plugins/manifests/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
# Generate bundle manifests and metadata, then validate generated files.
bundle: manifests
operator-sdk generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
operator-sdk bundle validate ./bundle
`
Expand All @@ -89,6 +90,7 @@ bundle: manifests
# Generate bundle manifests and metadata, then validate generated files.
bundle: kustomize
operator-sdk generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | operator-sdk generate bundle -q --overwrite --version $(VERSION) $(BUNDLE_METADATA_OPTS)
operator-sdk bundle validate ./bundle
`
Expand Down
20 changes: 2 additions & 18 deletions test/e2e-helm/e2e_helm_olm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package e2e_helm_test

import (
"fmt"
"os/exec"
"path"
"path/filepath"
Expand Down Expand Up @@ -50,12 +49,7 @@ var _ = Describe("Integrating Helm Projects with OLM", func() {

It("should generate and run a valid OLM bundle and packagemanifests", func() {
By("building the bundle")
err := tc.Make("bundle")
Expect(err).NotTo(HaveOccurred())

By("validating the bundle")
bundleValidateCmd := exec.Command(tc.BinaryName, "bundle", "validate", "bundle")
_, err = tc.Run(bundleValidateCmd)
err := tc.Make("bundle", "IMG="+tc.ImageName)
Expect(err).NotTo(HaveOccurred())

By("building the operator bundle image")
Expand All @@ -77,17 +71,7 @@ var _ = Describe("Integrating Helm Projects with OLM", func() {
Expect(err).Should(Succeed())

By("generating the operator package manifests")
err = tc.Make("packagemanifests")
Expect(err).NotTo(HaveOccurred())

By("updating clusterserviceversion with the manager image")
testutils.ReplaceInFile(
filepath.Join(tc.Dir, "packagemanifests", operatorVersion,
fmt.Sprintf("e2e-%s.clusterserviceversion.yaml", tc.TestSuffix)),
"controller:latest", tc.ImageName)

By("installing crds to run packagemanifests")
err = tc.Make("install")
err = tc.Make("packagemanifests", "IMG="+tc.ImageName)
Expect(err).NotTo(HaveOccurred())

By("running the package")
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/e2e_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ var _ = Describe("operator-sdk", 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")
err = tc.Make("bundle", "IMG="+tc.ImageName)
Expect(err).NotTo(HaveOccurred())

By("building the operator bundle image")
Expand Down
3 changes: 2 additions & 1 deletion test/internal/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ endif
PKG_MAN_OPTS ?= $(PKG_CHANNELS) $(PKG_IS_DEFAULT_CHANNEL)

# Generate package manifests.
packagemanifests: kustomize
packagemanifests: kustomize
operator-sdk generate kustomize manifests -q --interactive=false
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | operator-sdk generate packagemanifests -q --version $(VERSION) $(PKG_MAN_OPTS)
`

Expand Down
19 changes: 11 additions & 8 deletions website/content/en/docs/olm-integration/generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The following resource kinds are typically included in a CSV, which are addresse

You've recently run `operator-sdk init` and created your APIs with `operator-sdk create api`. Now you'd like to
package your Operator for deployment by OLM. Your Operator is at version `v0.0.1`; the `Makefile` variable `VERSION`
should be set to `0.0.1`.
should be set to `0.0.1`. You've also built your operator image, `quay.io/<user>/memcached-operator:v0.0.1`.

### Bundle format

Expand Down Expand Up @@ -141,6 +141,7 @@ PKG_MAN_OPTS ?= $(FROM_VERSION) $(PKG_CHANNELS) $(PKG_IS_DEFAULT_CHANNEL)
# Generate package manifests.
packagemanifests: kustomize manifests
operator-sdk generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | operator-sdk generate packagemanifests -q --version $(VERSION) $(PKG_MAN_OPTS)
```

Expand All @@ -162,13 +163,14 @@ PKG_MAN_OPTS ?= $(FROM_VERSION) $(PKG_CHANNELS) $(PKG_IS_DEFAULT_CHANNEL)
# Generate package manifests.
packagemanifests: kustomize
operator-sdk generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUSTOMIZE) build config/manifests | operator-sdk generate packagemanifests -q --version $(VERSION) $(PKG_MAN_OPTS)
```

By default `make packagemanifests` will generate a CSV, a package manifest file, and copy CRDs in the package manifests format:

```console
$ make packagemanifests
$ make packagemanifests IMG=quay.io/<user>/memcached-operator:v0.0.1
$ tree ./packagemanifests
./packagemanifests
├── 0.0.1
Expand All @@ -185,13 +187,13 @@ and added a port to your manager Deployment in `config/manager/manager.yaml`.
If using a bundle format, the current version of your CSV can be updated by running:

```console
$ make bundle
$ make bundle IMG=quay.io/<user>/memcached-operator:v0.0.1
```

If using a package manifests format, run:

```console
$ make packagemanifests
$ make packagemanifests IMG=quay.io/<user>/memcached-operator:v0.0.1
```

Running the command for either format will append your new CRD to `spec.customresourcedefinitions.owned`,
Expand All @@ -201,19 +203,20 @@ fields like `spec.maintainers`.

## Upgrade your Operator

Let's say you're upgrading your Operator to version `v0.0.2`, and you've already updated the `VERSION` variable
in your `Makefile` to `0.0.2`. You also want to add a new channel `beta`, and use it as the default channel.
Let's say you're upgrading your Operator to version `v0.0.2`, you've already updated the `VERSION` variable
in your `Makefile` to `0.0.2`, and built a new operator image `quay.io/<user>/memcached-operator:v0.0.2`.
You also want to add a new channel `beta`, and use it as the default channel.

If using a bundle format, a new version of your CSV can be created by running:

```console
$ make bundle CHANNELS=beta DEFAULT_CHANNEL=beta
$ make bundle CHANNELS=beta DEFAULT_CHANNEL=beta IMG=quay.io/<user>/memcached-operator:v0.0.2
```

If using a package manifests format, run:

```console
$ make packagemanifests FROM_VERSION=0.0.1 CHANNEL=beta IS_CHANNEL_DEFAULT=1
$ make packagemanifests FROM_VERSION=0.0.1 CHANNEL=beta IS_CHANNEL_DEFAULT=1 IMG=quay.io/<user>/memcached-operator:v0.0.2
```

Running the command for either format will persist user-defined fields, updates `spec.version`,
Expand Down