Skip to content

Commit d5b4e58

Browse files
authored
Merge pull request #155 from Yelp/spark_run_pod_identity_support
Add support for pod identity with executor
2 parents 317a1e5 + 1b062b1 commit d5b4e58

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

service_configuration_lib/spark_config.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
AWS_CREDENTIALS_DIR = '/etc/boto_cfg/'
2929
AWS_ENV_CREDENTIALS_PROVIDER = 'com.amazonaws.auth.EnvironmentVariableCredentialsProvider'
30+
AWS_DEFAULT_CREDENTIALS_PROVIDER = 'com.amazonaws.auth.DefaultAWSCredentialsProviderChain'
3031
GPU_POOLS_YAML_FILE_PATH = '/nail/srv/configs/gpu_pools.yaml'
3132
DEFAULT_PAASTA_VOLUME_PATH = '/etc/paasta/volumes.json'
3233
DEFAULT_SPARK_MESOS_SECRET_FILE = '/nail/etc/paasta_spark_secret'
@@ -348,9 +349,10 @@ def _get_k8s_spark_env(
348349
spark_env.update(
349350
{
350351
'spark.kubernetes.authenticate.serviceAccountName': service_account_name,
352+
'spark.kubernetes.authenticate.executor.serviceAccountName': service_account_name,
351353
},
352354
)
353-
elif not include_self_managed_configs:
355+
if not include_self_managed_configs:
354356
spark_env.update({
355357
'spark.master': f'k8s://{k8s_server_address}',
356358
})
@@ -1125,8 +1127,8 @@ def get_spark_conf(
11251127
spark_conf = {**(spark_opts_from_env or {}), **_filter_user_spark_opts(user_spark_opts)}
11261128
random_postfix = utils.get_random_string(4)
11271129

1128-
if aws_creds is not None and aws_creds[2] is not None:
1129-
spark_conf['spark.hadoop.fs.s3a.aws.credentials.provider'] = AWS_ENV_CREDENTIALS_PROVIDER
1130+
if (aws_creds is not None and aws_creds[2] is not None) or service_account_name is not None:
1131+
spark_conf['spark.hadoop.fs.s3a.aws.credentials.provider'] = AWS_DEFAULT_CREDENTIALS_PROVIDER
11301132

11311133
# app_name from env is already appended with port and time to make it unique
11321134
app_name = (spark_opts_from_env or {}).get('spark.app.name')

0 commit comments

Comments
 (0)