SparkKubernetesClientFactory Utility¶
SparkKubernetesClientFactory is a Spark-opinionated builder for Kubernetes clients.
Creating KubernetesClient¶
createKubernetesClient(
master: String,
namespace: Option[String],
kubernetesAuthConfPrefix: String,
clientType: ClientType.Value,
sparkConf: SparkConf,
defaultServiceAccountToken: Option[File],
defaultServiceAccountCaCert: Option[File]): KubernetesClient
createKubernetesClient utility takes the OAuth token-related configuration properties from the input SparkConf:
kubernetesAuthConfPrefix.oauthTokenFile (or defaults to the inputdefaultServiceAccountToken)kubernetesAuthConfPrefix.oauthToken
createKubernetesClient takes the spark.kubernetes.context configuraiton property (kubeContext).
createKubernetesClient takes the certificate-related configuration properties from the input SparkConf:
kubernetesAuthConfPrefix.caCertFile (or defaults to the inputdefaultServiceAccountCaCert)kubernetesAuthConfPrefix.clientKeyFilekubernetesAuthConfPrefix.clientCertFile
createKubernetesClient prints out the following INFO message to the logs:
Auto-configuring K8S client using [context [kubeContext] | current context] from users K8S config file
createKubernetesClient builds a Kubernetes Config (based on the configuration properties).
createKubernetesClient builds an OkHttpClient with a custom kubernetes-dispatcher dispatcher.
In the end, createKubernetesClient creates a Kubernetes DefaultKubernetesClient (with the OkHttpClient and Config).
createKubernetesClient is used when:
K8SSparkSubmitOperationis requested to executeKubernetesClientApplicationis requested to startKubernetesClusterManageris requested to create a SchedulerBackend
Exceptions¶
createKubernetesClient throws an IllegalArgumentException when an OAuth token is specified through a file and a value:
Cannot specify OAuth token through both a file [oauthTokenFileConf] and a value [oauthTokenConf].
Logging¶
Enable ALL logging level for org.apache.spark.deploy.k8s.SparkKubernetesClientFactory logger to see what happens inside.
Add the following line to conf/log4j.properties:
log4j.logger.org.apache.spark.deploy.k8s.SparkKubernetesClientFactory=ALL
Refer to Logging.