Skip to content

Commit 0f18330

Browse files
committed
OSDOCS-3633 Enable Azure DiskEncryptionSets at install time
1 parent e8408c7 commit 0f18330

11 files changed

+283
-0
lines changed

_topic_maps/_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ Topics:
182182
File: installing-azure-account
183183
- Name: Manually creating IAM
184184
File: manually-creating-iam-azure
185+
- Name: Enabling user-managed encryption on Azure
186+
File: enabling-user-managed-encryption-azure
185187
- Name: Installing a cluster quickly on Azure
186188
File: installing-azure-default
187189
- Name: Installing a cluster on Azure with customizations
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
:_content-type: ASSEMBLY
2+
[id="enabling-user-managed-encryption-azure"]
3+
= Enabling user-managed encryption for Azure
4+
include::_attributes/common-attributes.adoc[]
5+
:context: enabling-user-managed-encryption-azure
6+
7+
toc::[]
8+
9+
In {product-title} version {product-version}, you can install a cluster with a user-managed encryption key in Azure. To enable this feature, you can prepare an Azure DiskEncryptionSet before installation, modify the `install-config.yaml` file, and then perform post-installation steps.
10+
11+
include::modules/installation-azure-preparing-diskencryptionsets.adoc[leveloffset=+1]
12+
13+
[id="enabling-disk-encryption-sets-azure-next-steps"]
14+
== Next steps
15+
16+
* Install an {product-title} cluster:
17+
** xref:../../installing/installing_azure/installing-azure-customizations.adoc#installing-azure-customizations[Install a cluster with customizations on installer-provisioned infrastructure]
18+
** xref:../../installing/installing_azure/installing-azure-network-customizations.adoc#installing-azure-network-customizations[Install a cluster with network customizations on installer-provisioned infrastructure]
19+
** xref:../../installing/installing_azure/installing-azure-vnet.adoc#installing-azure-vnet[Install a cluster into an existing VNet on installer-provisioned infrastructure]
20+
** xref:../../installing/installing_azure/installing-azure-private.adoc#installing-azure-private[Install a private cluster on installer-provisioned infrastructure]
21+
** xref:../../installing/installing_azure/installing-azure-government-region.adoc#installing-azure-government-region[Install a cluster into an government region on installer-provisioned infrastructure]

installing/installing_azure/installing-azure-customizations.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ parameters in the `install-config.yaml` file before you install the cluster.
1818
* You xref:../../installing/installing_azure/installing-azure-account.adoc#installing-azure-account[configured an Azure account] to host the cluster and determined the tested and validated region to deploy the cluster to.
1919
* If you use a firewall, you xref:../../installing/install_config/configuring-firewall.adoc#configuring-firewall[configured it to allow the sites] that your cluster requires access to.
2020
* If the cloud identity and access management (IAM) APIs are not accessible in your environment, or if you do not want to store an administrator-level credential secret in the `kube-system` namespace, you can xref:../../installing/installing_azure/manually-creating-iam-azure.adoc#manually-creating-iam-azure[manually create and maintain IAM credentials].
21+
* If you use customer-managed encryption keys, you xref:../../installing/installing_azure/enabling-user-managed-encryption-azure.adoc#enabling-user-managed-encryption-azure[prepared your Azure environment for encryption].
2122

2223
include::modules/cluster-entitlements.adoc[leveloffset=+1]
2324

@@ -45,6 +46,8 @@ include::modules/machineset-azure-enabling-accelerated-networking-new-install.ad
4546

4647
include::modules/installation-launching-installer.adoc[leveloffset=+1]
4748

49+
include::modules/installation-azure-finalizing-encryption.adoc[leveloffset=+1]
50+
4851
include::modules/cli-installing-cli.adoc[leveloffset=+1]
4952

5053
include::modules/cli-logging-in-kubeadmin.adoc[leveloffset=+1]

installing/installing_azure/installing-azure-government-region.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ cluster.
1818
* You xref:../../installing/installing_azure/installing-azure-account.adoc#installing-azure-account[configured an Azure account] to host the cluster and determined the tested and validated government region to deploy the cluster to.
1919
* If you use a firewall, you xref:../../installing/install_config/configuring-firewall.adoc#configuring-firewall[configured it to allow the sites] that your cluster requires access to.
2020
* If the cloud identity and access management (IAM) APIs are not accessible in your environment, or if you do not want to store an administrator-level credential secret in the `kube-system` namespace, you can xref:../../installing/installing_azure/manually-creating-iam-azure.adoc#manually-creating-iam-azure[manually create and maintain IAM credentials].
21+
* If you use customer-managed encryption keys, you xref:../../installing/installing_azure/enabling-user-managed-encryption-azure.adoc#enabling-user-managed-encryption-azure[prepared your Azure environment for encryption].
2122

2223
include::modules/installation-azure-about-government-region.adoc[leveloffset=+1]
2324

@@ -55,6 +56,8 @@ include::modules/machineset-azure-enabling-accelerated-networking-new-install.ad
5556

5657
include::modules/installation-launching-installer.adoc[leveloffset=+1]
5758

59+
include::modules/installation-azure-finalizing-encryption.adoc[leveloffset=+1]
60+
5861
include::modules/cli-installing-cli.adoc[leveloffset=+1]
5962

6063
include::modules/cli-logging-in-kubeadmin.adoc[leveloffset=+1]

installing/installing_azure/installing-azure-network-customizations.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ cluster.
2323
* You xref:../../installing/installing_azure/installing-azure-account.adoc#installing-azure-account[configured an Azure account] to host the cluster and determined the tested and validated region to deploy the cluster to.
2424
* If you use a firewall, you xref:../../installing/install_config/configuring-firewall.adoc#configuring-firewall[configured it to allow the sites] that your cluster requires access to.
2525
* If the cloud identity and access management (IAM) APIs are not accessible in your environment, or if you do not want to store an administrator-level credential secret in the `kube-system` namespace, you can xref:../../installing/installing_azure/manually-creating-iam-azure.adoc#manually-creating-iam-azure[manually create and maintain IAM credentials]. Manual mode can also be used in environments where the cloud IAM APIs are not reachable.
26+
* If you use customer-managed encryption keys, you xref:../../installing/installing_azure/enabling-user-managed-encryption-azure.adoc#enabling-user-managed-encryption-azure[prepared your Azure environment for encryption].
2627

2728
include::modules/cluster-entitlements.adoc[leveloffset=+1]
2829

@@ -63,6 +64,8 @@ include::modules/machineset-azure-enabling-accelerated-networking-new-install.ad
6364

6465
include::modules/installation-launching-installer.adoc[leveloffset=+1]
6566

67+
include::modules/installation-azure-finalizing-encryption.adoc[leveloffset=+1]
68+
6669
include::modules/cli-installing-cli.adoc[leveloffset=+1]
6770

6871
include::modules/cli-logging-in-kubeadmin.adoc[leveloffset=+1]

installing/installing_azure/installing-azure-private.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ In {product-title} version {product-version}, you can install a private cluster
1515
* You xref:../../installing/installing_azure/installing-azure-account.adoc#installing-azure-account[configured an Azure account] to host the cluster and determined the tested and validated region to deploy the cluster to.
1616
* If you use a firewall, you xref:../../installing/install_config/configuring-firewall.adoc#configuring-firewall[configured it to allow the sites] that your cluster requires access to.
1717
* If the cloud identity and access management (IAM) APIs are not accessible in your environment, or if you do not want to store an administrator-level credential secret in the `kube-system` namespace, you can xref:../../installing/installing_azure/manually-creating-iam-azure.adoc#manually-creating-iam-azure[manually create and maintain IAM credentials].
18+
* If you use customer-managed encryption keys, you xref:../../installing/installing_azure/enabling-user-managed-encryption-azure.adoc#enabling-user-managed-encryption-azure[prepared your Azure environment for encryption].
1819

1920
include::modules/private-clusters-default.adoc[leveloffset=+1]
2021

@@ -50,6 +51,8 @@ include::modules/machineset-azure-enabling-accelerated-networking-new-install.ad
5051

5152
include::modules/installation-launching-installer.adoc[leveloffset=+1]
5253

54+
include::modules/installation-azure-finalizing-encryption.adoc[leveloffset=+1]
55+
5356
include::modules/cli-installing-cli.adoc[leveloffset=+1]
5457

5558
include::modules/cli-logging-in-kubeadmin.adoc[leveloffset=+1]

installing/installing_azure/installing-azure-vnet.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ In {product-title} version {product-version}, you can install a cluster into an
1515
* You xref:../../installing/installing_azure/installing-azure-account.adoc#installing-azure-account[configured an Azure account] to host the cluster and determined the tested and validated region to deploy the cluster to.
1616
* If you use a firewall, you xref:../../installing/install_config/configuring-firewall.adoc#configuring-firewall[configured it to allow the sites] that your cluster requires access to.
1717
* If the cloud identity and access management (IAM) APIs are not accessible in your environment, or if you do not want to store an administrator-level credential secret in the `kube-system` namespace, you can xref:../../installing/installing_azure/manually-creating-iam-azure.adoc#manually-creating-iam-azure[manually create and maintain IAM credentials].
18+
* If you use customer-managed encryption keys, you xref:../../installing/installing_azure/enabling-user-managed-encryption-azure.adoc#enabling-user-managed-encryption-azure[prepared your Azure environment for encryption].
1819

1920
include::modules/installation-about-custom-azure-vnet.adoc[leveloffset=+1]
2021

@@ -44,6 +45,8 @@ include::modules/machineset-azure-enabling-accelerated-networking-new-install.ad
4445

4546
include::modules/installation-launching-installer.adoc[leveloffset=+1]
4647

48+
include::modules/installation-azure-finalizing-encryption.adoc[leveloffset=+1]
49+
4750
include::modules/cli-installing-cli.adoc[leveloffset=+1]
4851

4952
include::modules/cli-logging-in-kubeadmin.adoc[leveloffset=+1]

modules/installation-azure-config-yaml.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,15 @@ controlPlane: <2>
4141
name: master
4242
platform:
4343
azure:
44+
encryptionAtHost: true
4445
ultraSSDCapability: Enabled
4546
osDisk:
4647
diskSizeGB: 1024 <5>
4748
diskType: Premium_LRS
49+
diskEncryptionSet:
50+
resourceGroup: disk_encryption_set_resource_group
51+
name: disk_encryption_set_name
52+
subscriptionId: secondary_subscription_id
4853
type: Standard_D8s_v3
4954
replicas: 3
5055
compute: <2>
@@ -54,9 +59,14 @@ compute: <2>
5459
azure:
5560
ultraSSDCapability: Enabled
5661
type: Standard_D2s_v3
62+
encryptionAtHost: true
5763
osDisk:
5864
diskSizeGB: 512 <5>
5965
diskType: Standard_LRS
66+
diskEncryptionSet:
67+
resourceGroup: disk_encryption_set_resource_group
68+
name: disk_encryption_set_name
69+
subscriptionId: secondary_subscription_id
6070
zones: <6>
6171
- "1"
6272
- "2"
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
//Module included in the following assemblies:
2+
//
3+
// * installing/installing_azure/installing-azure-customizations.adoc
4+
// * installing/installing_azure/installing-azure-government-region.adoc
5+
// * installing/installing_azure/installing-azure-network-customizations.adoc
6+
// * installing/installing_azure/installing-azure-private.adoc
7+
// * installing/installing_azure/installing-azure-vnet.adoc
8+
9+
:_content-type: PROCEDURE
10+
[id="finalizing-encryption_{context}"]
11+
= Finalizing user-managed encryption after installation
12+
If you installed {product-title} using a user-managed encryption key, you can complete the installation by creating a new storage class and granting write permissions to the Azure cluster resource group.
13+
14+
.Procedure
15+
. Obtain the identity of the cluster resource group used by the installer:
16+
.. If you specified an existing resource group in `install-config.yaml`, obtain its Azure identity by running the following command:
17+
+
18+
[source,terminal]
19+
----
20+
$ az identity list --resource-group "<existing_resource_group>"
21+
----
22+
.. If you did not specify a existing resource group in `install-config.yaml`, locate the resource group that the installer created, and then obtain its Azure identity by running the following commands:
23+
+
24+
[source,terminal]
25+
----
26+
$ az group list
27+
----
28+
+
29+
[source,terminal]
30+
----
31+
$ az identity list --resource-group "<installer_created_resource_group>"
32+
----
33+
+
34+
. Grant a role assignment to the cluster resource group so that it can write to the Disk Encryption Set by running the following command:
35+
+
36+
[source,terminal]
37+
----
38+
$ az role assignment create --role "<privileged_role>" \// <1>
39+
--assignee "<resource_group_identity>" <2>
40+
----
41+
<1> Specifies an Azure role that has read/write permissions to the disk encryption set. You can use the `Owner` role or a custom role with the necessary permissions.
42+
<2> Specifies the identity of the cluster resource group.
43+
+
44+
. Create a storage class that uses the user-managed disk encryption set:
45+
.. Save the following storage class definition to a file, for example `storage-class-definition.yaml`:
46+
+
47+
[source,yaml]
48+
----
49+
kind: StorageClass
50+
apiVersion: storage.k8s.io/v1
51+
metadata:
52+
name: managed-premium
53+
provisioner: kubernetes.io/azure-disk
54+
parameters:
55+
skuname: Premium_LRS
56+
kind: Managed
57+
diskEncryptionSetID: "<disk_encryption_set_ID>" <1>
58+
resourceGroup: <resource_group_name> <2>
59+
reclaimPolicy: Delete
60+
allowVolumeExpansion: true
61+
volumeBindingMode: WaitForFirstConsumer
62+
----
63+
<1> Specifies the ID of the disk encryption set that you created in the prerequisite steps, for example `"/subscriptions/xxxxxx-xxxxx-xxxxx/resourceGroups/test-encryption/providers/Microsoft.Compute/diskEncryptionSets/disk-encryption-set-xxxxxx"`.
64+
<2> Specifies the name of the resource group used by the installer. This is the same resource group from the first step.
65+
.. Create the storage class `managed-premium` from the file you created by running the following command:
66+
+
67+
[source,terminal]
68+
----
69+
$ oc create -f storage-class-definition.yaml
70+
----
71+
. Select the `managed-premium` storage class when you create persistent volumes to use encrypted storage.
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
//Module included in the following assemblies:
2+
//
3+
// * installing/installing_azure/enabling-disk-encryption-sets-azure.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="preparing-disk-encryption-sets"]
7+
= Preparing an Azure Disk Encryption Set
8+
The {product-title} installer can use an existing Disk Encryption Set with a user-managed key. To enable this feature, you can create a Disk Encryption Set in Azure and provide the key to the installer.
9+
10+
.Procedure
11+
12+
. Set the following environment variables for the Azure resource group by running the following command:
13+
+
14+
[source,terminal]
15+
----
16+
$ export RESOURCEGROUP="<resource_group>" \// <1>
17+
LOCATION="<location>" <2>
18+
----
19+
<1> Specifies the name of the Azure resource group where you will create the Disk Encryption Set and encryption key. To avoid losing access to your keys after destroying the cluster, you should create the Disk Encryption Set in a different resource group than the resource group where you install the cluster.
20+
<2> Specifies the Azure location where you will create the resource group.
21+
+
22+
. Set the following environment variables for the Azure Key Vault and Disk Encryption Set by running the following command:
23+
+
24+
[source,terminal]
25+
----
26+
$ export KEYVAULT_NAME="<keyvault_name>" \// <1>
27+
KEYVAULT_KEY_NAME="<keyvault_key_name>" \// <2>
28+
DISK_ENCRYPTION_SET_NAME="<disk_encryption_set_name>" <3>
29+
----
30+
<1> Specifies the name of the Azure Key Vault you will create.
31+
<2> Specifies the name of the encryption key you will create.
32+
<3> Specifies the name of the disk encryption set you will create.
33+
+
34+
. Set the environment variable for the ID of your Azure Service Principal by running the following command:
35+
+
36+
[source,terminal]
37+
----
38+
$ export CLUSTER_SP_ID="<service_principal_id>" <1>
39+
----
40+
<1> Specifies the ID of the service principal you will use for this installation.
41+
+
42+
. Enable host-level encryption in Azure by running the following commands:
43+
+
44+
[source,terminal]
45+
----
46+
$ az feature register --namespace "Microsoft.Compute" --name "EncryptionAtHost"
47+
----
48+
+
49+
[source,terminal]
50+
----
51+
$ az feature show --namespace Microsoft.Compute --name EncryptionAtHost
52+
----
53+
+
54+
[source,terminal]
55+
----
56+
$ az provider register -n Microsoft.Compute
57+
----
58+
+
59+
. Create an Azure Resource Group to hold the disk encryption set and associated resources by running the following command:
60+
+
61+
[source,terminal]
62+
----
63+
$ az group create --name $RESOURCEGROUP --location $LOCATION
64+
----
65+
+
66+
. Create an Azure key vault by running the following command:
67+
+
68+
[source,terminal]
69+
----
70+
$ az keyvault create -n $KEYVAULT_NAME -g $RESOURCEGROUP -l $LOCATION \
71+
--enable-purge-protection true --enable-soft-delete true
72+
----
73+
+
74+
. Create an encryption key in the key vault by running the following command:
75+
+
76+
[source,terminal]
77+
----
78+
$ az keyvault key create --vault-name $KEYVAULT_NAME -n $KEYVAULT_KEY_NAME \
79+
--protection software
80+
----
81+
+
82+
. Capture the ID of the key vault by running the following command:
83+
+
84+
[source,terminal]
85+
----
86+
$ KEYVAULT_ID=$(az keyvault show --name $KEYVAULT_NAME --query "[id]" -o tsv)
87+
----
88+
+
89+
. Capture the key URL in the key vault by running the following command:
90+
+
91+
[source,terminal]
92+
----
93+
$ KEYVAULT_KEY_URL=$(az keyvault key show --vault-name $KEYVAULT_NAME --name \
94+
$KEYVAULT_KEY_NAME --query "[key.kid]" -o tsv)
95+
----
96+
+
97+
. Create a disk encryption set by running the following command:
98+
+
99+
[source,terminal]
100+
----
101+
$ az disk-encryption-set create -n $DISK_ENCRYPTION_SET_NAME -l $LOCATION -g \
102+
$RESOURCEGROUP --source-vault $KEYVAULT_ID --key-url $KEYVAULT_KEY_URL
103+
----
104+
+
105+
. Grant the DiskEncryptionSet resource access to the key vault by running the following commands:
106+
+
107+
[source,terminal]
108+
----
109+
$ DES_IDENTITY=$(az disk-encryption-set show -n $DISK_ENCRYPTION_SET_NAME -g \
110+
$RESOURCEGROUP --query "[identity.principalId]" -o tsv)
111+
----
112+
+
113+
[source,terminal]
114+
----
115+
$ az keyvault set-policy -n $KEYVAULT_NAME -g $RESOURCEGROUP --object-id \
116+
$DES_IDENTITY --key-permissions wrapkey unwrapkey get
117+
----
118+
+
119+
. Grant the Azure Service Principal permission to read the DiskEncryptionSet by running the following commands:
120+
+
121+
[source,terminal]
122+
----
123+
$ DES_RESOURCE_ID=$(az disk-encryption-set show -n $DISK_ENCRYPTION_SET_NAME -g \
124+
$RESOURCEGROUP --query "[id]" -o tsv)
125+
----
126+
+
127+
[source,terminal]
128+
----
129+
$ az role assignment create --assignee $CLUSTER_SP_ID --role "<reader_role>" \// <1>
130+
--scope $DES_RESOURCE_ID -o jsonc
131+
----
132+
<1> Specifies an Azure role with read permissions to the disk encryption set. You can use the `Owner` role or a custom role with the necessary permissions.

0 commit comments

Comments
 (0)