<commit_before>// Module included in the following assemblies:
//
// * applications/operators/olm-deleting-operators-to-cluster.adoc

[id="olm-deleting-operator-from-a-cluster-using-cli_{context}"]
= Deleting Operators from a cluster using the CLI

Instead of using the {product-title} web console, you can delete an Operator
from your cluster by using the CLI. You do this by deleting the Subscription and
ClusterServiceVersion from the `targetNamespace`, then editing the
CatalogSourceConfig to remove the Operator's package name.

.Prerequisites

- Access to an {product-title} cluster using an account with
ifdef::openshift-enterprise,openshift-origin[]
`cluster-admin` permissions.
endif::[]
ifdef::openshift-dedicated[]
`dedicated-admins-cluster` permissions.
endif::[]
- Install the `oc` command on your local system.

.Procedure

In this example, there are two operators (Jaeger and Descheduler) installed in the
`openshift-operators` namespace. The goal is to remove Jaeger without removing Descheduler.

. Delete the Operator's subscription (for example, `jaeger`):
+
----
$ oc delete subscription jaeger -n openshift-operators
subscription.operators.coreos.com "jaeger" deleted
----

. Check the current version of the subscribed Operator (for example, `jaeger`):
+
----
$ oc get subscription jaeger -n openshift-operators -o yaml | grep currentCSV
  currentCSV: jaeger-operator.v1.8.2
----

. Delete the CSV for the Operator (`jaeger`) in the `targetNamespace`
(`openshift-operators`):
+
----
$ oc delete clusterserviceversion jaeger-operator.v1.8.2 -n openshift-operators
clusterserviceversion.operators.coreos.com "jaeger-operator.v1.8.2" deleted
----

. Display the contents of the `CatalogSourceConfig` resource and review the list
of packages in the `spec` section:
+
----
$ oc get catalogsourceconfig -n openshift-marketplace \
    installed-community-openshift-operators -o yaml
----
+
For example, the spec section might appear as follows:
+
.Example of CatalogSourceConfig
[source,yaml]
----
spec:
  csDisplayName: Community Operators
  csPublisher: Community
  packages: jaeger,descheduler
  targetNamespace: openshift-operators
----
<commit_msg>Swap steps in deleting Operators procedure<commit_after>// Module included in the following assemblies:
//
// * applications/operators/olm-deleting-operators-to-cluster.adoc

[id="olm-deleting-operator-from-a-cluster-using-cli_{context}"]
= Deleting Operators from a cluster using the CLI

Instead of using the {product-title} web console, you can delete an Operator
from your cluster by using the CLI. You do this by deleting the Subscription and
ClusterServiceVersion from the `targetNamespace`, then editing the
CatalogSourceConfig to remove the Operator's package name.

.Prerequisites

- Access to an {product-title} cluster using an account with
ifdef::openshift-enterprise,openshift-origin[]
`cluster-admin` permissions.
endif::[]
ifdef::openshift-dedicated[]
`dedicated-admins-cluster` permissions.
endif::[]
- Install the `oc` command on your local system.

.Procedure

In this example, there are two Operators (Jaeger and Descheduler) installed in
the `openshift-operators` namespace. The goal is to remove Jaeger without
removing Descheduler.

. Check the current version of the subscribed Operator (for example, `jaeger`)
in the `currentCSV` field:
+
----
$ oc get subscription jaeger -n openshift-operators -o yaml | grep currentCSV
  currentCSV: jaeger-operator.v1.8.2
----

. Delete the Operator's Subscription (for example, `jaeger`):
+
----
$ oc delete subscription jaeger -n openshift-operators
subscription.operators.coreos.com "jaeger" deleted
----

. Delete the CSV for the Operator in the target namespace using the `currentCSV`
value from the previous step:
+
----
$ oc delete clusterserviceversion jaeger-operator.v1.8.2 -n openshift-operators
clusterserviceversion.operators.coreos.com "jaeger-operator.v1.8.2" deleted
----

. Display the contents of the `CatalogSourceConfig` resource and review the list
of packages in the `spec` section:
+
----
$ oc get catalogsourceconfig -n openshift-marketplace \
    installed-community-openshift-operators -o yaml
----
+
For example, the spec section might appear as follows:
+
.Example of CatalogSourceConfig
[source,yaml]
----
spec:
  csDisplayName: Community Operators
  csPublisher: Community
  packages: jaeger,descheduler
  targetNamespace: openshift-operators
----

{'fraction_non_alphanumeric': 0.10052189698207398, 'fraction_numerical': 0.0040844111640571815, 'mean_word_length': 4.523809523809524, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4890964', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1259, 'n_words': 448}