Updating projects for newer Operator SDK versions

OKD 4.12 supports Operator SDK v1.25.0. If you already have the v1.22.0 CLI installed on your workstation, you can update the CLI to v1.25.0 by installing the latest version.

However, to ensure your existing Operator projects maintain compatibility with Operator SDK v1.25.0, update steps are required for the associated breaking changes introduced since v1.22.0. You must perform the update steps manually in any of your Operator projects that were previously created or maintained with v1.22.0.

Updating Java-based Operator projects for Operator SDK v1.25.0

The following procedure updates an existing Java-based Operator project for compatibility with v1.25.0.

Prerequisites

  • Operator SDK v1.25.0 installed

  • An Operator project created or maintained with Operator SDK v1.22.0

Procedure

  1. Make the following changes to the config/default/manager_auth_proxy_patch.yaml file:

    1. apiVersion: apps/v1
    2. kind: Deployment
    3. metadata:
    4. name: controller-manager
    5. namespace: system
    6. spec:
    7. template:
    8. spec:
    9. containers:
    10. - name: kube-rbac-proxy
    11. image: registry.redhat.io/openshift4/ose-kube-rbac-proxy:v4.12 (1)
    12. args:
    13. - "--secure-listen-address=0.0.0.0:8443"
    14. - "--upstream=http://127.0.0.1:8080/"
    15. - "--logtostderr=true"
    16. - "--v=0"
    17. ...
    1Update the tag version from v4.11 to v4.12.
  2. Make the following changes to your Makefile:

    1. To enable multi-architecture build support, add the docker-buildx target to your project Makefile:

      Example Makefile

      1. # PLATFORMS defines the target platforms for the manager image be build to provide support to multiple
      2. # architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
      3. # - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
      4. # - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
      5. # - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=<myregistry/image:<tag>> than the export will fail)
      6. # To properly provided solutions that supports more than one platform you should use this option.
      7. PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
      8. .PHONY: docker-buildx
      9. docker-buildx: test ## Build and push docker image for the manager for cross-platform support
      10. # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
      11. sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
      12. - docker buildx create --name project-v3-builder
      13. docker buildx use project-v3-builder
      14. - docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross
      15. - docker buildx rm project-v3-builder
      16. rm Dockerfile.cross
    2. To apply the changes to your Makefile and rebuild your Operator, enter the following command:

      1. $ make

Additional resources