Skip to content

Latest commit

 

History

History
159 lines (115 loc) · 5.29 KB

DEVELOPMENT.md

File metadata and controls

159 lines (115 loc) · 5.29 KB

Developing the IM Operator

Prerequisites

To build this project, you will need the following:

  1. Go 1.16 or greater
  2. operator-sdk
  3. A container CLI like Podman or Docker

Build Dependencies

The Makefile is structured such that other dependencies of this project are obtained as they are needed by running go install or curl to download and install these dependencies to the bin directory of this project. The versions of these dependencies are pinned via defaulted variables within the Makefile. If you would like to run with different versions of these dependencies, install them to this project's bin directory and export the variables associated with each custom version. These variables are as follows:

  • kustomize:
    • KUSTOMIZE: path to kustomize binary
    • KUSTOMIZE_VERSION: version of kustomize installed
  • yq:
    • YQ: path to yq binary
    • YQ_VERSION: version of yq installed
  • controller-gen:
    • CONTROLLER_GEN: path to controller-gen binary
    • CONTROLLER_TOOLS_VERSION: version of controller-gen installed
  • Go:
    • GO_VERSION: version of go installed

Building Artifacts

Environment Variables

These environment variables impact the resulting build artifacts and can be changed to affect the output of the build:

  • IMG: The base name of the Operator image
  • REGISTRY: The registry namespace; used for Operator image builds
  • IMAGE_TAG_BASE: The registry namespace and part of the image name; used for Operator bundle image builds
  • GIT_COMMIT_ID: The short commit SHA for the HEAD of the current branch; used for image labels and single-arch image tags
  • GIT_REMOTE_URL: The URL of the git remote for this project; used for image labels
  • CONTAINER_CLI: The container tool for builds and other image-related activities
  • VERSION: The version of the Operator; used for the bundle image, multi-arch manifest, and catalog image tags
  • BUILD_LOCALLY: Skips pushing the images when set to "1" for targets where Operator images are built
  • MODE: When set to "dev", runs bundle-related targets using development-only copies of overlays and Dockerfiles

Operator Binary

Running make build builds the Operator binary for the host OS and architecture.

Operator Images

Single-Arch Images

To build an Operator image for a single architecture only, run one of the following:

  • For amd64:

    make build-image-amd64
  • For ppc64le:

    make build-image-ppc64le
  • For s390x:

    make build-image-s390x

Multi-Arch Images

To build an Operator image for each architecture as well as a multi-arch manifest, run the following target:

make images

Operator Bundles

The Operator bundle is generated by using a variety of tools to create and fill out the templates in the config directory. To generate the Operator bundle based upon the configuration and code present, run the following:

make bundle

Bundle Development Targets

In order to allow for development-only changes to the kustomizations and config without touching the prod kustomization overlays, you can generate a new set of development-only overlays by running the following:

make dev-overlays

This make target will copy the contents of the prod overlays into new set of dev overlay directories. A common use case is updating the Operand images to point to pre-prod references; this can be achieved by editing the image_env_vars_patch.yaml to use whichever images references you want for the Operands.

Once all of the desired changes have been made, you can create a new Operator bundle using the dev overlays by running the following:

MODE=dev make bundle

When running the above make target, it will also replace the Operator image reference in the manager manifest with ${IMAGE_TAG_BASE}:${VERSION}. These variables default to the production registry reference and latest Operator version tag respectively, but setting these variables allows you to build and push Operator images to different registries and image tags. Note that these variables are used for other make targets as well and can affect their output; see Environment Variables for more.

Finally, to build a dev bundle image, run the following target:

MODE=dev make bundle-build

Updating the Project's Version

To set the version of the project to a new SemVer, run the following:

# NEW_VERSION is the desired SemVer to set across source and artifacts, e.g. 4.9.0
VERSION="${NEW_VERSION:-}" make update-version

This will update all image tags, the production kustomize overlays, and the version set in version.go with the SemVer value of VERSION. After this target completes successfully, you should also run make bundle to update the latest production bundle with these new version values.

Cleaning Up

There may come a point at which you would like to remove old manager binaries, dev kustomize overlays, and downloaded build tools to clear the way for new ones to be written. This can be done by running the following target:

make clean