Este conteúdo não está disponível no idioma selecionado.
Chapter 4. Creating ROSA with HCP clusters using a custom AWS KMS encryption key
Create a Red Hat OpenShift Service on AWS cluster using a custom AWS Key Management Service (KMS) key.
4.1. Red Hat OpenShift Service on AWS Prerequisites Copiar o linkLink copiado para a área de transferência!
To create a Red Hat OpenShift Service on AWS cluster, you must have the following items:
- A configured virtual private cloud (VPC)
- Account-wide roles
- An OIDC configuration
- Operator roles
4.2. Creating a Virtual Private Cloud for your Red Hat OpenShift Service on AWS clusters Copiar o linkLink copiado para a área de transferência!
You must have a Virtual Private Cloud (VPC) to create Red Hat OpenShift Service on AWS cluster. Use one of the following methods to create a VPC:
- Create a VPC using the ROSA command-line interface (CLI)
- Create a VPC by using a Terraform template
- Manually create the VPC resources in the AWS console
The Terraform instructions are for testing and demonstration purposes. Your own installation requires some modifications to the VPC for your own use. You should also ensure that when you use this Terraform script it is in the same region that you intend to install your cluster. In these examples, use us-east-2
.
Creating an AWS VPC using the ROSA CLI
The rosa create network
command is available in v.1.2.48 or later of the ROSA CLI. The command uses AWS CloudFormation to create a VPC and associated networking components necessary to install a Red Hat OpenShift Service on AWS cluster. CloudFormation is a native AWS infrastructure-as-code tool and is compatible with the AWS CLI.
If you do not specify a template, CloudFormation uses a default template that creates resources with the following parameters:
VPC parameter | Value |
---|---|
Availability zones | 1 |
Region |
|
VPC CIDR |
|
You can create and customize CloudFormation templates to use with the rosa create network
command. See the additional resources of this section for information on the default VPC template.
Prerequisites
- You have configured your AWS account
- You have configured your Red Hat accounts
- You have installed the ROSA CLI and configured it to the latest version
Procedure
Create an AWS VPC using the default CloudFormations template by running the following command:
rosa create network
$ rosa create network
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Customize your VPC by specifying additional parameters.
You can use the
--param
flag to specify changes to the default VPC template. The following example command specifies custom values forregion
,Name
,AvailabilityZoneCount
andVpcCidr
.rosa create network --param Region=us-east-2 --param Name=quickstart-stack --param AvailabilityZoneCount=3 --param VpcCidr=10.0.0.0/16
$ rosa create network --param Region=us-east-2 --param Name=quickstart-stack --param AvailabilityZoneCount=3 --param VpcCidr=10.0.0.0/16
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The command takes about 5 minutes to run and provides regular status updates from AWS as resources are created. If there is an issue with CloudFormation, a rollback is attempted. For all other errors that are encountered, please follow the error message instructions or contact AWS support.
Verification
When completed, you receive a summary of the created resources:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Creating a Virtual Private Cloud using Terraform
Terraform is a tool that allows you to create various resources using an established template. The following process uses the default options as required to create a Red Hat OpenShift Service on AWS cluster. For more information about using Terraform, see the additional resources.
Prerequisites
- You have installed Terraform version 1.4.0 or newer on your machine.
- You have installed Git on your machine.
Procedure
Open a shell prompt and clone the Terraform VPC repository by running the following command:
git clone https://github.com/openshift-cs/terraform-vpc-example
$ git clone https://github.com/openshift-cs/terraform-vpc-example
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Navigate to the created directory by running the following command:
cd terraform-vpc-example
$ cd terraform-vpc-example
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Initiate the Terraform file by running the following command:
terraform init
$ terraform init
Copy to Clipboard Copied! Toggle word wrap Toggle overflow A message confirming the initialization appears when this process completes.
To build your VPC Terraform plan based on the existing Terraform template, run the
plan
command. You must include your AWS region. You can choose to specify a cluster name. Arosa.tfplan
file is added to thehypershift-tf
directory after theterraform plan
completes. For more detailed options, see the Terraform VPC repository’s README file.terraform plan -out rosa.tfplan -var region=<region>
$ terraform plan -out rosa.tfplan -var region=<region>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply this plan file to build your VPC by running the following command:
terraform apply rosa.tfplan
$ terraform apply rosa.tfplan
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: You can capture the values of the Terraform-provisioned private, public, and machinepool subnet IDs as environment variables to use when creating your Red Hat OpenShift Service on AWS cluster by running the following commands:
export SUBNET_IDS=$(terraform output -raw cluster-subnets-string)
$ export SUBNET_IDS=$(terraform output -raw cluster-subnets-string)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the variables were correctly set with the following command:
echo $SUBNET_IDS
$ echo $SUBNET_IDS
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
subnet-0a6a57e0f784171aa,subnet-078e84e5b10ecf5b0
$ subnet-0a6a57e0f784171aa,subnet-078e84e5b10ecf5b0
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Creating an AWS Virtual Private Cloud manually
If you choose to manually create your AWS Virtual Private Cloud (VPC) instead of using Terraform, go to the VPC page in the AWS console.
Your VPC must meet the requirements shown in the following table.
Requirement | Details |
---|---|
VPC name | You need to have the specific VPC name and ID when creating your cluster. |
CIDR range | Your VPC CIDR range should match your machine CIDR. |
Availability zone | You need one availability zone for a single zone, and you need three for availability zones for multi-zone. |
Public subnet | You must have one public subnet with a NAT gateway for public clusters. Private clusters do not need a public subnet. |
DNS hostname and resolution | You must ensure that the DNS hostname and resolution are enabled. |
4.2.2. Creating the account-wide STS roles and policies Copiar o linkLink copiado para a área de transferência!
Before you create your Red Hat OpenShift Service on AWS cluster, you must create the required account-wide roles and policies.
Specific AWS-managed policies for Red Hat OpenShift Service on AWS must be attached to each role. Customer-managed policies must not be used with these required account roles. For more information regarding AWS-managed policies for Red Hat OpenShift Service on AWS clusters, see AWS managed policies for ROSA.
Prerequisites
- You have completed the AWS prerequisites for Red Hat OpenShift Service on AWS.
- You have available AWS service quotas.
- You have enabled the Red Hat OpenShift Service on AWS in the AWS Console.
-
You have installed and configured the latest ROSA CLI (
rosa
) on your installation host. - You have logged in to your Red Hat account by using the ROSA CLI.
Procedure
If they do not exist in your AWS account, create the required account-wide STS roles and attach the policies by running the following command:
rosa create account-roles --hosted-cp
$ rosa create account-roles --hosted-cp
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Set your prefix as an environmental variable by running the following command:
export ACCOUNT_ROLES_PREFIX=<account_role_prefix>
$ export ACCOUNT_ROLES_PREFIX=<account_role_prefix>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow View the value of the variable by running the following command:
echo $ACCOUNT_ROLES_PREFIX
$ echo $ACCOUNT_ROLES_PREFIX
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
ManagedOpenShift
ManagedOpenShift
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
For more information regarding AWS managed IAM policies for Red Hat OpenShift Service on AWS, see AWS managed IAM policies for ROSA.
4.2.3. Creating an OpenID Connect configuration Copiar o linkLink copiado para a área de transferência!
When creating a Red Hat OpenShift Service on AWS cluster, you can create the OpenID Connect (OIDC) configuration before creating your cluster. This configuration is registered to be used with OpenShift Cluster Manager.
Prerequisites
- You have completed the AWS prerequisites for Red Hat OpenShift Service on AWS.
-
You have installed and configured the latest ROSA CLI,
rosa
, on your installation host.
Procedure
To create your OIDC configuration alongside the AWS resources, run the following command:
rosa create oidc-config --mode=auto --yes
$ rosa create oidc-config --mode=auto --yes
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This command returns the following information.
Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow When creating your cluster, you must supply the OIDC config ID. The CLI output provides this value for
--mode auto
, otherwise you must determine these values based onaws
CLI output for--mode manual
.Optional: you can save the OIDC configuration ID as a variable to use later. Run the following command to save the variable:
export OIDC_ID=<oidc_config_id>
$ export OIDC_ID=<oidc_config_id>
1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- In the example output above, the OIDC configuration ID is 13cdr6b.
View the value of the variable by running the following command:
echo $OIDC_ID
$ echo $OIDC_ID
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
13cdr6b
13cdr6b
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
You can list the possible OIDC configurations available for your clusters that are associated with your user organization. Run the following command:
rosa list oidc-config
$ rosa list oidc-config
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
ID MANAGED ISSUER URL SECRET ARN 2330dbs0n8m3chkkr25gkkcd8pnj3lk2 true https://dvbwgdztaeq9o.cloudfront.net/2330dbs0n8m3chkkr25gkkcd8pnj3lk2 233hvnrjoqu14jltk6lhbhf2tj11f8un false https://oidc-r7u1.s3.us-east-1.amazonaws.com aws:secretsmanager:us-east-1:242819244:secret:rosa-private-key-oidc-r7u1-tM3MDN
ID MANAGED ISSUER URL SECRET ARN 2330dbs0n8m3chkkr25gkkcd8pnj3lk2 true https://dvbwgdztaeq9o.cloudfront.net/2330dbs0n8m3chkkr25gkkcd8pnj3lk2 233hvnrjoqu14jltk6lhbhf2tj11f8un false https://oidc-r7u1.s3.us-east-1.amazonaws.com aws:secretsmanager:us-east-1:242819244:secret:rosa-private-key-oidc-r7u1-tM3MDN
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
4.2.4. Creating Operator roles and policies Copiar o linkLink copiado para a área de transferência!
When you deploy a Red Hat OpenShift Service on AWS cluster, you must create the Operator IAM roles. The cluster Operators use the Operator roles and policies to obtain the temporary permissions required to carry out cluster operations, such as managing back-end storage and external access to a cluster.
Prerequisites
- You have completed the AWS prerequisites for Red Hat OpenShift Service on AWS.
-
You have installed and configured the latest ROSA CLI (
rosa
), on your installation host. - You created the account-wide AWS roles.
Procedure
To create your Operator roles, run the following command:
rosa create operator-roles --hosted-cp --prefix=$OPERATOR_ROLES_PREFIX --oidc-config-id=$OIDC_ID --installer-role-arn arn:aws:iam::$AWS_ACCOUNT_ID:role/${ACCOUNT_ROLES_PREFIX}-HCP-ROSA-Installer-Role
$ rosa create operator-roles --hosted-cp --prefix=$OPERATOR_ROLES_PREFIX --oidc-config-id=$OIDC_ID --installer-role-arn arn:aws:iam::$AWS_ACCOUNT_ID:role/${ACCOUNT_ROLES_PREFIX}-HCP-ROSA-Installer-Role
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following breakdown provides options for the Operator role creation.
rosa create operator-roles --hosted-cp
$ rosa create operator-roles --hosted-cp --prefix=$OPERATOR_ROLES_PREFIX
1 --oidc-config-id=$OIDC_ID
2 --installer-role-arn arn:aws:iam::$AWS_ACCOUNT_ID:role/$ACCOUNT_ROLES_PREFIX-HCP-ROSA-Installer-Role
3 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- You must supply a prefix when creating these Operator roles. Failing to do so produces an error. See the Additional resources of this section for information on the Operator prefix.
- 2
- This value is the OIDC configuration ID that you created for your Red Hat OpenShift Service on AWS cluster.
- 3
- This value is the installer role ARN that you created when you created the Red Hat OpenShift Service on AWS account roles.
You must include the
--hosted-cp
parameter to create the correct roles for Red Hat OpenShift Service on AWS clusters. This command returns the following information.Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The Operator roles are now created and ready to use for creating your Red Hat OpenShift Service on AWS cluster.
Verification
You can list the Operator roles associated with your Red Hat OpenShift Service on AWS account. Run the following command:
rosa list operator-roles
$ rosa list operator-roles
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- After the command runs, it displays all the prefixes associated with your AWS account and notes how many roles are associated with this prefix. If you need to see all of these roles and their details, enter "Yes" on the detail prompt to have these roles listed out with specifics.
4.2.5. Creating a Red Hat OpenShift Service on AWS cluster using a custom AWS KMS key Copiar o linkLink copiado para a área de transferência!
You can create a Red Hat OpenShift Service on AWS 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.
Red Hat OpenShift Service on AWS 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.
Procedure
Create a custom AWS customer-managed KMS key by running the following command:
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)
$ 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)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This command saves the Amazon Resource Name (ARN) output of this custom key for further steps.
NoteCustomers must provide the
--tags TagKey=red-hat,TagValue=true
argument that is required for a customer KMS key.Verify the KMS key has been created by running the following command:
echo $KMS_ARN
$ echo $KMS_ARN
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set your AWS account ID to an environment variable.
AWS_ACCOUNT_ID=<aws_account_id>
$ AWS_ACCOUNT_ID=<aws_account_id>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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 defaultManagedOpenShift-HCP-ROSA-Installer-Role
role is added:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Confirm the details of the policy file created by running the following command:
cat rosa-key-policy.json
$ cat rosa-key-policy.json
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the newly generated key policy to the custom KMS key by running the following command:
aws kms put-key-policy --key-id $KMS_ARN \ --policy file://rosa-key-policy.json \ --policy-name default
$ aws kms put-key-policy --key-id $KMS_ARN \ --policy file://rosa-key-policy.json \ --policy-name default
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the cluster by running the following command:
NoteIf your cluster name is longer than 15 characters, it will contain an autogenerated domain prefix as a sub-domain for your provisioned cluster on
*.openshiftapps.com
.To customize the subdomain, use the
--domain-prefix
flag. The domain prefix cannot be longer than 15 characters, must be unique, and cannot be changed after cluster creation.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 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.
- 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.
Verification
You can verify that your KMS key works by using OpenShift Cluster Manager.
- Navigate to OpenShift Cluster Manager and select Instances.
- Select your instance.
- Click the Storage tab.
- Copy the KMS key ID.
- Search and select Key Management Service.
- Enter your copied KMS key ID in the Filter field.