Updating projects for newer Operator SDK versions

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

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

Updating Ansible-based Operator projects for Operator SDK 1.31.0

The following procedure updates an existing Ansible-based Operator project for compatibility with 1.31.0.

Prerequisites

  • Operator SDK 1.31.0 installed

  • An Operator project created or maintained with Operator SDK 1.28.0

Procedure

  1. Make the following changes to your Operator’s Dockerfile:

    1. Replace the ansible-operator-2.11-preview base image with the ansible-operator base image and update the version to 1.31.0, as shown in the following example:

      Example Dockerfile

      1. FROM quay.io/operator-framework/ansible-operator:v1.31.0
    2. The update to Ansible 2.15.0 in version 1.30.0 of the Ansible Operator removed the following preinstalled Python modules:

      • ipaddress

      • openshift

      • jmespath

      • cryptography

      • oauthlib

      If your Operator depends on one of these removed Python modules, update your Dockerfile to install the required modules using the pip install command.

  2. Edit your Operator project’s makefile to update the Operator SDK version to 1.31.0, as shown in the following example:

    Example makefile

    1. # Set the Operator SDK version to use. By default, what is installed on the system is used.
    2. # This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
    3. OPERATOR_SDK_VERSION ?= v1.31.0 (1)
    1Change the version from {osdk_ver-n1} to 1.31.0.
  3. Update your requirements.yaml and requirements.go files to remove the community.kubernetes collection and update the operator_sdk.util collection to version 0.5.0, as shown in the following example:

    Example requirements.yaml file

    1. collections:
    2. - - name: community.kubernetes (1)
    3. - version: "2.0.1"
    4. - name: operator_sdk.util
    5. - version: "0.4.0"
    6. + version: "0.5.0" (2)
    7. - name: kubernetes.core
    8. version: "2.4.0"
    9. - name: cloud.common
    1Remove the community.kubernetes collection
    2Update the operator_sdk.util collection to version 0.5.0.
  4. Remove all instances of the lint field from your molecule/kind/molecule.yml and molecule/default/molecule.yml files, as shown in the following example:

    1. ---
    2. dependency:
    3. name: galaxy
    4. driver:
    5. name: delegated
    6. - lint: |
    7. - set -e
    8. - yamllint -d "{extends: relaxed, rules: {line-length: {max: 120}}}" .
    9. platforms:
    10. - name: cluster
    11. groups:
    12. - k8s
    13. provisioner:
    14. name: ansible
    15. - lint: |
    16. - set -e
    17. ansible-lint
    18. inventory:
    19. group_vars:
    20. all:
    21. namespace: ${TEST_OPERATOR_NAMESPACE:-osdk-test}
    22. host_vars:
    23. localhost:
    24. ansible_python_interpreter: '{{ ansible_playbook_python }}'
    25. config_dir: ${MOLECULE_PROJECT_DIRECTORY}/config
    26. samples_dir: ${MOLECULE_PROJECT_DIRECTORY}/config/samples
    27. operator_image: ${OPERATOR_IMAGE:-""}
    28. operator_pull_policy: ${OPERATOR_PULL_POLICY:-"Always"}
    29. kustomize: ${KUSTOMIZE_PATH:-kustomize}
    30. env:
    31. K8S_AUTH_KUBECONFIG: ${KUBECONFIG:-"~/.kube/config"}
    32. verifier:
    33. name: ansible
    34. - lint: |
    35. - set -e
    36. - ansible-lint

Additional resources