# removing an operator without removing k8s CRDs

**URL:** <https://forum.ansible.com/t/removing-an-operator-without-removing-k8s-crds/36515>\
**Category:** AWX Project\
**Tags:** kubernetes, awx\
**Created:** [April 6, 2022, 2:45pm UTC](https://forum.ansible.com/t/removing-an-operator-without-removing-k8s-crds/36515 "2022-04-06T14:45:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Magnus\_R\_Christoffer](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@Magnus\_R\_Christoffer](https://forum.ansible.com/u/Magnus_R_Christoffer)\
**Post date:** [April 6, 2022, 2:45pm UTC](https://forum.ansible.com/t/removing-an-operator-without-removing-k8s-crds/36515/1 "2022-04-06T14:45:35Z")

</div>

Hi  
Does anyone know if there is a way to properly remove an operator from a namespace, without having an affect on the AWX specific CRDs?

My setup consist of two namespace with each their operator. so if i run “make undeploy” for one of the namespaces, the other awx installation in the other namespace is affected, since the crd “awx” is gonna be removed.

I am running make from the same directory on the tag “0.19.0”

Dear regards  
Magnus

---

<div class="post-metadata">

**Author:** ![Vincent\_Rubiolo](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@Vincent\_Rubiolo](https://forum.ansible.com/u/Vincent_Rubiolo)\
**Post date:** [April 7, 2022, 7:55am UTC](https://forum.ansible.com/t/removing-an-operator-without-removing-k8s-crds/36515/2 "2022-04-07T07:55:55Z")

</div>

Hi Magnus,

I don’t have the full answer to your question but in my case (AWX 19.4.0 w/ operator 0.14.0 over K3S) the CRD is namespace-scoped:  
$ kubectl describe awx  
Name: awx  
Namespace: awx-vincent  
Labels: [app.kubernetes.io/component=awx](http://app.kubernetes.io/component=awx)  
[app.kubernetes.io/managed-by=awx-operator](http://app.kubernetes.io/managed-by=awx-operator)  
[app.kubernetes.io/name=awx](http://app.kubernetes.io/name=awx)  
[app.kubernetes.io/operator-version=](http://app.kubernetes.io/operator-version=)  
[app.kubernetes.io/part-of=awx](http://app.kubernetes.io/part-of=awx)  
Annotations:   
API Version: [awx.ansible.com/v1beta1](http://awx.ansible.com/v1beta1)

It is thus strange to me that the undeploy step from one namespace affects the other CRD (I expect it removes the CRD from its associated namespace but not the other namespaces).

I would expect that you need to set the NAMESPACE variable when doing the undeploy step for instance.

Would you mind sharing more info on the commands you use to undeploy as well as your namespaces and CRDs in your cluster?

HTH,

Vincent

---

<div class="post-metadata">

**Author:** ![Magnus\_R\_Christoffer](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@Magnus\_R\_Christoffer](https://forum.ansible.com/u/Magnus_R_Christoffer)\
**Post date:** [April 7, 2022, 11:07am UTC](https://forum.ansible.com/t/removing-an-operator-without-removing-k8s-crds/36515/3 "2022-04-07T11:07:01Z")

</div>

Hey Vincent  
My setup consist of two operators in each their namespace running on a single node k3s cluster.  
yes the “awx” is defined in each of the namespaces, the problem is that still when i execute “make undeploy” with a namespace defined as an env var, resources in the other namespace are affected…

this is my strategy for removing a cluster:

```auto
kubectl delete awx awx-<name> -n awx-<namespace>
cd awx-operator/
export NAMESPACE=awx-<namespace>
make undeploy

```

maybe i just test around with different operator versions, to see if there is any difference…

Best regards  
Magnus

---

<div class="post-metadata">

**Author:** ![Vincent\_Rubiolo](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@Vincent\_Rubiolo](https://forum.ansible.com/u/Vincent_Rubiolo)\
**Post date:** [April 7, 2022, 3:50pm UTC](https://forum.ansible.com/t/removing-an-operator-without-removing-k8s-crds/36515/4 "2022-04-07T15:50:50Z")

</div>

Magnus,

Thanks for the additional information. It might be a bug in the cleanup step.

Could it also be that the undeploy step deletes the CRD too (and that you do not need to do it yourself)? Or that it picks up the first CRD with the correct name, regardless of the namespace?

I also don’t know if, in addition to being in separate namespace names, the actual CRDs and resources also need to have a different name too.

Let us know how it goes,

Vincent

---

<div class="post-metadata">

**Author:** ![Jeremy\_Bouse](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@Jeremy\_Bouse](https://forum.ansible.com/u/Jeremy_Bouse)\
**Post date:** [April 7, 2022, 9:11pm UTC](https://forum.ansible.com/t/removing-an-operator-without-removing-k8s-crds/36515/5 "2022-04-07T21:11:28Z")

</div>

Not sure if this is the right or best way… but if I run `kubectl get deployments -A -l control-plane=controller-manager` I get the awx-operator-controller-manager deployment listed in both namespaces I have AWX operator deployed. While there are some extra configurations that would be left behind if you’re looking to simply remove the controller and leave the CRDS you could remove the deployment in the namespace you want to remove and thus leave the other. If you’ve already deleted the AWX deployments themselves this should be the only AWX-related pod running in that namespace. Then you could clean up the ConfigMaps and Secrets, I think I recall 1 Secret and 2 ConfigMaps that are `awx-operator` prefixed. You may also find you still have a few laying around from the AWX deployments themselves as well.

---

<div class="post-metadata">

**Author:** ![Christian\_Adams](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@Christian\_Adams](https://forum.ansible.com/u/Christian_Adams)\
**Post date:** [April 7, 2022, 9:35pm UTC](https://forum.ansible.com/t/removing-an-operator-without-removing-k8s-crds/36515/6 "2022-04-07T21:35:41Z")

</div>

Hello all,

As mentioned above, you can delete the deployment object for the awx-operator’s manager, which will remove the operator and leave behind all AWX CR’s.

_kubectl delete deployment awx-operator-controller-manager --namespace_

This will however leave behind a couple other artifacts that you may wish to clean up:

- 
  - serviceaccount/awx-operator-controller-manager

- 
  - service/awx-operator-controller-manager-metrics-service

- 
  - configmap/awx-operator

- 
  - configmap/awx-operator-awx-manager-config

- 
  - 3 secrets with prefix awx-operator-controller-manager

The reason why the `make undeploy` target also deletes your AWX CR’s is because the API’s/Custom Resource Definitions themselves get cleaned up by the undeploy target.

Thanks,  
Christian

---

<div class="post-metadata">

**Author:** ![Magnus\_R\_Christoffer](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@Magnus\_R\_Christoffer](https://forum.ansible.com/u/Magnus_R_Christoffer)\
**Post date:** [April 11, 2022, 9:08am UTC](https://forum.ansible.com/t/removing-an-operator-without-removing-k8s-crds/36515/7 "2022-04-11T09:08:19Z")

</div>

Hi Christian  
Thanks for the respond, this answers my question!  
thank you all for the participation in fixing my problem.

Best wishes,  
Magnus
