Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save noseka1/9b4033f10392c9285d87e3f9e402f810 to your computer and use it in GitHub Desktop.
Save noseka1/9b4033f10392c9285d87e3f9e402f810 to your computer and use it in GitHub Desktop.
How to approve OpenShift operator upgrade using CLI

Install the operator using the Manual approval strategy, see the attached screenshot.

An install plan has been created but not executed as it has not been approved:

oc get installplan -n openshift-logging
NAME            CSV                                    APPROVAL   APPROVED
install-dq68d   clusterlogging.4.5.0-202007012112.p0   Manual     false
$ oc get installplan -n openshift-logging -o yaml
apiVersion: v1
items:
- apiVersion: operators.coreos.com/v1alpha1
  kind: InstallPlan
  metadata:
    creationTimestamp: "2020-07-14T00:02:42Z"
    generateName: install-
    generation: 1
    name: install-dq68d
    namespace: openshift-logging
    ownerReferences:
    - apiVersion: operators.coreos.com/v1alpha1
      blockOwnerDeletion: false
      controller: false
      kind: Subscription
      name: cluster-logging
      uid: 4d6cffb5-9bcf-40ca-b88b-fef829d21051
    resourceVersion: "3483661"
    selfLink: /apis/operators.coreos.com/v1alpha1/namespaces/openshift-logging/installplans/install-dq68d
    uid: 570a99f9-212c-4b0b-8c9d-aefda026ceda
  spec:
    approval: Manual
    approved: false
    clusterServiceVersionNames:
    - clusterlogging.4.5.0-202007012112.p0
    generation: 1
    
    ....

Approve the installation of the operator by updating the approved field of the InstallPlan:

$ oc patch installplan install-dq68d \
    --namespace openshift-logging \
    --type merge \
    --patch '{"spec":{"approved":true}}'

Check that the operator has been installed:

$ oc get csv -n openshift-logging
NAME                                   DISPLAY                  VERSION                 REPLACES   PHASE
clusterlogging.4.5.0-202007012112.p0   Cluster Logging          4.5.0-202007012112.p0              Succeeded
@TiloGit
Copy link

TiloGit commented Jan 7, 2022

here how to find the one which need to be approved:

##find which one need approval
oc get ip -n my-project -o=jsonpath='{.items[?(@.spec.approved==false)].metadata.name}'
#here how to approve all (if batch approval is desired
oc patch installplan $(oc get ip -n my-project-o=jsonpath='{.items[?(@.spec.approved==false)].metadata.name}') -n my-project --type merge --patch '{"spec":{"approved":true}}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment