S3 keys outside the values file,
pods with a known identity.
Three scenarios: taking the S3 keys out of the values file, understanding the identity of the pods, and using the Ozone keys with security enabled. Each one covers: the values file block commented line by line and a step-by-step with verification.
The tdp-spark chart provides no S3 keys or passwords of its own: storage access keys are yours, in the values file or a Secret, and the master, workers and History Server read them from the same place. For installation, workers and History Server, see Spark Configuration.
Your environment
If you fill in your environment details here, the examples and commands on the page use what you entered. The namespace, the release name and the values file are your choices, not the chart's.
Scenarios
- 1 · S3 keys
- 2 · Pod identity
- 3 · Ozone with security
Move keys out of the values file and load them as environment variables.
Spark accesses S3-compatible storage with a key pair, and the chart provides none: the endpoint and keys are yours. Writing the keys in hadoopConfig works, but they remain in the values file and the core-site.xml ConfigMap. The alternative is a Secret containing AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, loaded as environment variables in the master and workers: Spark copies these values to fs.s3a.access.key and fs.s3a.secret.key. The image's Python libraries, such as PyIceberg, read the same variables.
No keys: neither in hadoopConfig nor in a Secret (spark.master.extraEnvVarsSecret and spark.worker.extraEnvVarsSecret are empty). The credentials provider reads keys from hadoopConfig or the pod's AWS_* variables.
Uses the Secret in spark.historyServer.extraEnvVarsSecret or, when empty, the master's Secret, including in the init container that creates the event log directory.
Where the pods get the S3 keys
Where keys are stored
- Spark pods. The master, workers and History Server read S3 keys from core-site.xml or the pod's AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variables. The History Server uses the master's Secret when it has none of its own.
- Keys in the values file. fs.s3a.access.key and fs.s3a.secret.key in hadoopConfig become core-site.xml properties in a ConfigMap. Chart default:
no keys. (tdp-spark.hadoopConfig) - S3 storage. The endpoint is set in hadoopConfig, with no chart default.
Where keys are stored: In the values file
- Spark pods. The master, workers and History Server read S3 keys from core-site.xml or the pod's AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variables. The History Server uses the master's Secret when it has none of its own.
- Keys in the values file. fs.s3a.access.key and fs.s3a.secret.key in hadoopConfig become core-site.xml properties in a ConfigMap. Chart default:
no keys. (tdp-spark.hadoopConfig) - S3 storage. The endpoint is set in hadoopConfig, with no chart default.
Where keys are stored: In a Secret
- Spark pods. The master, workers and History Server read S3 keys from core-site.xml or the pod's AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variables. The History Server uses the master's Secret when it has none of its own.
- Secret containing the keys. A Secret containing AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, loaded as environment variables in the master and workers. Spark copies them to fs.s3a.access.key and fs.s3a.secret.key. Chart default:
none. (spark.master.extraEnvVarsSecret · spark.worker.extraEnvVarsSecret) - S3 storage. The endpoint is set in hadoopConfig, with no chart default.
In the values file. Keys are set in hadoopConfig and reach core-site.xml. This is the shortest approach. In the values file: Best suited when the environment is for testing.
1tdp-spark:2hadoopConfig:3 fs.s3a.endpoint: "http://<S3_ENDPOINT>:<S3_PORT>"4 fs.s3a.access.key: "<S3_ACCESS_KEY>"5 fs.s3a.secret.key: "<S3_SECRET_KEY>"
They remain in your values file and the core-site.xml ConfigMap. To move them out, choose In a Secret above.
- Plaintext keys (linha 4). They remain in your values file and the core-site.xml ConfigMap. To move them out, choose In a Secret above.
In a Secret. The Secret contains exactly the keys AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, because each key becomes an environment variable with the same name. The endpoint remains in hadoopConfig. In a Secret: Best suited when the keys cannot stay in the values file or in the core-site.xml ConfigMap.
1tdp-spark:2hadoopConfig:3 fs.s3a.endpoint: "http://<S3_ENDPOINT>:<S3_PORT>"45spark:6master:7 extraEnvVarsSecret: <S3_SECRET_NAME>8worker:9 extraEnvVarsSecret: <S3_SECRET_NAME>
fs.s3a.access.key and fs.s3a.secret.key are removed from the values file.
- No keys here (linha 2). fs.s3a.access.key and fs.s3a.secret.key are removed from the values file.
- Master (linha 7). Each Secret key becomes an environment variable in the master. The History Server uses this same Secret when spark.historyServer.extraEnvVarsSecret is empty.
- Workers (linha 9). The same Secret in the workers.
Create the SecretOpcional
Only if you chose In a Secret above. The Secret belongs in the same namespace as Spark.
kubectl -n <NAMESPACE> create secret generic <S3_SECRET_NAME> \
--from-literal=AWS_ACCESS_KEY_ID=<S3_ACCESS_KEY> \
--from-literal=AWS_SECRET_ACCESS_KEY=<S3_SECRET_KEY>
Apply to the release
Pods start with keys from the chosen location.
helm upgrade --install <RELEASE_NAME> oci://registry.tecnisys.com.br/tdp/charts/tdp-spark \
--version 3.0.3 \
-n <NAMESPACE> --create-namespace \
-f <VALUES_FILE>
Success criteria
Running and an application reads and writes to the bucket, as in the Integrations - Spark test.If pods remain in CreateContainerConfigError
The Secret does not exist in the Spark namespace or does not contain both keys. See When something goes wrong.
Drivers running outside this chart's pods, such as those in Jupyter notebooks and Airflow tasks, do not receive these variables: they need their own AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. See Integrations - Airflow.
ServiceAccount, pod user and group, OpenShift and Hadoop authentication.
You want to know which identity Spark runs with in the cluster, to review permissions or install on OpenShift. The master, workers and History Server use the ServiceAccount in the spark.serviceAccount block, created by the chart. Pods run with a fixed user and group, except on OpenShift, where the restricted-v2 SCC assigns the UID and GID. On the Hadoop side, authentication is simple: Kerberos is disabled in the default core-site.xml and spark-defaults.conf, and the Hadoop user is spark.
Created by the chart (spark.serviceAccount.create), with the name tdp-spark-sa.
Fixed in spark.master.securityContext, spark.worker.securityContext and spark.historyServer.podSecurityContext (values in the block below).
With global.compatibility.openshift.adaptSecurityContext set to auto, the default, pods stop fixing the UID and GID on OpenShift, and the restricted-v2 SCC assigns them. force does this in any cluster. disabled never does.
Authentication is simple and authorization is disabled in hadoopConfig. Hadoop user spark.
1spark:2serviceAccount:3 create: true4 name: "tdp-spark-sa"5master:6 securityContext:7 runAsUser: 10018 runAsGroup: 10019 fsGroup: 100110worker:11 securityContext:12 runAsUser: 100113 runAsGroup: 100114 fsGroup: 100115historyServer:16 podSecurityContext:17 runAsUser: 100118 runAsGroup: 100119 fsGroup: 10012021global:22compatibility:23 openshift:24 adaptSecurityContext: auto
The ServiceAccount of the master, workers and History Server. This is the spark subchart block, at the root of the file.
- ServiceAccount (linha 2). The ServiceAccount of the master, workers and History Server. This is the spark subchart block, at the root of the file.
- UID and GID (linha 7). User, group and volume group of the pods, outside OpenShift.
- History Server (linha 16). The History Server has its own podSecurityContext, with the same defaults.
- OpenShift (linha 24). auto: on OpenShift, the restricted-v2 SCC assigns the UID and GID. force: in any cluster. disabled: never.
Check the pods' ServiceAccount
The release's pods use the chart's ServiceAccount.
kubectl -n <NAMESPACE> get pods -l app.kubernetes.io/instance=<RELEASE_NAME> \
-o custom-columns=POD:.metadata.name,SA:.spec.serviceAccountName
Success criteria
spark.serviceAccount.name.The keys accepted by the S3 Gateway when Ozone security is enabled.
Spark stores data in the Ozone S3 Gateway. With Ozone defaults, without Kerberos, the S3 Gateway does not check keys: it accepts any request, and any nonempty key pair works. In this mode the ozone-s3-credentials Secret does not exist. With Ozone security enabled through Kerberos (tdp-ozone.kerberos.enabled), the S3 Gateway starts validating each request, and only keys issued by Ozone itself work: the key in the ozone-s3-credentials Secret, which the Ozone chart populates, or an additional S3 user's key. You provide that key to Spark.
When you enable Ozone security through the kit, Spark starts reading keys from the ozone-s3-credentials Secret in the master, workers and History Server. Pods already running need a restart. See Ozone security in the GitOps kit.
The procedure below: read keys from the ozone-s3-credentials Secret and copy them to a Secret containing AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, as in scenario 1.
Ozone security enabled, the ozone-s3-credentials Secret populated and the warehouse bucket created. The commands below assume Ozone is in the same namespace as Spark, as in the GitOps kit. If it is in another namespace, read the Secret in the Ozone namespace. To give Spark its own key instead of the S3 administrator's key, issue it as described in Security - Ozone and use it in step 2.
The S3 keys with Ozone security
- Spark pods. The master, workers and History Server read S3 keys from core-site.xml or the pod's AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variables. The History Server uses the master's Secret when it has none of its own.
- Secret containing the keys. A Secret containing AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, loaded as environment variables in the master and workers. Spark copies them to fs.s3a.access.key and fs.s3a.secret.key. With Ozone security enabled, the values come from the ozone-s3-credentials Secret or an additional S3 user. Chart default:
none. (spark.master.extraEnvVarsSecret · spark.worker.extraEnvVarsSecret) - S3 Gateway with security. With Ozone security enabled, the S3 Gateway validates each request: only keys issued by Ozone work, such as the key in the ozone-s3-credentials Secret.
1tdp-spark:2hadoopConfig:3 fs.s3a.endpoint: "http://tdp-ozone-s3g-rest.<NAMESPACE>.svc.cluster.local:9878"45spark:6master:7 extraEnvVarsSecret: <S3_SECRET_NAME>8worker:9 extraEnvVarsSecret: <S3_SECRET_NAME>
The S3 Gateway Service, in the Ozone namespace.
- Ozone S3 Gateway (linha 3). The S3 Gateway Service, in the Ozone namespace.
- Secret containing the keys (linha 7). The Secret created in step 2 below, containing Ozone keys. The History Server uses the same Secret as the master.
Read the Ozone keys
The ozone-s3-credentials Secret stores the S3 key accepted by the S3 Gateway.
AWS_ACCESS_KEY_ID=$(kubectl -n <NAMESPACE> get secret ozone-s3-credentials -o jsonpath='{.data.aws_access_key_id}' | base64 -d)
AWS_SECRET_ACCESS_KEY=$(kubectl -n <NAMESPACE> get secret ozone-s3-credentials -o jsonpath='{.data.aws_secret_access_key}' | base64 -d)
Create the Spark Secret
The same keys, with the variable names Spark reads.
kubectl -n <NAMESPACE> create secret generic <S3_SECRET_NAME> \
--from-literal=AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" \
--from-literal=AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY"
Apply to the release
The master, workers and History Server start reading the Secret.
helm upgrade --install <RELEASE_NAME> oci://registry.tecnisys.com.br/tdp/charts/tdp-spark \
--version 3.0.3 \
-n <NAMESPACE> --create-namespace \
-f <VALUES_FILE>
Restart pods that were already running
Pods that were already running keep the old keys until restarted.
kubectl -n <NAMESPACE> rollout restart statefulset,deployment -l app.kubernetes.io/instance=<RELEASE_NAME>
Success criteria
Running and an application reads and writes to the warehouse bucket. The bucket must exist. Create it with the same keys if it does not exist yet.If access is still denied
Check that the Spark Secret contains the current keys from ozone-s3-credentials and that pods have been restarted. See When something goes wrong.
With Ozone security enabled, drivers running outside this chart's pods, such as Jupyter and Airflow drivers, also need these keys. See Integrations - Airflow.
When something goes wrong
Troubleshooting
Paste the error message or choose a symptom. The answer includes the cause, what to do and the command.
- S3 access fails: no keys. Cause: The chart has no default S3 keys: neither in hadoopConfig nor in a Secret loaded in the master and workers. What to do: Set the keys in hadoopConfig or a Secret (scenario 1).
- Access denied after enabling Ozone security. Cause: With Ozone security (Kerberos) enabled, the S3 Gateway only accepts keys issued by Ozone: the key in the ozone-s3-credentials Secret or an additional S3 user's key. What to do: Load one of these keys into the Spark Secret and restart the pods (scenario 3).
- Pods still use the old keys. Cause: Environment variables are read when the pod starts. Pods already running keep the old keys. What to do: Restart the release's StatefulSets and Deployments.
- Pods in CreateContainerConfigError. Cause: The specified Secret does not yet exist in the namespace, or does not contain the expected keys. What to do: Create the Secret in the same namespace as Spark, with the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY keys.
- Jupyter notebooks or Airflow tasks cannot access S3. Cause: Drivers running outside this chart's pods do not receive the master and worker variables. What to do: The driver itself needs AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. See Integrations - Airflow, Spark in DAGs scenario.
- Other problem. Cause: Start with pod status and namespace events. What to do: Events in chronological order show what prevents the pod from starting.
Best practices
- Prefer placeholders in the values file and provide keys through a Secret, Helm's
--setor an external secrets tool. - Enable Ozone security in any environment beyond a demonstration: without it, the S3 Gateway accepts any key.
All parameters
The chart prefix is already filled in. Keys without a prefix, such as those in the spark block, belong at the root of the values file.
15 of 15 parameters
| Parameter | Description | Chart default |
|---|---|---|
tdp-spark.hadoopConfig.fs.s3a.access.keyS3 keys | S3 access key in core-site.xml | no default |
tdp-spark.hadoopConfig.fs.s3a.secret.keyS3 keys | S3 secret key in core-site.xml | no default |
tdp-spark.hadoopConfig.fs.s3a.aws.credentials.providerS3 keys | Credentials provider: core-site.xml keys or the pod's AWS_* variables | org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider |
spark.master.extraEnvVarsSecretS3 keys | Secret loaded as environment variables in the master | "" |
spark.worker.extraEnvVarsSecretS3 keys | Secret loaded as environment variables in the workers | "" |
spark.historyServer.extraEnvVarsSecretS3 keys | Secret for the History Server and init container. When empty, the master's | "" |
spark.historyServer.extraEnvVarsS3 keys | Individual History Server variables, including keys from a Secret with other names | [] |
spark.serviceAccount.createIdentity | Creates the ServiceAccount | true |
spark.serviceAccount.nameIdentity | ServiceAccount of the master, workers and History Server | tdp-spark-sa |
spark.master.securityContextIdentity | Master UID, GID and fsGroup | 1001 |
spark.worker.securityContextIdentity | Worker UID, GID and fsGroup | 1001 |
spark.historyServer.podSecurityContextIdentity | History Server UID, GID and fsGroup | 1001 |
global.compatibility.openshift.adaptSecurityContextIdentity | On OpenShift, lets the SCC assign UID and GID: auto, force or disabled | auto |
tdp-spark.hadoopConfig.hadoop.security.authenticationHadoop | Hadoop authentication | simple |
tdp-spark.hadoopConfig.hadoop.security.authorizationHadoop | Hadoop authorization | "false" |
Next steps
Integrations
Integrations - Spark
S3 and Ozone, Iceberg and Delta Lake in Hive Metastore, Jupyter and Airflow.