Sometimes you're just testing something out, or an application life cycle has come to an end, and the need to clean up existing resources arise.
Delete an application
# Usage
okctl delete application -f <application manifest>
# Example
okctl delete application -f app.yaml
Delete an application manually
okctl apply application
creates a few different resources depending on configuration.
Delete ArgoCD application manifest
To stop ArgoCD from reapplying deleted resources, it is recommended to start with deleting the ArgoCD application manifest. Delete the file infrastructure/<cluster>/argocd/applications/<app name>.yaml
, commit and push the changes.
If you enable cascading deletion for your application, ArgoCD will handle deleting all related Kubernetes resources. Read more here.
Delete Kubernetes resources
ArgoCD uses Kustomize to compile the Kubernetes resources before applying them to the cluster. To delete all related Kubernetes manifests, use kustomize build infrastructure/applications/<app name>/overlays/<cluster name> | kubectl delete -f -
.
You can also use kubectl -n <namespace> get <resource type>
to view resources in a certain namespace, then kubectl -n <namespace> delete <resource type> <resource name>
to delete a certain resource.
Delete ECR repository
If you've enabled an ECR for your repository, you delete it by going into the AWS web console, search for CloudFormation, find the stack called okctl-containerrepository-<app name>
and delete it.
N.B.: The ECR repository must be empty prior to deleting it. This can be done by going to the AWS web console, searching for ECR, select the relevant repository, select all the images and press delete.
Delete the ACM certificate
If you've enabled an ingress for your application, you delete it by going into the AWS web console, search for CloudFormation, find the stack called okctl-certificate-<cluster name>-<relevant domain>
and delete it.
N.B.: Deletion requires the relevant Amazon Load Balancer to be deleted. This happens automatically when deleting the applications ingress, but can take a few minutes.
Delete the application security group
If you've enabled Postgres integration for your application, your application will have a security group connected to it. To delete it, go into the AWS web console, search for CloudFormation, find the stack called okctl-sg-<cluster name>-<app name>
and delete it.
N.B.: Deletion requires the associated inbound rule in the Postgres security group to be removed. To remove it, go to the AWS web console, search for EC2, select Security Groups from the menu on the left, find the security group named okctl-<cluster name>-RDSPostgresIncoming
, edit inbound rules and delete the rule with the description "Allow postgres traffic from <app name>".