-
-
Notifications
You must be signed in to change notification settings - Fork 3
docs: Kerberos example #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f1d0beb
doc(kerberos): first draft
razvan 10ca2ee
fix: add logging and kerberos to nav.adoc
razvan 77dc351
fix: rename kerberos.adoc to security.adoc
razvan 6b6cefc
more security docs
razvan 44aa08a
fix typos and grammar
razvan d340f84
fix: language tool lints
razvan d9405d8
more on hdfs
razvan 3b94013
Merge branch 'main' into docs/kerberos-example
razvan 818992d
update
razvan 44b1714
Update docs/modules/spark-k8s/pages/usage-guide/security.adoc
razvan cbb4365
Update docs/modules/spark-k8s/pages/usage-guide/security.adoc
razvan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,134 @@ | ||
= Security | ||
|
||
== Authentication | ||
|
||
Currently, the only supported authentication mechanism is Kerberos, which is disabled by default. | ||
|
||
Kerberos is a network authentication protocol that works on the basis of "tickets" to allow nodes communicating over a non-secure network to prove their identity to one another securely. It is used in Spark to authenticate users and to secure communication between Spark components. | ||
|
||
In this guide we show how to configure Spark applications to use Kerberos. The Stackable Secret Operator is used to generate the keytab files. In production environments, users might have different means to provision the keytab files. | ||
|
||
|
||
== Prerequisites | ||
|
||
It is assumed that you have a KDC server running in your cluster and that the Stackable Secret Operator is configured to provision the keytab files as described in xref:home:secret-operator:secretclass.adoc#backend-kerberoskeytab[secret-operator documentation]. | ||
|
||
If the Spark application processes data from a kerberized Hadoop cluster, follow the xref:hdfs-operator:usage-guide:security.adoc[HDFS operator guide] to configure HDFS with Kerberos. | ||
|
||
This guide makes use of a SecretClass named `kerberos-default`. It is assumed that this class exists and is configured with a `kerberosBackend`. | ||
|
||
== Steps | ||
|
||
There are three steps to configure a Spark application to use Kerberos: | ||
|
||
1. Provision the Spark `driver` end `executor` pods with the keytab and `krb5.conf` files. | ||
2. Provision the Spark `job` pod with the keytab and `krb5.conf` files. | ||
3. Instruct the Spark application to use Kerberos. | ||
|
||
=== Driver and Executor pods | ||
|
||
Install the keytab and the `krb5.conf` files in the Spark pods. The keytab file contains the credentials of the user that is used to authenticate with the Kerberos server. The `krb5.conf` file contains the configuration settings for the Kerberos client. | ||
|
||
In the example below, the Stackable Secret Operator is used to provision the keytab via a volume claim. The `krb5.conf` file is mounted as a ConfigMap. | ||
|
||
[source,yaml] | ||
---- | ||
... | ||
driver: | ||
config: | ||
volumeMounts: | ||
- name: kerberos | ||
mountPath: /stackable/kerberos <1> | ||
executor: | ||
config: | ||
volumeMounts: | ||
- name: kerberos | ||
mountPath: /stackable/kerberos <2> | ||
volumes: | ||
- name: kerberos-config | ||
configMap: | ||
name: krb5-kdc <3> | ||
- name: kerberos | ||
ephemeral: | ||
volumeClaimTemplate: | ||
metadata: | ||
annotations: | ||
secrets.stackable.tech/class: kerberos-default <4> | ||
secrets.stackable.tech/scope: service=spark-teragen <5> | ||
secrets.stackable.tech/kerberos.service.names: testuser <6> | ||
spec: | ||
storageClassName: secrets.stackable.tech | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: "1" | ||
---- | ||
<1> Mount the keytab volume in the driver pod. | ||
<2> Mount the keytab volume in the executor pods. | ||
<3> Mount the `krb5.conf` file as a ConfigMap. | ||
<4> Name of the Secret class used to provision the keytab. | ||
<5> Scope of the Secret. | ||
<6> Name of the user for which the keytab is provisioned. | ||
|
||
|
||
=== Job pod | ||
|
||
Install the keytab and the `krb5.conf` files in the Spark `job` pod. This must be currently done via pod overrides. This is because the Spark application volumes are not currently visible to the `job` pod. We hope to address this limitation in a future release. | ||
|
||
[source,yaml] | ||
---- | ||
job: | ||
podOverrides: | ||
spec: | ||
volumes: | ||
- name: kerberos-config | ||
configMap: | ||
name: krb5-kdc <1> | ||
- name: kerberos | ||
ephemeral: | ||
volumeClaimTemplate: | ||
metadata: | ||
annotations: | ||
secrets.stackable.tech/class: kerberos-default <2> | ||
secrets.stackable.tech/scope: service=spark-teragen <3> | ||
secrets.stackable.tech/kerberos.service.names: testuser <4> | ||
spec: | ||
storageClassName: secrets.stackable.tech | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: "1" | ||
containers: | ||
- name: spark-submit | ||
volumeMounts: | ||
- name: kerberos <5> | ||
mountPath: /stackable/kerberos | ||
---- | ||
<1> Mount the `krb5.conf` file as a ConfigMap. | ||
<2> Name of the Secret class used to provision the keytab. | ||
<3> Scope of the Secret. | ||
<4> Name of the user for which the keytab is provisioned. | ||
<5> Mount the keytab volume in the job pod. | ||
|
||
|
||
|
||
=== Spark application | ||
|
||
Instruct the Spark application to use Kerberos by setting the `spark.kerberos.keytab` and `spark.kerberos.principal` properties in the `SparkApplication` CRD. | ||
|
||
Finally, instruct Spark to use the keytab and `krb5.conf` files provisioned in the previous steps. | ||
|
||
[source,yaml] | ||
---- | ||
sparkConf: | ||
"spark.kerberos.keytab": "/stackable/kerberos/keytab" | ||
"spark.kerberos.principal": "testuser/[email protected]" | ||
"spark.driver.extraJavaOptions": "-Djava.security.krb5.conf=/stackable/kerberos/krb5.conf" | ||
"spark.executor.extraJavaOptions": "-Djava.security.krb5.conf=/stackable/kerberos/krb5.conf" | ||
---- | ||
|
||
=== Hadoop | ||
|
||
TODO: where is the kerberized HDFS discovery config map coming from ? | ||
razvan marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.