Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package org.apache.spark.deploy.k8s.integrationtest.backend.minikube

import java.nio.file.Paths
import java.nio.file.{Files, Paths}

import io.fabric8.kubernetes.client.{ConfigBuilder, DefaultKubernetesClient}

Expand Down Expand Up @@ -68,15 +68,23 @@ private[spark] object Minikube extends Logging {
def getKubernetesClient: DefaultKubernetesClient = {
val kubernetesMaster = s"https://${getMinikubeIp}:8443"
val userHome = System.getProperty("user.home")
val minikubeBasePath = Paths.get(userHome, MINIKUBE_PATH).toString
val profileDir = if (Files.exists(Paths.get(minikubeBasePath, "apiserver.crt"))) {
// For Minikube <1.9
""
} else {
// For Minikube >=1.9
Paths.get("profiles", executeMinikube("profile")(0)).toString
}
val apiServerCertPath = Paths.get(minikubeBasePath, profileDir, "apiserver.crt")
val apiServerKeyPath = Paths.get(minikubeBasePath, profileDir, "apiserver.key")
val kubernetesConf = new ConfigBuilder()
.withApiVersion("v1")
.withMasterUrl(kubernetesMaster)
.withCaCertFile(
Paths.get(userHome, MINIKUBE_PATH, "ca.crt").toFile.getAbsolutePath)
.withClientCertFile(
Paths.get(userHome, MINIKUBE_PATH, "apiserver.crt").toFile.getAbsolutePath)
.withClientKeyFile(
Paths.get(userHome, MINIKUBE_PATH, "apiserver.key").toFile.getAbsolutePath)
.withClientCertFile(apiServerCertPath.toFile.getAbsolutePath)
.withClientKeyFile(apiServerKeyPath.toFile.getAbsolutePath)
.build()
new DefaultKubernetesClient(kubernetesConf)
}
Expand Down Expand Up @@ -120,7 +128,7 @@ private[spark] object Minikube extends Logging {

def executeMinikube(action: String, args: String*): Seq[String] = {
ProcessUtils.executeProcess(
Array("bash", "-c", s"minikube $action ${args.mkString(" ")}"),
Array("bash", "-c", s"MINIKUBE_IN_STYLE=true minikube $action ${args.mkString(" ")}"),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers: Without this change, the output of minikube profile is with the prefix * .
(e.g. * minikube rather than minikube) in case stderr is not tty.

MINIKUBE_STARTUP_TIMEOUT_SECONDS).filter{x =>
!x.contains("There is a newer version of minikube") &&
!x.contains("https://github.com/kubernetes")
Expand Down