|
| 1 | +--- |
| 2 | + date: 2026-02-16 |
| 3 | + title: Experimental support for pattern uninstall |
| 4 | + summary: Uninstalling patterns now possible |
| 5 | + author: Akos Eros |
| 6 | + blog_tags: |
| 7 | + - patterns |
| 8 | + - announce |
| 9 | +--- |
| 10 | +:toc: |
| 11 | +:imagesdir: /images |
| 12 | + |
| 13 | +We are excited to announce that uninstalling patterns are now experimentally supported from pattern operator version 0.0.65 |
| 14 | +To initiate the uninstallation, only the pattern cr needs to be deleted. |
| 15 | +[source,bash] |
| 16 | +---- |
| 17 | +oc delete -n openshift-operators patterns/<pattern-name> |
| 18 | +---- |
| 19 | + |
| 20 | +== Initial approach |
| 21 | + |
| 22 | +When we initialy started to work on supporting pattern uninstall, the naive approach was to remove the app of apps, and let argocd handle and clean up the rest. |
| 23 | +Unfortunatelly this path was unfeasable for two reasons: some long outstanding issues in argocd regarding application health checks, |
| 24 | +link:https://github.com/argoproj/argo-cd/issues/6708[**here**] and link:https://github.com/argoproj/argo-cd/issues/10550[**here**] |
| 25 | +and the hub-spoke architecture with acm policies. |
| 26 | + |
| 27 | + |
| 28 | +== Gory implementation details |
| 29 | + |
| 30 | +We decided to go with a more fine grained solution, and do phases: |
| 31 | + |
| 32 | +* Delete spoke child applications |
| 33 | +* Delete spoke app of apps |
| 34 | +* Delete hub child applications |
| 35 | +* Delete hub app of apps |
| 36 | + |
| 37 | +The main control is in the operator, we pass the phase as a variable to clustergroup chart, and to the acm chart. |
| 38 | +In order to achive this, we made some changes to the clustergroup chart, to remove child applications when needed. |
| 39 | +In the acm chart we also needed some changes to support distinction between the phases in hub and spoke clusters. |
| 40 | +The resource removal is still managed by argocd. |
| 41 | +In prior operator versions the gitops subscription was owned by the pattern CR, we transfer the ownership to the patterns operator. |
| 42 | +The patterns operator, and cluster-wide OpenShift GitOps instance will remain installed. |
| 43 | + |
| 44 | +To initiate the uninstallation, only the pattern cr needs to be deleted. |
| 45 | +[source,bash] |
| 46 | +---- |
| 47 | +oc delete -n openshift-operators patterns/<pattern-name> |
| 48 | +---- |
| 49 | + |
| 50 | +=== Deletion Phase Flow |
| 51 | + |
| 52 | +We store each phase in the pattern status deletionPhase, initialized as empty string. |
| 53 | + |
| 54 | +==== Initial Phase |
| 55 | + |
| 56 | +Right after deleting the pattern cr we set the deletionPhase to DeleteSpokeChildApps if we have acm hub resource or DeleteHubChildApps if we have no acm hub detected. |
| 57 | + |
| 58 | +==== DeleteSpokeChildApps |
| 59 | + |
| 60 | +When deleting spoke apps we update the clustergroup chart global.deletePattern variable to DeleteSpokeChildApps, this gets passed to the acm chart. |
| 61 | +The acm chart passes/changes global.deletePattern variable to DeleteChildApps, so the spoke clustergroup chart can start to remove child applications. |
| 62 | + |
| 63 | +We check the spoke child applications from the operator, and once all are gone, we change the deletionPhase to DeleteSpoke. |
| 64 | + |
| 65 | +==== DeleteSpoke |
| 66 | + |
| 67 | +This will be passed through the clustergroup chart to acm where the application policy will be deleted, and because pruneObjectBehavior: DeleteIfCreated is set, the app of apps will be removed from the spoke(s). |
| 68 | + |
| 69 | +We check the spoke app of apps from the operator, and once it is gone, we change the deletionPhase to DeleteHubChildApps. |
| 70 | + |
| 71 | +==== DeleteHubChildApps |
| 72 | + |
| 73 | +At this phase we detach all managed clusters from the hub cluster. |
| 74 | +We update the clustergroup chart global.deletePattern variable to DeleteChildApps so argocd can start to remove child apps from the hub. |
| 75 | + |
| 76 | +We check the hub child applications from the operator, and once all are gone, we change the deletionPhase to DeleteHub. |
| 77 | + |
| 78 | +==== DeleteHub |
| 79 | + |
| 80 | +The last phase we remove the app of apps from the spoke, which will remove all the subscriptions and namespaces, and remove the pattern cr as well. |
| 81 | + |
| 82 | + |
| 83 | +== Known limitations |
| 84 | + |
| 85 | +We did our due diligence and tested the uninstallation of the mcg pattern with both hub and spoke clusters. |
| 86 | +____ |
| 87 | +"By design, when OLM uninstalls an operator it does not remove any of the operator’s owned CRDs, APIServices, or CRs in order to prevent data loss." |
| 88 | +____ |
| 89 | +With the above in mind, we only remove operators/subscriptions, and do not remove any crds. |
| 90 | +If the operator is installed to a namespace, its ClusterServiceVersion will be removed (when the namespace is deleted). |
| 91 | +However if its installed to a namespace that is not cleaned up (ie: openshift-operators) the csv will remain in the cluster. |
0 commit comments