Revision 786a21884cbd173e7df312ed27164238089e8cfa authored by Dongjoon Hyun on 23 August 2023, 05:45:52 UTC, committed by Dongjoon Hyun on 23 August 2023, 05:46:02 UTC
### What changes were proposed in this pull request?

This PR aims to stop materializing `OAuth token` from the default service token file, `/var/run/secrets/kubernetes.io/serviceaccount/token`, because the content of volumes varies which means being renewed or expired by K8s control plane. We need to read the content in a on-demand manner to be in the up-to-date status.

Note the followings:

- Since we use `autoConfigure` for K8s client, K8s client still uses the default service tokens if exists and needed.

https://github.com/apache/spark/blob/13588c10cbc380ecba1231223425eaad2eb9ec80/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/SparkKubernetesClientFactory.scala#L91

- This PR doesn't change Spark's behavior for the user-provided token file location. Spark will load the content of the user-provided token file locations to get `OAuth token` because Spark cannot assume that the files of that locations are refreshed or not in the future.

### Why are the changes needed?

[BoundServiceAccountTokenVolume](https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/#bound-service-account-token-volume) became `Stable` at K8s 1.22.

- [KEP-1205 Bound Service Account Tokens](https://github.com/kubernetes/enhancements/blob/master/keps/sig-auth/1205-bound-service-account-tokens/README.md#boundserviceaccounttokenvolume-1) : **BoundServiceAccountTokenVolume**

Alpha | Beta | GA
-- | -- | --
1.13 | 1.21 | 1.22

- [EKS Service Account with 90 Days Expiration](https://docs.aws.amazon.com/eks/latest/userguide/service-accounts.html)
  > For Amazon EKS clusters, the extended expiry period is 90 days. Your Amazon EKS cluster's Kubernetes API server rejects requests with tokens that are greater than 90 days old.

- As of today, [all supported EKS clusters are from 1.23 to 1.27](https://docs.aws.amazon.com/eks/latest/userguide/kubernetes-versions.html) which means we always use `BoundServiceAccountTokenVolume`.

### Does this PR introduce _any_ user-facing change?

No. This fixes only the bugs caused by some outdated tokens where K8s control plane denies Spark's K8s API invocation.

### How was this patch tested?

Pass the CIs with the all existing unit tests and integration tests.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #42624 from dongjoon-hyun/SPARK-44925.

Authored-by: Dongjoon Hyun <dhyun@apple.com>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
(cherry picked from commit 7b1a3494107b304a93f571920fc3816cde71f706)
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
1 parent 5ffefd0
History

README.md

back to top