×

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

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

Updating Helm-based Operator projects for Operator SDK 1.25.4

The following procedure updates an existing Helm-based Operator project for compatibility with 1.25.4.

Prerequisites
  • Operator SDK 1.25.4 installed

  • An Operator project created or maintained with Operator SDK 1.22.2

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

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: controller-manager
      namespace: system
    spec:
      template:
        spec:
          containers:
          - name: kube-rbac-proxy
            image: registry.redhat.io/openshift4/ose-kube-rbac-proxy:v4.12 (1)
            args:
            - "--secure-listen-address=0.0.0.0:8443"
            - "--upstream=http://127.0.0.1:8080/"
            - "--logtostderr=true"
            - "--v=0"
    ...
    1 Update 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
      # PLATFORMS defines the target platforms for  the manager image be build to provide support to multiple
      # architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
      # - able to use docker buildx . More info: https://docs.docker.com/build/buildx/
      # - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/
      # - 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)
      # To properly provided solutions that supports more than one platform you should use this option.
      PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
      .PHONY: docker-buildx
      docker-buildx: test ## Build and push docker image for the manager for cross-platform support
      	# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
      	sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
      	- docker buildx create --name project-v3-builder
      	docker buildx use project-v3-builder
      	- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross
      	- docker buildx rm project-v3-builder
      	rm Dockerfile.cross
    2. To enable support for 64-bit ARM architectures in your Operator project, make the following changes to your Makefile:

      Old Makefile
      OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
      ARCH := $(shell uname -m | sed 's/x86_64/amd64/')
      New Makefile
      OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
      ARCH := $(shell uname -m | sed 's/x86_64/amd64/' |  sed 's/aarch64/arm64/')
    3. Update the Kustomize version to v4.5.5 as shown in the following example:

      Old Makefile
      .PHONY: kustomize
      KUSTOMIZE = $(shell pwd)/bin/kustomize
      kustomize: ## Download kustomize locally if necessary.
      ifeq (,$(wildcard $(KUSTOMIZE)))
      ifeq (,$(shell which kustomize 2>/dev/null))
      	@{ \
      	set -e ;\
      	mkdir -p $(dir $(KUSTOMIZE)) ;\
      	curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v3.8.7/kustomize_v3.8.7_$(OS)_$(ARCH).tar.gz | \
      	tar xzf - -C bin/ ;\
      	}
      else
      New Makefile
      .PHONY: kustomize
      KUSTOMIZE = $(shell pwd)/bin/kustomize
      kustomize: ## Download kustomize locally if necessary.
      ifeq (,$(wildcard $(KUSTOMIZE)))
      ifeq (,$(shell which kustomize 2>/dev/null))
      	@{ \
      	set -e ;\
      	mkdir -p $(dir $(KUSTOMIZE)) ;\
      	curl -sSLo - https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.5/kustomize_v4.5.5_$(OS)_$(ARCH).tar.gz | \ (1)
      	tar xzf - -C bin/ ;\
      	}
      else
      1 Update version v3.8.7 to v4.5.5.

      Kustomize version 4.0.0 removed the go-getter plugin and introduced breaking changes that are not backwards compatible with earlier versions. Operator projects that rely on older versions of Kustomize might not work with newer releases.

    4. To apply the changes to your Makefile and rebuild your Operator, enter the following command:

      $ make
  3. Update the image tag in your Operator’s Dockerfile as shown in the following example:

    Example Dockerfile
    FROM registry.redhat.io/openshift4/ose-helm-operator:v4.12 (1)
    1 Update the version tag to v4.12.
  4. Update your config/default/kustomizations.yaml file as shown in the following examples:

    Example kustomizations.yaml file
    # Adds namespace to all resources.
    namespace: memcached-operator-system
    # Value of this field is prepended to the
    # names of all resources, e.g. a deployment named
    # "wordpress" becomes "alices-wordpress".
    # Note that it should also match with the prefix (text before '-') of the namespace
    # field above.
    namePrefix: memcached-operator-
    
    # Labels to add to all resources and selectors.
    #labels: (1)
    #- includeSelectors: true (2)
    #  pairs:
    #    someName: someValue
    
    resources: (3)
    - ../crd
    - ../rbac
    - ../manager
    1 Replace the commonLabels field with the labels field.
    2 Add includeSelectors: true.
    3 Replace the bases field with the resources field.