Chapter 3. Enabling user-managed encryption for Azure
In OpenShift Container Platform version 4.15, 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 complete the installation.
3.1. Preparing an Azure Disk Encryption Set Copy linkLink copied to clipboard!
The OpenShift Container Platform 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.
Procedure
Set the following environment variables for the Azure resource group by running the following command:
export RESOURCEGROUP="<resource_group>" \ LOCATION="<location>"
$ export RESOURCEGROUP="<resource_group>" \
1 LOCATION="<location>"
2 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 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.
- 2
- Specifies the Azure location where you will create the resource group.
Set the following environment variables for the Azure Key Vault and Disk Encryption Set by running the following command:
export KEYVAULT_NAME="<keyvault_name>" \ KEYVAULT_KEY_NAME="<keyvault_key_name>" \ DISK_ENCRYPTION_SET_NAME="<disk_encryption_set_name>"
$ export KEYVAULT_NAME="<keyvault_name>" \
1 KEYVAULT_KEY_NAME="<keyvault_key_name>" \
2 DISK_ENCRYPTION_SET_NAME="<disk_encryption_set_name>"
3 Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the environment variable for the ID of your Azure Service Principal by running the following command:
export CLUSTER_SP_ID="<service_principal_id>"
$ export CLUSTER_SP_ID="<service_principal_id>"
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specifies the ID of the service principal you will use for this installation.
Enable host-level encryption in Azure by running the following commands:
az feature register --namespace "Microsoft.Compute" --name "EncryptionAtHost"
$ az feature register --namespace "Microsoft.Compute" --name "EncryptionAtHost"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az feature show --namespace Microsoft.Compute --name EncryptionAtHost
$ az feature show --namespace Microsoft.Compute --name EncryptionAtHost
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az provider register -n Microsoft.Compute
$ az provider register -n Microsoft.Compute
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an Azure Resource Group to hold the disk encryption set and associated resources by running the following command:
az group create --name $RESOURCEGROUP --location $LOCATION
$ az group create --name $RESOURCEGROUP --location $LOCATION
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an Azure key vault by running the following command:
az keyvault create -n $KEYVAULT_NAME -g $RESOURCEGROUP -l $LOCATION \ --enable-purge-protection true
$ az keyvault create -n $KEYVAULT_NAME -g $RESOURCEGROUP -l $LOCATION \ --enable-purge-protection true
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create an encryption key in the key vault by running the following command:
az keyvault key create --vault-name $KEYVAULT_NAME -n $KEYVAULT_KEY_NAME \ --protection software
$ az keyvault key create --vault-name $KEYVAULT_NAME -n $KEYVAULT_KEY_NAME \ --protection software
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Capture the ID of the key vault by running the following command:
KEYVAULT_ID=$(az keyvault show --name $KEYVAULT_NAME --query "[id]" -o tsv)
$ KEYVAULT_ID=$(az keyvault show --name $KEYVAULT_NAME --query "[id]" -o tsv)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Capture the key URL in the key vault by running the following command:
KEYVAULT_KEY_URL=$(az keyvault key show --vault-name $KEYVAULT_NAME --name \ $KEYVAULT_KEY_NAME --query "[key.kid]" -o tsv)
$ KEYVAULT_KEY_URL=$(az keyvault key show --vault-name $KEYVAULT_NAME --name \ $KEYVAULT_KEY_NAME --query "[key.kid]" -o tsv)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create a disk encryption set by running the following command:
az disk-encryption-set create -n $DISK_ENCRYPTION_SET_NAME -l $LOCATION -g \ $RESOURCEGROUP --source-vault $KEYVAULT_ID --key-url $KEYVAULT_KEY_URL
$ az disk-encryption-set create -n $DISK_ENCRYPTION_SET_NAME -l $LOCATION -g \ $RESOURCEGROUP --source-vault $KEYVAULT_ID --key-url $KEYVAULT_KEY_URL
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Grant the DiskEncryptionSet resource access to the key vault by running the following commands:
DES_IDENTITY=$(az disk-encryption-set show -n $DISK_ENCRYPTION_SET_NAME -g \ $RESOURCEGROUP --query "[identity.principalId]" -o tsv)
$ DES_IDENTITY=$(az disk-encryption-set show -n $DISK_ENCRYPTION_SET_NAME -g \ $RESOURCEGROUP --query "[identity.principalId]" -o tsv)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az keyvault set-policy -n $KEYVAULT_NAME -g $RESOURCEGROUP --object-id \ $DES_IDENTITY --key-permissions wrapkey unwrapkey get
$ az keyvault set-policy -n $KEYVAULT_NAME -g $RESOURCEGROUP --object-id \ $DES_IDENTITY --key-permissions wrapkey unwrapkey get
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Grant the Azure Service Principal permission to read the DiskEncryptionSet by running the following commands:
DES_RESOURCE_ID=$(az disk-encryption-set show -n $DISK_ENCRYPTION_SET_NAME -g \ $RESOURCEGROUP --query "[id]" -o tsv)
$ DES_RESOURCE_ID=$(az disk-encryption-set show -n $DISK_ENCRYPTION_SET_NAME -g \ $RESOURCEGROUP --query "[id]" -o tsv)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow az role assignment create --assignee $CLUSTER_SP_ID --role "<reader_role>" \ --scope $DES_RESOURCE_ID -o jsonc
$ az role assignment create --assignee $CLUSTER_SP_ID --role "<reader_role>" \
1 --scope $DES_RESOURCE_ID -o jsonc
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 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.
3.2. Next steps Copy linkLink copied to clipboard!
Install an OpenShift Container Platform cluster:
- Install a cluster with customizations on installer-provisioned infrastructure
- Install a cluster with network customizations on installer-provisioned infrastructure
- Install a cluster into an existing VNet on installer-provisioned infrastructure
- Install a private cluster on installer-provisioned infrastructure
- Install a cluster into an government region on installer-provisioned infrastructure