Skip to content

Commit

Permalink
Allow spark driver find shuffle pods in specified namespace (apache-s…
Browse files Browse the repository at this point in the history
…park-on-k8s#357)

The conf property spark.kubernetes.shuffle.namespace is used to
specify the namesapce of shuffle pods.

In normal cases, only one "shuffle daemonset" is deployed and
shared by all spark pods.

The spark driver should be able to list and watch shuffle pods
in the namespace specified by user.

Note: by default, spark driver pod doesn't have authority to
list and watch shuffle pods in another namespace. Some action
is needed to grant it the authority. For example, below ABAC
policy works.

```
{"apiVersion": "abac.authorization.kubernetes.io/v1beta1", "kind":
"Policy", "spec": {"group": "system:serviceaccounts", "namespace":
"SHUFFLE_NAMESPACE",
"resource": "pods", "readonly": true}}
```
  • Loading branch information
Hong Zhiguo authored and Puneet Loya committed Mar 8, 2019
1 parent 5a230f2 commit 927d859
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ private[spark] class ShufflePodCache (

def start(): Unit = {
// seed the initial cache.
val pods = client.pods().withLabels(dsLabels.asJava).list()
val pods = client.pods()
.inNamespace(dsNamespace).withLabels(dsLabels.asJava).list()
pods.getItems.asScala.foreach {
pod =>
if (Readiness.isReady(pod)) {
Expand All @@ -50,6 +51,7 @@ private[spark] class ShufflePodCache (

watcher = client
.pods()
.inNamespace(dsNamespace)
.withLabels(dsLabels.asJava)
.watch(new Watcher[Pod] {
override def eventReceived(action: Watcher.Action, p: Pod): Unit = {
Expand Down

0 comments on commit 927d859

Please sign in to comment.