Change the namespace for a SparkApplication
This article explains how to move an existing SparkApplication to a different namespace when it cannot access a required secret in its current namespace.
Overview
A SparkApplication can only read secrets that exist in the same namespace as the application itself.
A common failure case is:
Error: secret "kfp-openstack-s3-creds" not found
This usually means that:
the SparkApplication was created in one namespace, for example default,
the required secret exists in another namespace, for example kubeflow-user-example-com.
The fix is to recreate the SparkApplication in the namespace where the secret already exists.
Prerequisites
Before starting, make sure that:
SparkOperator is installed in the cluster.
The secret kfp-openstack-s3-creds exists in the kubeflow-user-example-com namespace.
The SparkApplication was created in the default namespace.
The logs or describe output show the following error:
Error: secret "kfp-openstack-s3-creds" not found
Procedure
Locate the secret.
kubectl get secret kfp-openstack-s3-creds -n kubeflow-user-example-com
Delete the SparkApplication from the old namespace (default).
kubectl delete sparkapplication s3-spark-job -n default
Optional verification:
kubectl get sparkapplications -A
Add the namespace to the YAML manifest.
apiVersion: "sparkoperator.k8s.io/v1beta2" kind: SparkApplication metadata: name: s3-spark-job namespace: kubeflow-user-example-com ...
Create the SparkApplication in the new namespace.
kubectl apply -f s3_app.yaml -n kubeflow-user-example-com
Verify in the new namespace.
kubectl get sparkapplications -n kubeflow-user-example-com kubectl get pods -n kubeflow-user-example-com
Inspect the application and logs:
kubectl describe sparkapplication s3-spark-job -n kubeflow-user-example-com kubectl logs s3-spark-job-driver -n kubeflow-user-example-com
Optional: change the default kubectl context namespace.
kubectl config set-context --current --namespace=kubeflow-user-example-com
Verify the context change:
kubectl config view --minify -o 'jsonpath={..namespace}'
Result
After completing this procedure:
the SparkApplication s3-spark-job runs in the kubeflow-user-example-com namespace,
the application can access the kfp-openstack-s3-creds secret,
the error
secret "kfp-openstack-s3-creds" not found
is resolved because the job and the secret now reside in the same namespace.
What to do next
After moving the SparkApplication to the correct namespace, you can:
verify that S3 access now works correctly,
check whether the driver and executor both receive the required secret values,
update future SparkApplication manifests so that the namespace is always set explicitly.