Delete a SparkApplication
This article explains how to delete one or more SparkApplication resources and how to verify that they have been removed.
Overview
When working with the Spark Operator, it is often necessary to remove finished, failed, or no longer needed SparkApplication resources.
This procedure shows how to:
list existing SparkApplication resources across namespaces,
delete one specific SparkApplication,
delete all SparkApplication resources in one namespace,
verify that the deletion was successful.
Prerequisites
Before starting, make sure that:
You can access the cluster by using kubectl.
The Spark Operator is installed and SparkApplication resources are available in the cluster.
You know the name of the SparkApplication that you want to remove, or you can list it first.
Delete a SparkApplication
To view your current SparkApplication resources across all namespaces, run:
kubectl get sparkapplications -A
The output will look similar to this:
Example output showing SparkApplication resources across namespaces.
Delete a specific SparkApplication.
For example, to delete a job named s3-spark-job in the default namespace, run:
kubectl delete sparkapplication s3-spark-job -n default
If the application is in a different namespace, replace the values by using the data from the NAME and NAMESPACE columns:
kubectl delete sparkapplication JOB_NAME -n NAMESPACE_NAME
Delete all SparkApplication resources within a single namespace (optional).
For example, in the default namespace, run:
kubectl delete sparkapplication --all -n default
Warning
This command removes every SparkApplication resource in the selected namespace.
Verify deletion.
After executing the delete command, verify that the resources have been removed by running:
kubectl get sparkapplications -A
If the deletion was successful, the removed SparkApplication should no longer appear in the output.
What to do next
After deleting a SparkApplication, the next useful steps are:
recreating it with corrected configuration,
checking whether related resources were also cleaned up,
verifying that you are using the correct namespace before creating the next SparkApplication.