forked from apache-spark-on-k8s/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apache-spark-on-k8s#137 from palantir/resync-kube-…
…upstream Resync kube upstream
- Loading branch information
Showing
21 changed files
with
1,250 additions
and
617 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
layout: global | ||
title: Running Spark in the cloud with Kubernetes | ||
--- | ||
|
||
For general information about running Spark on Kubernetes, refer to [running Spark on Kubernetes](running-on-kubernetes.md). | ||
|
||
A Kubernetes cluster may be brought up on different cloud providers or on premise. It is commonly provisioned through [Google Container Engine](https://cloud.google.com/container-engine/), or using [kops](https://github.com/kubernetes/kops) on AWS, or on premise using [kubeadm](https://kubernetes.io/docs/getting-started-guides/kubeadm/). | ||
|
||
## Running on Google Container Engine (GKE) | ||
|
||
* Create a GKE [container cluster](https://cloud.google.com/container-engine/docs/clusters/operations). | ||
* Obtain kubectl and [configure](https://cloud.google.com/container-engine/docs/clusters/operations#configuring_kubectl) it appropriately. | ||
* Find the identity of the master associated with this project. | ||
|
||
> kubectl cluster-info | ||
Kubernetes master is running at https://<master-ip>:443 | ||
* Run spark-submit with the master option set to `k8s://https://<master-ip>:443`. The instructions for running spark-submit are provided in the [running on kubernetes](running-on-kubernetes.md) tutorial. | ||
* Check that your driver pod, and subsequently your executor pods are launched using `kubectl get pods`. | ||
* Read the stdout and stderr of the driver pod using `kubectl logs <name-of-driver-pod>`, or stream the logs using `kubectl logs -f <name-of-driver-pod>`. | ||
|
||
Known issues: | ||
* If you face OAuth token expiry errors when you run spark-submit, it is likely because the token needs to be refreshed. The easiest way to fix this is to run any `kubectl` command, say, `kubectl version` and then retry your submission. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...ain/scala/org/apache/spark/deploy/kubernetes/DriverPodKubernetesCredentialsProvider.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.spark.deploy.kubernetes | ||
|
||
import java.io.File | ||
|
||
import com.google.common.io.{BaseEncoding, Files} | ||
|
||
import org.apache.spark.SparkConf | ||
import org.apache.spark.deploy.kubernetes.config._ | ||
import org.apache.spark.deploy.rest.KubernetesCredentials | ||
import org.apache.spark.internal.config.OptionalConfigEntry | ||
|
||
private[spark] class DriverPodKubernetesCredentialsProvider(sparkConf: SparkConf) { | ||
|
||
def get(): KubernetesCredentials = { | ||
sparkConf.get(KUBERNETES_SERVICE_ACCOUNT_NAME).foreach { _ => | ||
require(sparkConf.get(KUBERNETES_DRIVER_OAUTH_TOKEN).isEmpty, | ||
"Cannot specify both a service account and a driver pod OAuth token.") | ||
require(sparkConf.get(KUBERNETES_DRIVER_CA_CERT_FILE).isEmpty, | ||
"Cannot specify both a service account and a driver pod CA cert file.") | ||
require(sparkConf.get(KUBERNETES_DRIVER_CLIENT_KEY_FILE).isEmpty, | ||
"Cannot specify both a service account and a driver pod client key file.") | ||
require(sparkConf.get(KUBERNETES_DRIVER_CLIENT_CERT_FILE).isEmpty, | ||
"Cannot specify both a service account and a driver pod client cert file.") | ||
} | ||
val oauthToken = sparkConf.get(KUBERNETES_DRIVER_OAUTH_TOKEN) | ||
val caCertDataBase64 = safeFileConfToBase64(KUBERNETES_DRIVER_CA_CERT_FILE, | ||
s"Driver CA cert file provided at %s does not exist or is not a file.") | ||
val clientKeyDataBase64 = safeFileConfToBase64(KUBERNETES_DRIVER_CLIENT_KEY_FILE, | ||
s"Driver client key file provided at %s does not exist or is not a file.") | ||
val clientCertDataBase64 = safeFileConfToBase64(KUBERNETES_DRIVER_CLIENT_CERT_FILE, | ||
s"Driver client cert file provided at %s does not exist or is not a file.") | ||
val serviceAccountName = sparkConf.get(KUBERNETES_SERVICE_ACCOUNT_NAME) | ||
KubernetesCredentials( | ||
oauthToken = oauthToken, | ||
caCertDataBase64 = caCertDataBase64, | ||
clientKeyDataBase64 = clientKeyDataBase64, | ||
clientCertDataBase64 = clientCertDataBase64) | ||
} | ||
|
||
private def safeFileConfToBase64( | ||
conf: OptionalConfigEntry[String], | ||
fileNotFoundFormatString: String): Option[String] = { | ||
sparkConf.get(conf) | ||
.map(new File(_)) | ||
.map { file => | ||
require(file.isFile, String.format(fileNotFoundFormatString, file.getAbsolutePath)) | ||
BaseEncoding.base64().encode(Files.toByteArray(file)) | ||
} | ||
} | ||
} |
Oops, something went wrong.