|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * monitoring/enabling-monitoring-for-user-defined-projects.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="creating-cluster-with-aws-kms-key"] |
| 7 | += Creating a ROSA cluster using a custom AWS KMS key |
| 8 | + |
| 9 | +You can create a {product-title} (ROSA) cluster with a customer-provided KMS key that is used to encrypt either node root volumes, the etcd database, or both. A different KMS key ARN can be provided for each option. |
| 10 | + |
| 11 | +[NOTE] |
| 12 | +==== |
| 13 | +{hcp-title} does not automatically configure the `default` storage class to encrypt persistent volumes with the customer-provided KMS key. This is something that can be configured in-cluster after installation. |
| 14 | +==== |
| 15 | + |
| 16 | + |
| 17 | +.Procedure |
| 18 | + |
| 19 | +. Create a custom AWS customer-managed KMS key by running the following command: |
| 20 | ++ |
| 21 | +[source,terminal] |
| 22 | +---- |
| 23 | +$ KMS_ARN=$(aws kms create-key --region $AWS_REGION --description 'Custom ROSA Encryption Key' --tags TagKey=red-hat,TagValue=true --query KeyMetadata.Arn --output text) |
| 24 | +---- |
| 25 | ++ |
| 26 | +This command saves the Amazon Resource Name (ARN) output of this custom key for further steps. |
| 27 | ++ |
| 28 | +[NOTE] |
| 29 | +==== |
| 30 | +Customers must provide the `--tags TagKey=red-hat,TagValue=true` argument that is required for a customer KMS key. |
| 31 | +==== |
| 32 | + |
| 33 | + |
| 34 | +. Verify the KMS key has been created by running the following command: |
| 35 | ++ |
| 36 | +[source,terminal] |
| 37 | +---- |
| 38 | +$ echo $KMS_ARN |
| 39 | +---- |
| 40 | + |
| 41 | +. Set your AWS account ID to an environment variable. |
| 42 | ++ |
| 43 | +[source,terminal] |
| 44 | +---- |
| 45 | +$ AWS_ACCOUNT_ID=<aws_account_id> |
| 46 | +---- |
| 47 | +. Add the ARN for the account-wide installer role and operator roles that you created in the preceding step to the `Statement.Principal.AWS` section in the file. In the following example, the ARN for the default `ManagedOpenShift-HCP-ROSA-Installer-Role` role is added: |
| 48 | + |
| 49 | ++ |
| 50 | +[source,terminal] |
| 51 | +---- |
| 52 | +{ |
| 53 | + "Version": "2012-10-17", |
| 54 | + "Id": "key-rosa-policy-1", |
| 55 | + "Statement": [ |
| 56 | + { |
| 57 | + "Sid": "Enable IAM User Permissions", |
| 58 | + "Effect": "Allow", |
| 59 | + "Principal": { |
| 60 | + "AWS": "arn:aws:iam::${AWS_ACCOUNT_ID}:root" |
| 61 | + }, |
| 62 | + "Action": "kms:*", |
| 63 | + "Resource": "*" |
| 64 | + }, |
| 65 | + { |
| 66 | + "Sid": "Installer Permissions", |
| 67 | + "Effect": "Allow", |
| 68 | + "Principal": { |
| 69 | + "AWS": "arn:aws:iam::${AWS_ACCOUNT_ID}:role/ManagedOpenShift-HCP-ROSA-Installer-Role" |
| 70 | + }, |
| 71 | + "Action": [ |
| 72 | + "kms:CreateGrant", |
| 73 | + "kms:DescribeKey", |
| 74 | + "kms:GenerateDataKeyWithoutPlaintext" |
| 75 | + ], |
| 76 | + "Resource": "*" |
| 77 | + }, |
| 78 | + { |
| 79 | + "Sid": "ROSA KubeControllerManager Permissions", |
| 80 | + "Effect": "Allow", |
| 81 | + "Principal": { |
| 82 | + "AWS": "arn:aws:iam::${AWS_ACCOUNT_ID}:role/<operator_role_prefix>-kube-system-kube-controller-manager" |
| 83 | +
|
| 84 | + }, |
| 85 | + "Action": "kms:DescribeKey", |
| 86 | + "Resource": "*" |
| 87 | + }, |
| 88 | + { |
| 89 | + "Sid": "ROSA KMS Provider Permissions", |
| 90 | + "Effect": "Allow", |
| 91 | + "Principal": { |
| 92 | + "AWS": "arn:aws:iam::${AWS_ACCOUNT_ID}:role/<operator_role_prefix>-kube-system-kms-provider" |
| 93 | + }, |
| 94 | + "Action": [ |
| 95 | + "kms:Encrypt", |
| 96 | + "kms:Decrypt", |
| 97 | + "kms:DescribeKey" |
| 98 | + ], |
| 99 | + "Resource": "*" |
| 100 | + }, |
| 101 | + { |
| 102 | + "Sid": "ROSA NodeManager Permissions", |
| 103 | + "Effect": "Allow", |
| 104 | + "Principal": { |
| 105 | + "AWS": "arn:aws:iam::${AWS_ACCOUNT_ID}:role/<operator_role_prefix>-kube-system-capa-controller-manager" |
| 106 | + }, |
| 107 | + "Action": [ |
| 108 | + "kms:DescribeKey", |
| 109 | + "kms:GenerateDataKeyWithoutPlaintext", |
| 110 | + "kms:CreateGrant" |
| 111 | + ], |
| 112 | + "Resource": "*" |
| 113 | + } |
| 114 | + ] |
| 115 | + } |
| 116 | +---- |
| 117 | + |
| 118 | +. Confirm the details of the policy file created by running the following command: |
| 119 | ++ |
| 120 | +[source,terminal] |
| 121 | +---- |
| 122 | +$ cat rosa-key-policy.json |
| 123 | +---- |
| 124 | + |
| 125 | +. Apply the newly generated key policy to the custom KMS key by running the following command: |
| 126 | + |
| 127 | ++ |
| 128 | +[source,terminal] |
| 129 | +---- |
| 130 | +$ aws kms put-key-policy --key-id $KMS_ARN \ |
| 131 | +--policy file://rosa-key-policy.json \ |
| 132 | +--policy-name default |
| 133 | +---- |
| 134 | + |
| 135 | +. Create the cluster by running the following command: |
| 136 | + |
| 137 | ++ |
| 138 | +[source,terminal] |
| 139 | +---- |
| 140 | +$ rosa create cluster --cluster-name <cluster_name> \ |
| 141 | +--subnet-ids <private_subnet_id>,<public_subnet_id> \ |
| 142 | +--sts \ |
| 143 | +--mode auto \ |
| 144 | +--machine-cidr 10.0.0.0/16 \ |
| 145 | +--compute-machine-type m5.xlarge \ |
| 146 | +--hosted-cp \ |
| 147 | +--region <aws_region> \ |
| 148 | +--oidc-config-id $OIDC_ID \ |
| 149 | +--kms-key-arn $KMS_ARN \ <1> |
| 150 | +--etcd-encryption-kms-arn $KMS_ARN \ <2> |
| 151 | +--operator-roles-prefix $OPERATOR_ROLES_PREFIX |
| 152 | +---- |
| 153 | +<1> This KMS key ARN is used to encrypt all worker node root volumes. It is not required if only etcd database encryption is needed. |
| 154 | +<2> This KMS key ARN is used to encrypt the etcd database. The etcd database is always encrypted by default with an AES cipher block, but can be encrypted instead with a KMS key. It is not required if only node root volume encryption is needed. |
| 155 | + |
| 156 | +.Verification |
| 157 | + |
| 158 | +You can verify that your KMS key works by using {cluster-manager-url}. |
| 159 | + |
| 160 | +. Navigate to {cluster-manager-url} and select *Instances*. |
| 161 | + |
| 162 | +. Select your instance. |
| 163 | + |
| 164 | +. Click the *Storage* tab. |
| 165 | + |
| 166 | +. Copy the *KMS key ID*. |
| 167 | + |
| 168 | +. Search and select *Key Management Service*. |
| 169 | + |
| 170 | +. Enter your copied _KMS key ID_ in the *Filter* field. |
0 commit comments