|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * operators/operator_sdk/golang/osdk-golang-updating-projects.adoc |
| 4 | +// * operators/operator_sdk/ansible/osdk-ansible-updating-projects.adoc |
| 5 | +// * operators/operator_sdk/helm/osdk-helm-updating-projects.adoc |
| 6 | +// * operators/operator_sdk/helm/osdk-hybrid-helm-updating-projects.adoc |
| 7 | +// * operators/operator_sdk/java/osdk-java-updating-projects.adoc |
| 8 | + |
| 9 | +ifeval::["{context}" == "osdk-golang-updating-projects"] |
| 10 | +:golang: |
| 11 | +:type: Go |
| 12 | +endif::[] |
| 13 | +ifeval::["{context}" == "osdk-ansible-updating-projects"] |
| 14 | +:ansible: |
| 15 | +:type: Ansible |
| 16 | +endif::[] |
| 17 | +ifeval::["{context}" == "osdk-helm-updating-projects"] |
| 18 | +:helm: |
| 19 | +:type: Helm |
| 20 | +endif::[] |
| 21 | +ifeval::["{context}" == "osdk-hybrid-helm-updating-projects"] |
| 22 | +:hybrid: |
| 23 | +:type: Hybrid Helm |
| 24 | +endif::[] |
| 25 | +ifeval::["{context}" == "osdk-java-updating-projects"] |
| 26 | +:java: |
| 27 | +:type: Java |
| 28 | +endif::[] |
| 29 | + |
| 30 | +:_content-type: PROCEDURE |
| 31 | +[id="osdk-upgrading-projects_{context}"] |
| 32 | += Updating {type}-based Operator projects for Operator SDK {osdk_ver} |
| 33 | + |
| 34 | +The following procedure updates an existing {type}-based Operator project for compatibility with {osdk_ver}. |
| 35 | + |
| 36 | +.Prerequisites |
| 37 | + |
| 38 | +* Operator SDK {osdk_ver} installed |
| 39 | +* An Operator project created or maintained with Operator SDK {osdk_ver_n1} |
| 40 | +
|
| 41 | +.Procedure |
| 42 | + |
| 43 | +ifdef::golang,hybrid,java[] |
| 44 | +* Edit your Operator project's makefile to update the Operator SDK version to {osdk_ver}, as shown in the following example: |
| 45 | ++ |
| 46 | +.Example makefile |
| 47 | +[source,make,subs="attributes+"] |
| 48 | +---- |
| 49 | +# Set the Operator SDK version to use. By default, what is installed on the system is used. |
| 50 | +# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit. |
| 51 | +OPERATOR_SDK_VERSION ?= v{osdk_ver} <1> |
| 52 | +---- |
| 53 | +<1> Change the version from `{osdk_ver_n1}` to `{osdk_ver}`. |
| 54 | +endif::[] |
| 55 | + |
| 56 | +ifdef::helm[] |
| 57 | +. Edit your Operator's Dockerfile to update the Helm Operator version to {osdk_ver}, as shown in the following example: |
| 58 | ++ |
| 59 | +.Example Dockerfile |
| 60 | +[source,docker,subs="attributes+"] |
| 61 | +---- |
| 62 | +FROM quay.io/operator-framework/helm-operator:v{osdk_ver} <1> |
| 63 | +---- |
| 64 | +<1> Update the Helm Operator version from `{osdk_ver_n1}` to `{osdk_ver}` |
| 65 | + |
| 66 | +. Edit your Operator project's makefile to update the Operator SDK to {osdk_ver}, as shown in the following example: |
| 67 | ++ |
| 68 | +.Example makefile |
| 69 | +[source,make,subs="attributes+"] |
| 70 | +---- |
| 71 | +# Set the Operator SDK version to use. By default, what is installed on the system is used. |
| 72 | +# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit. |
| 73 | +OPERATOR_SDK_VERSION ?= v{osdk_ver} <1> |
| 74 | +---- |
| 75 | +<1> Change the version from `{osdk_ver-n1}` to `{osdk_ver}`. |
| 76 | + |
| 77 | +. If you use a custom service account for deployment, define the following role to require a watch operation on your secrets resource, as shown in the following example: |
| 78 | ++ |
| 79 | +.Example `config/rbac/role.yaml` file |
| 80 | +[source,yaml] |
| 81 | +---- |
| 82 | +apiVersion: rbac.authorization.k8s.io/v1 |
| 83 | +kind: ClusterRoleBinding |
| 84 | +metadata: |
| 85 | + name: <operator_name>-admin |
| 86 | +subjects: |
| 87 | +- kind: ServiceAccount |
| 88 | + name: <operator_name> |
| 89 | + namespace: <operator_namespace> |
| 90 | +roleRef: |
| 91 | + kind: ClusterRole |
| 92 | + name: cluster-admin |
| 93 | + apiGroup: "" |
| 94 | +rules: <1> |
| 95 | + - apiGroups: |
| 96 | + - "" |
| 97 | + resources: |
| 98 | + - secrets |
| 99 | + verbs: |
| 100 | + - watch |
| 101 | +---- |
| 102 | +<1> Add the `rules` stanza to create a watch operation for your secrets resource. |
| 103 | +endif::[] |
| 104 | + |
| 105 | +ifdef::ansible[] |
| 106 | + |
| 107 | +. Make the following changes to your Operator's Dockerfile: |
| 108 | + |
| 109 | +.. Replace the `ansible-operator-2.11-preview` base image with the `ansible-operator` base image and update the version to {osdk_ver}, as shown in the following example: |
| 110 | ++ |
| 111 | +.Example Dockerfile |
| 112 | +[source,docker,subs="attributes+"] |
| 113 | +---- |
| 114 | +FROM quay.io/operator-framework/ansible-operator:v{osdk_ver} |
| 115 | +---- |
| 116 | + |
| 117 | +.. The update to Ansible 2.15.0 in version 1.30.0 of the Ansible Operator removed the following pre-installed Python modules: |
| 118 | ++ |
| 119 | +-- |
| 120 | +* `ipaddress` |
| 121 | +* `openshift` |
| 122 | +* `jmespath` |
| 123 | +* `cryptography` |
| 124 | +* `oauthlib` |
| 125 | +-- |
| 126 | ++ |
| 127 | +If your Operator depends on one of these removed Python modules, update your Dockerfile to install the required modules using the `pip install` command. |
| 128 | + |
| 129 | +. Edit your Operator project's makefile to update the Operator SDK version to {osdk_ver}, as shown in the following example: |
| 130 | ++ |
| 131 | +.Example makefile |
| 132 | +[source,make,subs="attributes+"] |
| 133 | +---- |
| 134 | +# Set the Operator SDK version to use. By default, what is installed on the system is used. |
| 135 | +# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit. |
| 136 | +OPERATOR_SDK_VERSION ?= v{osdk_ver} <1> |
| 137 | +---- |
| 138 | +<1> Change the version from `{osdk_ver-n1}` to `{osdk_ver}`. |
| 139 | + |
| 140 | +. 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: |
| 141 | ++ |
| 142 | +.Example `requirements.yaml` file |
| 143 | +[source,diff] |
| 144 | +---- |
| 145 | + collections: |
| 146 | +- - name: community.kubernetes <1> |
| 147 | +- version: "2.0.1" |
| 148 | + - name: operator_sdk.util |
| 149 | +- version: "0.4.0" |
| 150 | ++ version: "0.5.0" <2> |
| 151 | + - name: kubernetes.core |
| 152 | + version: "2.4.0" |
| 153 | + - name: cloud.common |
| 154 | +---- |
| 155 | +<1> Remove the `community.kubernetes` collection |
| 156 | +<2> Update the `operator_sdk.util` collection to version `0.5.0`. |
| 157 | +
|
| 158 | +. 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: |
| 159 | ++ |
| 160 | +[source,diff] |
| 161 | +---- |
| 162 | + --- |
| 163 | + dependency: |
| 164 | + name: galaxy |
| 165 | + driver: |
| 166 | + name: delegated |
| 167 | +- lint: | |
| 168 | +- set -e |
| 169 | +- yamllint -d "{extends: relaxed, rules: {line-length: {max: 120}}}" . |
| 170 | + platforms: |
| 171 | + - name: cluster |
| 172 | + groups: |
| 173 | + - k8s |
| 174 | + provisioner: |
| 175 | + name: ansible |
| 176 | +- lint: | |
| 177 | +- set -e |
| 178 | + ansible-lint |
| 179 | + inventory: |
| 180 | + group_vars: |
| 181 | + all: |
| 182 | + namespace: ${TEST_OPERATOR_NAMESPACE:-osdk-test} |
| 183 | + host_vars: |
| 184 | + localhost: |
| 185 | + ansible_python_interpreter: '{{ ansible_playbook_python }}' |
| 186 | + config_dir: ${MOLECULE_PROJECT_DIRECTORY}/config |
| 187 | + samples_dir: ${MOLECULE_PROJECT_DIRECTORY}/config/samples |
| 188 | + operator_image: ${OPERATOR_IMAGE:-""} |
| 189 | + operator_pull_policy: ${OPERATOR_PULL_POLICY:-"Always"} |
| 190 | + kustomize: ${KUSTOMIZE_PATH:-kustomize} |
| 191 | + env: |
| 192 | + K8S_AUTH_KUBECONFIG: ${KUBECONFIG:-"~/.kube/config"} |
| 193 | + verifier: |
| 194 | + name: ansible |
| 195 | +- lint: | |
| 196 | +- set -e |
| 197 | +- ansible-lint |
| 198 | +---- |
| 199 | +endif::[] |
| 200 | +
|
| 201 | +
|
| 202 | +ifeval::["{context}" == "osdk-golang-updating-projects"] |
| 203 | +:!golang: |
| 204 | +:!type: |
| 205 | +endif::[] |
| 206 | +ifeval::["{context}" == "osdk-ansible-updating-projects"] |
| 207 | +:!ansible: |
| 208 | +:!type: |
| 209 | +endif::[] |
| 210 | +ifeval::["{context}" == "osdk-helm-updating-projects"] |
| 211 | +:!helm: |
| 212 | +:!type: |
| 213 | +endif::[] |
| 214 | +ifeval::["{context}" == "osdk-hybrid-helm-updating-projects"] |
| 215 | +:!hybrid: |
| 216 | +:!type: |
| 217 | +endif::[] |
| 218 | +ifeval::["{context}" == "osdk-java-updating-projects"] |
| 219 | +:!java: |
| 220 | +:!type: |
| 221 | +endif::[] |
0 commit comments