You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/spark-k8s/pages/usage-guide/security.adoc
+33-99Lines changed: 33 additions & 99 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,16 +6,16 @@ Currently, the only supported authentication mechanism is Kerberos, which is dis
6
6
7
7
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.
8
8
9
-
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.
9
+
In this guide we show how to configure Spark applications to use Kerberos while accessing data in HDFS cluster. The Stackable Secret Operator is used to generate the keytab files. In production environments, users might have different means to provision the keytab files.
10
10
11
11
12
12
== Prerequisites
13
13
14
14
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].
15
15
16
-
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.
16
+
For details on HDFS and Kerberos, see the xref:hdfs-operator:usage-guide:security.adoc[HDFS operator guide].
17
17
18
-
This guide makes use of a SecretClass named `kerberos-default`. It is assumed that this class exists and is configured with a `kerberosBackend`.
18
+
This guide makes use of a SecretClass named `kerberos`. It is assumed that this class exists and is configured with a `kerberosBackend`.
19
19
20
20
== Steps
21
21
@@ -29,33 +29,42 @@ There are three steps to configure a Spark application to use Kerberos:
29
29
30
30
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.
31
31
32
-
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.
32
+
In the example below, the Stackable Secret Operator is used to provision the keytab via a volume claim. For brevity the configuration shared by the job, driver and executor pods is only specified once and then referenced in all other places where needed.
<4> Name of the Secret class used to provision the keytab.
71
-
<5> Scope of the Secret.
72
-
<6> Name of the user for which the keytab is provisioned.
73
-
74
-
75
-
=== Job pod
76
-
77
-
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.
<2> Name of the Secret class used to provision the keytab.
111
-
<3> Scope of the Secret.
112
-
<4> Name of the user for which the keytab is provisioned.
113
-
<5> Mount the keytab volume in the job pod.
114
-
76
+
<1> Mount the keytab from the kerberos volume.
77
+
<2> Mount the `krb5.conf` file from the kerberos volume.
78
+
<3> Mount the Hadoop configuration files from the `hdfs-config` module.
79
+
<4> Hadoop configuration files as published by the Hdfs operator.
80
+
<5> Name of the Secret class used to provision the keytab.
81
+
<6> Scope of the Secret.
82
+
<7> Name of the user for which the keytab is provisioned.
115
83
116
84
117
85
=== Spark application
118
86
119
87
Instruct the Spark application to use Kerberos by setting the `spark.kerberos.keytab` and `spark.kerberos.principal` properties in the `SparkApplication` CRD.
120
88
121
-
Finally, instruct Spark to use the keytab and `krb5.conf` files provisioned in the previous steps.
<2> Principal name. This needs to have the format `<SERVICE_NAME>.default.svc.cluster.local@<REALM>` where `SERVICE_NAME` matches the volume claim annotation `secrets.stackable.tech/kerberos.service.names` and `REALM` must be `CLUSTER.LOCAL`.
133
-
<3> Location of the Kerberos configuration for the application driver.
134
-
<4> Location of the Kerberos configuration for the application executors.
135
-
136
-
=== Hadoop
137
-
138
-
When reading and writing data from a kerberized Hadoop cluster, a the HDFS discovery map must mounted the `SparkApplication` pods as follows:
139
-
140
-
For the driver and executor pods:
141
-
142
-
[source,yaml]
143
-
----
144
-
...
145
-
driver:
146
-
config:
147
-
volumeMounts:
148
-
- name: hdfs-config
149
-
mountPath: /etc/hadoop/conf <1>
150
-
executor:
151
-
config:
152
-
volumeMounts:
153
-
- name: hdfs-config
154
-
mountPath: /etc/hadoop/conf <2>
155
-
volumes:
156
-
- name: hdfs-config
157
-
configMap:
158
-
name: hdfs-discovery-cm <3>
159
-
----
160
-
<1> Location of the HDFS configuration for the driver.
161
-
<2> Location of the HDFS configuration for the executors.
162
-
<3> Name of the HDFS discovery ConfigMap as published by the HDFS operator.
96
+
<2> Principal name. This needs to have the format `<SERVICE_NAME>.default.svc.cluster.local@<REALM>` where `SERVICE_NAME` matches the volume claim annotation `secrets.stackable.tech/kerberos.service.names` and `REALM` must be `CLUSTER.LOCAL` unless a different realm was used explicitly. In that case, the `KERBEROS_REALM` environment variable must also be set accordingly.
0 commit comments