Updating Go-based Operator projects for newer Operator SDK versions

OKD 4.13 supports Operator SDK 1.28.0. If you already have the 1.25.4 CLI installed on your workstation, you can update the CLI to 1.28.0 by installing the latest version.

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

Updating Go-based Operator projects for Operator SDK 1.28.0

The following procedure updates an existing Go-based Operator project for compatibility with 1.28.0.

Prerequisites

  • Operator SDK 1.28.0 installed

  • An Operator project created or maintained with Operator SDK 1.25.4

Procedure

  1. Find the ose-kube-rbac-proxy pull spec in the following files, and update the image tag to v4.13:

    • config/default/manager_auth_proxy_patch.yaml

    • bundle/manifests/memcached-operator.clusterserviceversion.yaml

    1. containers:
    2. - name: kube-rbac-proxy
    3. image: registry.redhat.io/openshift4/ose-kube-rbac-proxy:v4.13 (1)
    1Update the tag version from v4.12 to v4.13.
  2. Modify your go.mod file to include the following dependencies and updated versions:

    1. k8s.io/api v0.26.2
    2. k8s.io/apiextensions-apiserver v0.26.2
    3. k8s.io/apimachinery v0.26.2
    4. k8s.io/cli-runtime v0.26.2
    5. k8s.io/client-go v0.26.2
    6. k8s.io/kubectl v0.26.2
    7. sigs.k8s.io/controller-runtime v0.14.5
    8. sigs.k8s.io/controller-tools v0.11.3
    9. sigs.k8s.io/kubebuilder/v3 v3.9.1
  3. Download the latest dependencies by running the following command:

    1. $ go mod tidy
  4. Modify your Makefile with the following changes:

    1. Change the ENVTEST_K8S_VERSION field from 1.25 to 1.26.

    2. Change the build target from generate fmt vet to manifests generate fmt vet:

      1. - build: generate fmt vet ## Build manager binary.
      2. + build: manifests generate fmt vet ## Build manager binary.

Additional resources