|
| 1 | +--- |
| 2 | +title: Encryption at rest |
| 3 | +titleSuffix: SQL Server Big Data Clusters |
| 4 | +description: Learn all about encryption at rest on a SQL Server 2019 Big Data Cluster. |
| 5 | +author: dacoelho |
| 6 | +ms.author: dacoelho |
| 7 | +ms.reviewer: mikeray |
| 8 | +ms.metadata: seo-lt-2019 |
| 9 | +ms.date: 10/19/2020 |
| 10 | +ms.topic: conceptual |
| 11 | +ms.prod: sql |
| 12 | +ms.technology: big-data-cluster |
| 13 | +--- |
| 14 | + |
| 15 | +# Encryption at rest concepts and configuration guide |
| 16 | + |
| 17 | +Starting from SQL Server Big Data Clusters CU8, a comprehensive encryption at rest feature set is available to provide application level encryption to all data stored in the platform. This guide documents the concepts, architecture, and configuration for the encryption at rest feature set for SQL Server Big Data Clusters. |
| 18 | + |
| 19 | +SQL Server Big Data Clusters stores data in the following two locations: |
| 20 | + |
| 21 | +* __SQL Server__ master instance |
| 22 | +* __HDFS__ used by Storage pool and Spark. |
| 23 | + |
| 24 | +To be able to transparently encrypt data in SQL Server Big Data Clusters, there are two possible approaches: |
| 25 | + |
| 26 | +* __Volume encryption__. This approach is supported by the Kubernetes platform and is expected as a best practice for Big Data Clusters deployments. This guide does not cover volume encryption. Consult your Kubernetes platform or appliance documentation for guides on how to properly encrypt volumes that will be used for SQL Server Big Data Clusters. |
| 27 | +* __Application level encryption__. This architecture refers to the encryption of data by the application handling the data before it is written to disk. In case the volumes are exposed, an attacker wouldn’t be able to restore data artifacts elsewhere, unless the destination system also has been configured with the same encryption keys. |
| 28 | + |
| 29 | +The Encryption at Rest feature set of SQL Server Big Data Clusters supports the core scenario of application level encryption for the SQL Server and HDFS components. |
| 30 | + |
| 31 | +The following capabilities are provided: |
| 32 | + |
| 33 | +* __System-managed encryption at rest__. This capability is available in CU8. |
| 34 | +* __User-managed encryption at rest (BYOK)__, with both service-managed and external key provider integrations. Currently only service-managed user created keys are supported. |
| 35 | + |
| 36 | +## Key Definitions |
| 37 | + |
| 38 | +### SQL Server Big Data Clusters key management service (KMS) |
| 39 | + |
| 40 | +A Controller hosted service responsible for managing keys and certificates for the Encryption at Rest feature set for the SQL Server BDC cluster. It’s a service that supports the following features: |
| 41 | + |
| 42 | +* Secure management and storage of keys and certificates used for encryption at rest. |
| 43 | +* Hadoop KMS compatibility. It acts as the key management service for HDFS component on BDC. |
| 44 | +* SQL Server TDE certificate management. |
| 45 | + |
| 46 | +The following feature is not supported at this time: |
| 47 | +* *Keys Versioning support*. |
| 48 | + |
| 49 | +We will reference this service as __BDC KMS__ throughout the rest of this document. Also the term __BDC__ is used to refer to the __SQL Server Big Data Clusters__ computing platform. |
| 50 | + |
| 51 | +### System-managed keys and certificates |
| 52 | + |
| 53 | +The BDC KMS service will manage all keys and certificates for SQL Server and HDFS. |
| 54 | + |
| 55 | +### User provided certificates |
| 56 | + |
| 57 | +User provided keys and certificates to be managed by BDC KMS, commonly known as bring your own key (BYOK). |
| 58 | + |
| 59 | +### External providers |
| 60 | + |
| 61 | +External key solutions compatible with BDC KMS for external delegation. This capability isn't supported at this time. |
| 62 | + |
| 63 | +## Encryption at rest on SQL Server Big Data Clusters CU8 |
| 64 | + |
| 65 | +SQL Server Big Data Clusters CU8 is the initial release of the Encryption at rest feature set. Read this document carefully to completely assess your scenario. |
| 66 | + |
| 67 | +The feature set introduces the __BDC KMS controller service__ to provide system-managed keys and certificates for data encryption at rest on both SQL Server and HDFS. Those keys and certificates are service-managed and this documentation provides operational guidance on how to interact with the service. |
| 68 | + |
| 69 | +* __SQL Server__ instances leverage the established [Transparent Data Encryption (TDE)](../relational-databases/security/encryption/transparent-data-encryption.md) functionality. |
| 70 | +* __HDFS__ uses native Hadoop KMS within each pod to interact with BDC KMS on the controller. This enables HDFS encryption zones, which provide secure paths on HDFS. |
| 71 | + |
| 72 | +### SQL Server instances |
| 73 | + |
| 74 | +* A system-generated certificate will be installed on SQL Server pods to be used with TDE commands. The system-managed certificate naming standard is `TDECertificate` + `timestamp`. For example, `TDECertificate2020_09_15_22_46_27`. |
| 75 | +* Master instance BDC provisioned databases and user databases won’t be encrypted automatically. DBAs may use the installed certificate to encrypt any database. |
| 76 | +* Compute pool and storage pool will be automatically encrypted using the system-generated certificate. |
| 77 | +* Data pool encryption, albeit technically possible using T-SQL `EXECUTE AT` commands, is discouraged and unsupported at this time. Using this technique to encrypt data pool databases might not be effective and encryption may not be happening at the desired state. It also creates an incompatible upgrade path towards next releases. |
| 78 | +* There is no certificate rotation at this time. It is supported to decrypt and then encrypt with a new certificate using T-SQL commands if not on HA deployments. |
| 79 | +* Encryption monitoring happens through existing standard SQL Server DMVs for TDE. |
| 80 | +* It is supported to back up and restore a TDE enabled database into the cluster. |
| 81 | +* HA is supported. If a database on the primary instance of SQL Server is encrypted, then all secondary replica of the database will be encrypted as well. |
| 82 | + |
| 83 | +### HDFS encryption zones |
| 84 | + |
| 85 | +* [Active Directory integration](active-directory-prerequisites.md) is required to enable the encryption zones feature for HDFS. |
| 86 | +* A system-generated key will be provisioned in Hadoop KMS. The key name is `securelakekey`. On CU8 the default key is 256-bit and we support 256-bit AES encryption. |
| 87 | +* A default encryption zone will be provisioned using the above system-generated key on a path named `/securelake`. |
| 88 | +* Users can create additional keys and encryption zones using specific instructions provided in this guide. Users will be able to choose the key size of 128, 192, or 256 during key creation. |
| 89 | +* In place key rotation for HDFS is not possible in CU8. As an alternative, the data can be moved from one encryption zone to another using distcp. |
| 90 | +* It's not supported to perform HDFS Tiering mounting on top of an encryption zone. |
| 91 | + |
| 92 | +## Configuration guide |
| 93 | + |
| 94 | +SQL Server Big Data Clusters encryption at rest is a service-managed feature and, depending on your deployment path, may require additional steps. |
| 95 | + |
| 96 | +During __new deployments of SQL Server Big Data Clusters__, CU8 onwards, __encryption at rest will be enabled and configured by default__. That means: |
| 97 | + |
| 98 | +* BDC KMS component will be deployed in the controller and will generate a default set of keys and certificates. |
| 99 | +* SQL Server will be deployed with TDE turned on and certificates will get installed by the controller. |
| 100 | +* Hadoop KMS (for HDFS) will be configured to interact with BDC KMS for encryption operations. HDFS encryption zones are configured and ready to use. |
| 101 | + |
| 102 | +Requirements and default behaviors described in the previous section apply. |
| 103 | + |
| 104 | +If __upgrading your cluster to CU8__, __read carefully the next section__. |
| 105 | + |
| 106 | +### Upgrading to CU8 |
| 107 | + |
| 108 | + > [!CAUTION] |
| 109 | + > Before upgrading to SQL Server Big Data Clusters CU8 perform a complete backup of your data. |
| 110 | +
|
| 111 | +On existing clusters, the upgrade process won't enforce encryption on user data and won't configure HDFS encryption zones. This behavior is by design and the following needs to be considered per component: |
| 112 | + |
| 113 | +* __SQL Server__ |
| 114 | + |
| 115 | + 1. __SQL Server master instance__. The upgrade process won’t affect any master instance databases and installed TDE certificates, but it is highly encouraged to back up your databases and your manually installed TDE certificates before the upgrade process. It is also advised to store those artifacts outside the SQL Server BDC cluster. |
| 116 | + 1. __Compute and storage pool__. Those databases are system-managed, volatile and will be recreated and automatically encrypted on cluster upgrade. |
| 117 | + 1. __Data pool__. Upgrade does not impact databases in the SQL Server instances part of data pool. |
| 118 | + |
| 119 | +* __HDFS__ |
| 120 | + |
| 121 | + 1. __HDFS__. The upgrade process won't touch HDFS files and folders outside encryption zones. |
| 122 | + 1. __Encryption Zones won't be configured__. The Hadoop KMS component won't be configured to use BDC KMS. In order to configure and enable HDFS encryption zones feature after upgrade follow the next section. |
| 123 | + |
| 124 | +### Enable HDFS encryption zones after upgrade |
| 125 | + |
| 126 | +Execute the following actions if you upgraded your cluster to CU8 (`azdata upgrade`) and want to enable HDFS encryption zones. |
| 127 | + |
| 128 | +Requirements: |
| 129 | + |
| 130 | +- [Active Directory](active-directory-prerequisites.md) integrated cluster. |
| 131 | + |
| 132 | +- Azure Data CLI (`azdata`) configured and logged into the cluster in AD mode. |
| 133 | + |
| 134 | +Follow the following procedure to reconfigure the cluster with encryption zones support. |
| 135 | + |
| 136 | +1. After performing the upgrade with `azdata`, save the following scripts. |
| 137 | + |
| 138 | + Scripts execution requirements: |
| 139 | + |
| 140 | + * Both scripts should be located in the same directory. |
| 141 | + * `kubectl` on `PATH |
| 142 | + * ```config``` file for Kubernetes in the folder ```$HOME/.kube``` |
| 143 | + |
| 144 | + This script should be named __```run-key-provider-patch.sh```__: |
| 145 | + |
| 146 | + ```console |
| 147 | + #!/bin/bash |
| 148 | + |
| 149 | + if [[ -z "${BDC_DOMAIN}" ]]; then |
| 150 | + echo "BDC_DOMAIN environment variable with the domain name of the cluster is not defined." |
| 151 | + exit 1 |
| 152 | + fi |
| 153 | + |
| 154 | + if [[ -z "${BDC_CLUSTER_NS}" ]]; then |
| 155 | + echo "BDC_CLUSTER_NS environment variable with the cluster namespace is not defined." |
| 156 | + exit 1 |
| 157 | + fi |
| 158 | + |
| 159 | + kubectl get configmaps -n test |
| 160 | + |
| 161 | + diff <(kubectl get configmaps mssql-hadoop-storage-0-configmap -n $BDC_CLUSTER_NS -o json | ./updatekeyprovider.py) <(kubectl get configmaps mssql-hadoop-storage-0-configmap -n $BDC_CLUSTER_NS -o json | python -m json.tool) |
| 162 | + |
| 163 | + diff <(kubectl get configmaps mssql-hadoop-sparkhead-configmap -n $BDC_CLUSTER_NS -o json | ./updatekeyprovider.py) <(kubectl get configmaps mssql-hadoop-sparkhead-configmap -n $BDC_CLUSTER_NS -o json | python -m json.tool) |
| 164 | + |
| 165 | + # Replace the config maps. |
| 166 | + # |
| 167 | + kubectl replace -n $BDC_CLUSTER_NS -o json -f <(kubectl get configmaps mssql-hadoop-storage-0-configmap -n $BDC_CLUSTER_NS -o json | ./updatekeyprovider.py) |
| 168 | + |
| 169 | + kubectl replace -n $BDC_CLUSTER_NS -o json -f <(kubectl get configmaps mssql-hadoop-sparkhead-configmap -n $BDC_CLUSTER_NS -o json | ./updatekeyprovider.py) |
| 170 | + |
| 171 | + # Restart the pods which need to have the necessary changes with the core-site.xml |
| 172 | + kubectl delete pods -n $BDC_CLUSTER_NS nmnode-0-0 |
| 173 | + kubectl delete pods -n $BDC_CLUSTER_NS storage-0-0 |
| 174 | + kubectl delete pods -n $BDC_CLUSTER_NS storage-0-1 |
| 175 | + |
| 176 | + # Wait for sometime for pods to restart |
| 177 | + # |
| 178 | + sleep 300 |
| 179 | + |
| 180 | + # Check for the KMS process status. |
| 181 | + # |
| 182 | + kubectl exec -n $BDC_CLUSTER_NS -c hadoop nmnode-0-0 -- bash -c 'ps aux | grep kms' |
| 183 | + kubectl exec -n $BDC_CLUSTER_NS -c hadoop storage-0-0 -- bash -c 'ps aux | grep kms' |
| 184 | + kubectl exec -n $BDC_CLUSTER_NS -c hadoop storage-0-1 -- bash -c 'ps aux | grep kms' |
| 185 | + ``` |
| 186 | + |
| 187 | + This script should be named __```updatekeyprovider.py```__: |
| 188 | + |
| 189 | + ```python |
| 190 | + #!/usr/bin/env python3 |
| 191 | + |
| 192 | + import json |
| 193 | + import re |
| 194 | + import sys |
| 195 | + import xml.etree.ElementTree as ET |
| 196 | + import os |
| 197 | + |
| 198 | + class CommentedTreeBuilder(ET.TreeBuilder): |
| 199 | + def comment(self, data): |
| 200 | + self.start(ET.Comment, {}) |
| 201 | + self.data(data) |
| 202 | + self.end(ET.Comment) |
| 203 | + |
| 204 | + domain_name = os.environ['BDC_DOMAIN'] |
| 205 | + |
| 206 | + parser = ET.XMLParser(target=CommentedTreeBuilder()) |
| 207 | + |
| 208 | + core_site = 'core-site.xml' |
| 209 | + j = json.load(sys.stdin) |
| 210 | + cs = j['data'][core_site] |
| 211 | + csxml = ET.fromstring(cs, parser=parser) |
| 212 | + props = [prop.find('value').text for prop in csxml.findall( |
| 213 | + "./property/name/..[name='hadoop.security.key.provider.path']")] |
| 214 | + |
| 215 | + kms_provider_path='' |
| 216 | + |
| 217 | + for x in range(5): |
| 218 | + if len(kms_provider_path) != 0: |
| 219 | + kms_provider_path = kms_provider_path + ';' |
| 220 | + kms_provider_path = kms_provider_path + 'nmnode-0-0.' + domain_name |
| 221 | + |
| 222 | + if len(props) == 0: |
| 223 | + prop = ET.SubElement(csxml, 'property') |
| 224 | + name = ET.SubElement(prop, 'name') |
| 225 | + name.text = 'hadoop.security.key.provider.path' |
| 226 | + value = ET.SubElement(prop, 'value') |
| 227 | + value.text = 'kms://https@' + kms_provider_path + ':9600/kms' |
| 228 | + cs = ET.tostring(csxml, encoding='utf-8').decode('utf-8') |
| 229 | + |
| 230 | + j['data'][core_site] = cs |
| 231 | + |
| 232 | + kms_site = 'kms-site.xml.tmpl' |
| 233 | + ks = j['data'][kms_site] |
| 234 | + |
| 235 | + kp_uri_regex = re.compile('(<name>hadoop.kms.key.provider.uri</name>\s*<value>\s*)(.*)(\s*</value>)', re.MULTILINE) |
| 236 | + |
| 237 | + def replace_uri(match_obj): |
| 238 | + key_provider_uri = 'bdc://https@hdfsvault-svc.' + domain_name |
| 239 | + if match_obj.group(2) == 'jceks://file@/var/run/secrets/keystores/kms/kms.jceks' or match_obj.group(2) == key_provider_uri: |
| 240 | + return match_obj.group(1) + key_provider_uri + match_obj.group(3) |
| 241 | + return match_obj.group(0) |
| 242 | + |
| 243 | + ks = kp_uri_regex.sub(replace_uri, ks) |
| 244 | + |
| 245 | + j['data'][kms_site] = ks |
| 246 | + print(json.dumps(j, indent=4, sort_keys=True)) |
| 247 | + ``` |
| 248 | + |
| 249 | + Execute __```run-key-provider-patch.sh```__ with the appropriate parameters. |
| 250 | + |
| 251 | +## Next steps |
| 252 | + |
| 253 | +To learn more about how to effectively use encryption at rest SQL Server Big Data Clusters see the following articles: |
| 254 | + |
| 255 | +- [Encryption at rest - SQL Server TDE](encryption-at-rest-sql-server-tde.md) |
| 256 | +- [Encryption at rest - HDFS encryption zones](encryption-at-rest-hdfs-encryption-zones.md) |
| 257 | + |
| 258 | +To learn more about the [!INCLUDE[big-data-clusters-2019](../includes/ssbigdataclusters-ss-nover.md)], see the following overview: |
| 259 | + |
| 260 | +- [What are [!INCLUDE[big-data-clusters-2019](../includes/ssbigdataclusters-ver15.md)]?](big-data-cluster-overview.md) |
0 commit comments