Github user rvesse commented on a diff in the pull request: https://github.com/apache/spark/pull/22805#discussion_r227400699 --- Diff: resource-managers/kubernetes/integration-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/backend/docker/DockerForDesktopBackend.scala --- @@ -0,0 +1,68 @@ +package org.apache.spark.deploy.k8s.integrationtest.backend.docker + +import java.nio.file.Paths + +import io.fabric8.kubernetes.client.{Config, DefaultKubernetesClient} +import org.apache.spark.deploy.k8s.integrationtest.ProcessUtils +import org.apache.spark.deploy.k8s.integrationtest.backend.IntegrationTestBackend + +private[spark] object DockerForDesktopBackend extends IntegrationTestBackend { + + private val KUBECTL_STARTUP_TIMEOUT_SECONDS = 15 + + private var defaultClient: DefaultKubernetesClient = _ + private var initialContext = "" + + private def getCurrentContext: String = { + val outputs = executeKubectl("config", "current-context") + assert(outputs.size == 1, "Unexpected amount of output from kubectl config current-context") + outputs.head + } + + private def setContext(context: String): Unit = { + val outputs = executeKubectl("config", "use-context", context) + assert(outputs.size == 1, "Unexpected amount of output from kubectl config use-context") + val errors = outputs.filter(_.startsWith("error")) + assert(errors.size == 0, s"Received errors from kubectl: ${errors.head}") + } + + override def initialize(): Unit = { + // Switch context if necessary + // TODO: If we were using Fabric 8 client 3.1.0 then we could + // instead just use the overload of autoConfigure() that takes the + // desired context avoiding the need to interact with kubectl at all + initialContext = getCurrentContext --- End diff -- Would people be opposed to bumping the K8S client to 3.1.0 (or even a more recent 3.1.x release) as this would simplify the code significantly and avoid any need to shell out to `kubectl`?
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org