ngrok-operator helm chart uses finalizers on its custom resources to ensure proper cleanup of ngrok API resources before deletion. The chart includes a pre-delete helm hook that automates removing these finalizers and optionally deleting resources during uninstall.
Quick uninstall (preserves ngrok account resources)
By default, uninstalling the operator preserves resources in your ngrok account such as CloudEndpoints and Domains. This prevents an uninstall from taking down cloud infrastructure that may be supporting a production site.pre-delete helm hook job automatically:
- Signals the operator to stop reconciling resources
- Patches every custom resource to remove its finalizer
- Allows the helm uninstall to proceed, tearing down the operator deployment (and CRDs, if they were bundled with the operator release)
Cleaning up ngrok account resources
If you want to also delete ngrok API resources (CloudEndpoints, Domains, etc.) from your account during uninstall, first upgrade your release to set thedrainPolicy to Delete:
helm uninstall ngrok-operator -n ngrok-operator, the pre-delete hook job will:
- Delete each custom resource and wait for the operator to clean up the corresponding ngrok API resource
- Remove finalizers from
Ingressobjects (but does NOT delete them) - Allow the helm uninstall to proceed
Recommended setup
The following recommendations make uninstalling simpler and help avoid stuck resources:-
Install the operator in its own namespace (for example,
ngrok-operator). Keep it separate from the namespace where you createIngressobjects or custom resources. This way, if you delete a namespace full of resources, the operator stays running and can process the deletions. -
Install CRDs separately using the
ngrok-crdschart. This decouples CRD lifecycle from the operator. See Separate CRD installation below. -
Delete resources before uninstalling if you want to clean up your ngrok account. Deleting
Ingressobjects and custom resources likeCloudEndpointwhile the operator is still running gives it time to properly clean up the corresponding ngrok API resources.
How the uninstall process works
The ngrok-operator uses finalizers on its custom resources. These prevent Kubernetes from removing objects until the operator has performed cleanup tasks, such as deleting the corresponding resource from the ngrok API. When youhelm uninstall, the chart’s pre-delete hook job handles these finalizers so you don’t have to. What happens depends on two factors:
- How CRDs were installed: bundled with the operator chart (default) or separately via the
ngrok-crdschart - The
drainPolicyvalue:Retain(default) orDelete
CRDs bundled with operator (default)
When CRDs are part of the same helm release, uninstalling the operator also uninstalls the CRDs, which forces all custom resources into deletion.CRDs installed separately
When CRDs are installed via thengrok-crds chart with installCRDs=false on the operator, uninstalling the operator does not remove the CRDs or force CR deletion.
With separate CRDs and
drainPolicy=Retain, the remaining CRs are left without finalizers, which means you can:
- Delete those resources without them getting stuck
- Delete namespaces containing those resources without them getting stuck
- Uninstall the CRDs separately whenever you’re ready
Separate CRD installation
Instead of bundling CRDs with the operator, you can install them separately. This is strongly recommended for production and required for multiple installations.Multiple installations
If you have multiple operators installed (see Multiple Installations), the uninstall behavior depends on how they were installed and which one you are uninstalling. When uninstalling one of multiple operators:- First uninstall operators that have
installCRDs=false - Last, uninstall the single installation that includes the CRDs (if applicable)
Cleaning up account resources with multiple operators
You canhelm upgrade a specific operator to set drainPolicy=Delete before uninstalling it. The cleanup job uses the same ingress.watchNamespace filter that the operator uses, so it only deletes resources within that operator’s scope.
Disabling the cleanup job
If you prefer manual cleanup or have a custom uninstall process, disable the helm hook:Triggering cleanup without Helm
If you are not using a system that supports helm hooks (for example, some GitOps tools), you can trigger the cleanup process manually by deleting theKubernetesOperator resource:
drainPolicy set during installation. Once the KubernetesOperator resource is deleted, you can proceed to uninstall the operator and CRDs however you see fit.
Reinstalling after uninstall
After uninstalling, your cluster may be in different states depending on how the install and uninstall were done:- Ingress objects: Still exist but without finalizers and aren’t being reconciled
- Custom resources: May be fully deleted, or may still exist without finalizers but with their Status information intact
- ngrok API resources: May still exist in your account or may have been deleted (depending on
drainPolicy)
drainPolicy=Delete): Reinstalling the operator will recreate them from your existing Kubernetes resources.
If ngrok API resources were preserved (drainPolicy=Retain):
- If CRDs were installed separately and CRs still exist in the cluster, reinstalling the operator will re-add finalizers and resume managing them with no duplication.
- If CRDs were bundled and were deleted (forcing CR deletion), you’ll need to reapply your manifests. This may create duplicate resources (for example, a second CloudEndpoint in a pool) if the originals still exist in your ngrok account. Check the ngrok Dashboard and clean up any duplicates.
- For
Ingressobjects, the new operator will see them and automatically create the corresponding resources.
Troubleshooting
Viewing cleanup job logs
Thepre-delete helm hook runs as a Kubernetes Job. To view its logs:
Viewing Operator drain logs
If you triggered cleanup via theKubernetesOperator resource, the drain process runs inside the operator pod:
Checking drain status
TheKubernetesOperator custom resource reports the current state of the drain process in its status: