Updating Hybrid Helm-based 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 Hybrid Helm-based Operator projects for Operator SDK v1.25.0

The following procedure updates an existing Hybrid Helm-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
  3. To update Go and its dependencies, make the following changes to your go.mod file:

    1. go 1.19 (1)
    2. require (
    3. github.com/onsi/ginkgo/v2 v2.1.4 (2)
    4. github.com/onsi/gomega v1.19.0 (3)
    5. k8s.io/api v0.25.0 (4)
    6. k8s.io/apimachinery v0.25.0 (4)
    7. k8s.io/client-go v0.25.0 (4)
    8. sigs.k8s.io/controller-runtime v0.13.0 (5)
    9. )
    1Update version 1.18 to 1.19.
    2Update version v1.16.5 to v2.1.4.
    3Update version v1.18.1 to v1.19.0.
    4Update version v0.24.0 to v0.25.0.
    5Update version v0.12.1 to v0.13.0.
  4. To download the updated versions, clean up the dependencies, and apply the changes in your go.mod file, run the following command:

    1. $ go mod tidy

Additional resources