Skip to content

[SPARK-55653][K8S] Support NetworkPolicy for Spark executor pods#54442

Closed
dongjoon-hyun wants to merge 2 commits intoapache:masterfrom
dongjoon-hyun:SPARK-55653
Closed

[SPARK-55653][K8S] Support NetworkPolicy for Spark executor pods#54442
dongjoon-hyun wants to merge 2 commits intoapache:masterfrom
dongjoon-hyun:SPARK-55653

Conversation

@dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Feb 24, 2026

What changes were proposed in this pull request?

This PR aims to support NetworkPolicy for Spark executor pods.

Why are the changes needed?

NetworkPolicy is frequently used in the production to isolate Spark applications.

Does this PR introduce any user-facing change?

This is a security feature to make Spark K8s executor pods access only from the pods with the same application ID.

There are two ways if a user wants to access the executor pods from outside.

  1. Use a pod with the same application ID with the target Spark applications.
  2. Submit a Spark job with the following configuration.
spark.kubernetes.driver.pod.excludedFeatureSteps=org.apache.spark.deploy.k8s.features.NetworkPolicyFeatureStep

How was this patch tested?

Pass the CIs with the newly added test suite.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Gemini 3.1 Pro (High) on Antigravity

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-55653][K8S] Support NetworkPolicy for Spark executors [SPARK-55653][K8S] Support NetworkPolicy for Spark executors pods Feb 24, 2026
@dongjoon-hyun
Copy link
Member Author

cc @peter-toth

@peter-toth
Copy link
Contributor

Does this change need to be explicitly mentioned in migration docs?

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-55653][K8S] Support NetworkPolicy for Spark executors pods [SPARK-55653][K8S] Support NetworkPolicy for Spark executor pods Feb 24, 2026
(cherry picked from commit f9d4080)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
@dongjoon-hyun
Copy link
Member Author

Thank you, @peter-toth . I addressed your comment by updating the migration guide.

  • Since Spark 4.2, Spark configures a NetworkPolicy by default so that executor pods only accept ingress traffic from the driver and peer executors within the same job. To disable this and restore the legacy behavior, set spark.kubernetes.driver.pod.excludedFeatureSteps to org.apache.spark.deploy.k8s.features.NetworkPolicyFeatureStep.

@dongjoon-hyun
Copy link
Member Author

dongjoon-hyun commented Feb 24, 2026

Merged to master

@dongjoon-hyun dongjoon-hyun deleted the SPARK-55653 branch February 24, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants