Chapter 5. Managing compute nodes using Red Hat build of Karpenter
5.1. About Red Hat build of Karpenter Copy linkLink copied to clipboard!
The Red Hat build of Karpenter provisions compute nodes automatically based on workload demand. By automatically provisioning your nodes, the Red Hat build of Karpenter helps improve cluster efficiency and reduce costs.
5.1.1. About the Red Hat build of Karpenter Copy linkLink copied to clipboard!
The Red Hat build of Karpenter builds on the open source Karpenter project to provide automatic node provisioning for Red Hat OpenShift Service on AWS clusters.
Karpenter watches for pods that the Kubernetes scheduler marks as unschedulable and evaluates their scheduling constraints, such as resource requests, node selectors, affinities, tolerations, and topology spread constraints. Karpenter then provisions nodes that meet the requirements of those waiting pods.
5.2. Set up the Red Hat build of Karpenter Copy linkLink copied to clipboard!
Set up and enable the Red Hat build of Karpenter on your Red Hat OpenShift Service on AWS cluster by configuring the required IAM roles, tagging policies, and cluster settings.
5.2.1. Prerequisites for setting up the Red Hat build of Karpenter Copy linkLink copied to clipboard!
Before you set up the Red Hat build of Karpenter, ensure your environment meets the following requirements.
-
You have installed the ROSA command-line interface (CLI) (
rosa) version 1.2.61 or later. - You have an OpenShift cluster version 4.22.0 or later.
-
You have installed the
jqCLI tool. -
You have installed the
ocCLI tool. - You have the required AWS Identity and Access Management (IAM) permissions to create policies and roles.
If you want to use Spot instances with Karpenter, you must configure your AWS account based on the AWS instructions. For more information, see Additional resources.
5.2.2. Set environment variables for the Red Hat build of Karpenter setup Copy linkLink copied to clipboard!
Set the environment variables that are used throughout the Red Hat build of Karpenter setup procedures.
Procedure
Export the following environment variables:
$ export CLUSTER_NAME=<cluster_name> $ export AWS_REGION=<aws_region> $ export CLUSTER_ID=$(rosa describe cluster -c "$CLUSTER_NAME" -o json | jq -r '.id')ImportantEnsure that your AWS client is using the region where your cluster is deployed.
Verification
Run the following command to verify that the variables are set:
$ echo $CLUSTER_NAME $AWS_REGION $CLUSTER_ID
5.2.3. Prepare an AWS IAM role for the Red Hat build of Karpenter Copy linkLink copied to clipboard!
Create the IAM policy and role that the Red Hat build of Karpenter requires to provision Amazon Elastic Compute Cloud (Amazon EC2) instances.
Procedure
Create the trust policy for the Karpenter service account:
$ cat > trust-policy.json <<EOF { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Federated": "arn:aws:iam::$(aws sts get-caller-identity --query Account --output text):oidc-provider/$(rosa describe cluster -c $CLUSTER_NAME -o json | jq -r .aws.sts.oidc_endpoint_url | sed 's|https://||')" }, "Action": "sts:AssumeRoleWithWebIdentity", "Condition": { "StringEquals": { "$(rosa describe cluster -c $CLUSTER_NAME -o json | jq -r .aws.sts.oidc_endpoint_url | sed 's|https://||'):sub": "system:serviceaccount:kube-system:karpenter" } } } ] } EOFCreate the IAM role:
$ aws iam create-role --role-name rosa-karpenter-controller-role-${CLUSTER_NAME} \ --assume-role-policy-document file://trust-policy.json \ --tags Key=red-hat-managed,Value=trueAttach the AWS managed IAM policy:
$ aws iam attach-role-policy \ --role-name rosa-karpenter-controller-role-${CLUSTER_NAME} \ --policy-arn arn:aws:iam::aws:policy/service-role/ROSAKarpenterControllerPolicy
Verification
Verify that policies are present by running:
$ aws iam list-attached-role-policies --role-name rosa-karpenter-controller-role-${CLUSTER_NAME}
5.2.4. Enable the Red Hat build of Karpenter using rosa CLI Copy linkLink copied to clipboard!
Enable the Red Hat build of Karpenter on your cluster by using ROSA command-line interface (CLI) (rosa) after it finishes installing.
Procedure
Wait for the cluster to become ready:
$ rosa describe cluster -c $CLUSTER_ID | grep -i StateExample output
State: readyEnsure that your Red Hat build of Karpenter IAM role is correctly set:
$ ROLE_ARN=$(aws iam get-role --role-name rosa-karpenter-controller-role-${CLUSTER_NAME} --query 'Role.Arn' --output text)Enable the Red Hat build of Karpenter:
$ rosa edit cluster -c $CLUSTER_ID \ --autonode=enabled \ --autonode-iam-role-arn=$ROLE_ARNIf you do not already have cluster admin access, create a cluster admin user:
$ rosa create admin -c $CLUSTER_IDLog in to the cluster using the credentials from the previous command:
$ oc login <api_url> --username cluster-admin --password <password>Verify that the Red Hat build of Karpenter custom resource definitions (CRDs) are present:
$ oc get ec2nodeclassNoteThe node pool manifest uses the
EC2NodeClassresource.Example output
NAME READY AGE default True 5m$ oc get openshiftec2nodeclassNoteThe
OpenshiftEC2NodeClassresource is Red Hat’s wrapper to communicate with theEC2NodeClassresource.Example output
NAME READY default True
5.2.5. Enable the Red Hat build of Karpenter using OpenShift Cluster Manager Copy linkLink copied to clipboard!
Enable the Red Hat build of Karpenter on your cluster by using OpenShift Cluster Manager after it finishes installing.
Prerequisites
- You have created an AWS Identity and Access Management (IAM) role to be configured for the Red Hat build of Karpenter.
You have your cluster’s OpenID Connect (OIDC) Endpoint URL.
NoteRun
rosa describe cluster -c $CLUSTER_NAME | grep "OIDC Endpoint URL"to see this URL. Do not include thehttps://prefix from the OIDC Endpoint URL. For example, useexample-oidc-endpoint.cloudfront.net/abcd1234examplehash5678instead ofhttps://example-oidc-endpoint.cloudfront.net/abcd1234examplehash5678.- You have the proper credentials to access the AWS console.
Procedure
Export your AWS ID:
$ export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)- Log in to the AWS console.
- In the AWS console, navigate to IAM > Roles.
On your Red Hat build of Karpenter Amazon Resource Name (ARN), update the trust policy to include the following policy specifications:
NoteTo access this ARN, run:
$ echo $ROLE_ARN{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Federated": "arn:aws:iam::<aws_account_id>:oidc-provider/<oidc-endpoint-URL>" }, "Action": "sts:AssumeRoleWithWebIdentity", "Condition": { "StringEquals": { "<oidc-endpoint-URL>:sub": "system:serviceaccount:kube-system:karpenter" } } } ] }where:
- <aws_account_id>
- Specifies your AWS Account ID.
- <oidc-endpoint-URL>
- Specifies the OIDC endpoint URL that you acquired.
- In OpenShift Cluster Manager, select your cluster from the cluster list.
- On the cluster details screen, select the Edit button next to the status for the Red Hat build of Karpenter.
- On the Edit Autonode settings dialog box, toggle Enable Autonode.
- Add your Red Hat build of Karpenter IAM role ARN to the field in this dialog box.
- Select Save to save your configurations and close the Edit Autonode settings box.
Verification
Log in to the cluster:
$ oc login <api_url> --username cluster-admin --password <password>Verify that the Red Hat build of Karpenter custom resource definitions (CRDs) are present:
$ oc get ec2nodeclassExample output
NAME READY AGE default True 5m$ oc get openshiftec2nodeclassExample output
NAME READY default True
5.3. Manage the Red Hat build of Karpenter node pools Copy linkLink copied to clipboard!
Create and manage node pools that define the compute capacity that the Red Hat build of Karpenter can provision.
5.3.1. NodePool resource constraints Copy linkLink copied to clipboard!
When you create or edit NodePool custom resources, you must conform to the following engineering validations and structural constraints.
-
Instance sizing validation: Select from the supported list of Amazon
EC2instances. The selectedEC2instance must meet the minimum resource requirements of 4 vCPUs or more. To enforce this validation on your cluster, include thekarpenter.k8s.aws/instance-cpukey in yourspec.template.spec.requirementsblock. Reserved Kubernetes labels: In the
NodePoolconfigurations that you create, avoid using the following reserved Kubernetes labels:-
node-role.kubernetes.io/master -
node-role.kubernetes.io/infra -
node-role.kubernetes.io/control-plane
-
-
Static capacity restrictions: Setting the
spec.replicasfield orStaticCapacityis not supported. This field requires the feature gate. Workload interruption defaults: Review the default values of the custom resources managed by Karpenter. For example, Karpenter includes the spot market type for the EC2 instances and nodes automatically expire after 30 days by default. If your workloads must not be interrupted, you must configure the custom resources explicitly to modify these behaviors.
WarningBy default, Karpenter schedules workloads on spot instances, which AWS can reclaim at any time. If your workloads require uninterrupted availability, you must explicitly set the
karpenter.sh/capacity-typerequirement toon-demandin yourNodePoolconfiguration.
5.3.2. Create a node pool Copy linkLink copied to clipboard!
Create a node pool to define the compute capacity that the Red Hat build of Karpenter can provision.
Prerequisites
- The Red Hat build of Karpenter is enabled on the cluster.
-
The default
OpenshiftEC2NodeClassis in aReadystate. -
You have installed the
ocCLI and are logged in to the cluster.
Procedure
Create a node pool manifest:
$ cat > nodepool.yaml <<'EOF' apiVersion: karpenter.sh/v1 kind: NodePool metadata: name: default-np spec: template: metadata: labels: autonode: "true" spec: requirements: - key: node.kubernetes.io/instance-type operator: In values: - c5.xlarge - key: karpenter.sh/capacity-type operator: In values: ["on-demand"] nodeClassRef: group: karpenter.k8s.aws kind: EC2NodeClass name: default EOFwhere:
nodeClassRef.kind-
Required field that must use the
EC2NodeClasstype. spec.labelsOptional field that you can use to place pods by using labels.
NoteFor a list of all requirements available under
spec.requirements, see the Additional resources.
Apply the node pool:
$ oc apply -f nodepool.yamlVerify the node pool is ready:
$ oc get nodepoolExample output
NAME NODECLASS NODES READY AGE default-np default 0 True 3s
5.3.3. Create a node pool with a non-default OpenshiftEC2NodeClass Copy linkLink copied to clipboard!
After creating a non-default OpenshiftEC2NodeClass resource, create a NodePool that references it. This binds the node pool’s provisioned nodes to the custom configuration defined in the non-default OpenshiftEC2NodeClass.
Prerequisites
-
A non-default
OpenshiftEC2NodeClassresource exists and is in aReadystate.
Procedure
Create a node pool manifest that references the non-default
OpenshiftEC2NodeClass:$ cat > nodepool.yaml <<'EOF' apiVersion: karpenter.sh/v1 kind: NodePool metadata: name: custom-np spec: template: spec: requirements: - key: "karpenter.k8s.aws/instance-cpu" operator: Gte values: ["4"] - key: karpenter.k8s.aws/instance-category operator: In values: ["c","r","m"] nodeClassRef: group: karpenter.k8s.aws kind: EC2NodeClass name: <non-default-nodeclass-name> EOFwhere:
nodeClassRef.name-
The name of the non-default
OpenshiftEC2NodeClassresource. This value must match themetadata.nameof an existingOpenshiftEC2NodeClass.
Apply the node pool:
$ oc apply -f nodepool.yaml
Verification
Verify that the node pool references the non-default
OpenshiftEC2NodeClass:$ oc get nodepoolExample output
NAME NODECLASS NODES READY AGE custom-np custom-nodeclass 0 True 3s
5.4. Manage OpenshiftEC2NodeClass resources Copy linkLink copied to clipboard!
Create, update, and delete non-default OpenshiftEC2NodeClass resources to customize how the Red Hat build of Karpenter provisions worker nodes.
5.4.1. OpenshiftEC2NodeClass immutability and lifecycle rules Copy linkLink copied to clipboard!
The OpenshiftEC2NodeClass resource has immutability and lifecycle rules that you must follow when managing node classes.
-
Resource immutability: The default
OpenshiftEC2NodeClassresource is immutable. Use this resource only for referencing purposes inside theNodePoolresources that you create. -
Default node classes: A default
OpenshiftEC2NodeClassis created automatically when you enable the Red Hat build of Karpenter in the cluster. AllNodePoolresources that reference the defaultOpenshiftEC2NodeClassupgrade automatically when the hosted control plane upgrades. -
Control plane version pinning: All
NodePoolresources that do not specify aspec.versionfield upgrade automatically alongside the hosted control plane. If you prefer to prevent automated upgrades for specific node pools, you must pin the version of theOpenshiftEC2NodeClassresource by using thespec.versionfield. Reserved AWS tags: Avoid using reserved AWS tags within your node class configurations. The following tag patterns are strictly prohibited:
-
red-hat-managed -
api.openshift.com/* -
kubernetes.io/cluster/*
-
-
De-provisioning sequence: When you remove nodes managed by Karpenter, clean up the
NodePoolcustom resources and the applications running on them before cleaning up any customOpenshiftEC2NodeClassthat theNodePoolresources reference.
5.4.2. Storage and networking constraints Copy linkLink copied to clipboard!
The following storage and networking constraints apply to OpenshiftEC2NodeClass resources.
-
Root volume constraints: Within the
OpenshiftEC2NodeClassspecification, the minimum allowed root volume size is100 GiB. - Volume encryption validation: When you customize the root volume disk settings, ensure that disk encryption is turned on. You can use a custom key managed by the AWS Key Management Service (KMS) to encrypt these root volumes.
-
Public IP address support: The association of public IP addresses for worker nodes is not supported. Avoid setting the
associatePublicIPAddressfield totrueon anyOpenshiftEC2NodeClassthat you create.
5.4.3. About non-default OpenshiftEC2NodeClass resources Copy linkLink copied to clipboard!
When you enable the Red Hat build of Karpenter, a default OpenshiftEC2NodeClass resource is automatically created with the same OpenShift version as the hosted control plane. This default resource is immutable and cannot be modified.
You can create non-default OpenshiftEC2NodeClass resources to customize how the Red Hat build of Karpenter provisions worker nodes. Create a non-default OpenshiftEC2NodeClass resource when you need any of the following customizations:
- The worker nodes require a different OpenShift version than the hosted control plane. By pinning the version, the worker nodes are not drained and upgraded during hosted control plane upgrades.
- The worker nodes require Amazon EC2 Capacity Reservations.
- The worker nodes must be placed in VPC subnets that are different from the cluster’s VPC subnets.
- The worker nodes require Amazon EC2 Instance Metadata Service v1 (IMDSv1), which does not use HTTP tokens.
- The worker nodes require additional AWS security groups for custom ingress or egress rules.
- The worker nodes require additional AWS tags.
The OpenshiftEC2NodeClass resource is Red Hat’s Custom Resource (CR) that communicates with the upstream Karpenter EC2NodeClass resource. When you create an OpenshiftEC2NodeClass, a corresponding EC2NodeClass resource is automatically managed by the system. Node pools reference the EC2NodeClass through the nodeClassRef field.
5.4.3.1. OpenshiftEC2NodeClass configuration fields Copy linkLink copied to clipboard!
The following example and field descriptions define the configurable fields for a non-default OpenshiftEC2NodeClass resource.
Example OpenshiftEC2NodeClass manifest
apiVersion: karpenter.hypershift.openshift.io/v1
kind: OpenshiftEC2NodeClass
metadata:
name: <nodeclass_name>
spec:
version: "<openshift_version>"
metadataOptions:
httpTokens: "<token_requirement>"
subnetSelectorTerms:
- tags:
karpenter.sh/discovery: "<cluster_id>"
<additional_tag_key>: "<additional_tag_value>"
- name: my-subnet
- id: subnet-0123456
securityGroupSelectorTerms:
- tags:
karpenter.sh/discovery: "<cluster_id>"
- id: "<security_group_id>"
tags:
<tag_key>: "<tag_value>"
capacityReservationSelectorTerms:
- tags:
<reservation_tag_key>: "<reservation_tag_value>"
spec:
kubelet:
podsPerCore: 2
maxPods: 20
podPidsLimit: 4096
where:
metadata.name-
The name of the
OpenshiftEC2NodeClassresource. The namedefaultis reserved for the system-managed immutable resource. Non-default resources must use a different name. spec.versionPins the OpenShift version for all nodes provisioned by this class. The pinned version can be up to two minor versions behind the hosted control plane version. For example, if the hosted control plane is version 4.25, the minimum pinned version is 4.23.
ImportantThe two minor version skew for
OpenshiftEC2NodeClassresources differs from the two minor version skew supported by standard Red Hat OpenShift Service on AWS machine pools.spec.metadataOptions.httpTokens-
Controls whether the EC2 Instance Metadata Service requires session tokens. Set to
optionalto allow IMDSv1 access without HTTP tokens. Set torequiredto enforce IMDSv2 with HTTP tokens. The default value isrequired. spec.subnetSelectorTerms- Specifies the VPC subnets where the Red Hat build of Karpenter launches worker nodes. Use tag-based selectors to target subnets that are different from the cluster’s default VPC subnets. Each entry in the list is a selector term that matches subnets by tags.
spec.securityGroupSelectorTerms- Specifies the AWS security groups to attach to worker nodes. You can select security groups by tags or by ID. Add additional entries to include security groups beyond the cluster defaults.
spec.tags- Specifies additional AWS tags to apply to all EC2 instances that the Red Hat build of Karpenter provisions by using this class. Tags are key-value pairs.
spec.capacityReservationSelectorTerms- Specifies the EC2 Capacity Reservations that the Red Hat build of Karpenter can use when provisioning worker nodes. Use tag-based selectors to match specific reservations.
Example Elastic Block Store (EBS) configuration manifest
blockDeviceMappings:
- deviceName: /dev/xvda
rootVolume: RootVolume
ebs:
volumeSizeGiB: 200
volumeType: GP3
encrypted: "Encrypted"
kmsKeyID: "arn:aws:kms:us-east-1:123456789012:key/abc-123"
iops: 3000
throughput: 125
deleteOnTermination: Delete
Example kubelet manifest
kubelet:
maxPods: 250
podsPerCore: 10
kubeReserved:
cpu: "500m"
memory: "1Gi"
systemReserved:
cpu: "500m"
memory: "512Mi"
evictionHard:
memory.available: "100Mi"
nodefs.available: "10%"
imageGCHighThresholdPercent: 85
imageGCLowThresholdPercent: 80
5.4.4. Create a non-default OpenshiftEC2NodeClass Copy linkLink copied to clipboard!
Create a non-default resource when you need to customize the OpenShift version, VPC subnets, security groups, tags, metadata options, or capacity reservations for your worker nodes. The default OpenshiftEC2NodeClass is immutable.
Modifying these resources, such as adding or changing AWS tags, security groups, and capacity reservation can cause a drift and initiate a new instance roll-out. See the Additional resources for more information.
Prerequisites
- The Red Hat build of Karpenter is enabled on the cluster.
-
The default
OpenshiftEC2NodeClassis in aReadystate. - You have cluster administrator access.
-
You have installed the
ocCLI and are logged in to the cluster.
Procedure
Create an
OpenshiftEC2NodeClassmanifest:$ cat > openshiftec2nodeclass.yaml <<'EOF' apiVersion: karpenter.hypershift.openshift.io/v1 kind: OpenshiftEC2NodeClass metadata: name: custom-nodeclass spec: tags: team: "engineering" EOFFor a complete list of configurable fields, see "OpenshiftEC2NodeClass configuration fields".
Apply the manifest:
$ oc apply -f openshiftec2nodeclass.yaml
Verification
Verify that the
OpenshiftEC2NodeClassresource was created:$ oc get openshiftec2nodeclassExample output
NAME READY AGE default True 1h custom-nodeclass True 5sVerify the resource is ready by checking its status conditions:
$ oc get openshiftec2nodeclass/custom-nodeclass -o json | jq '.status.conditions'If the
Readycondition isFalse, see the troubleshooting guidance in Additional resources.
5.4.5. Update a non-default OpenshiftEC2NodeClass Copy linkLink copied to clipboard!
You can update the fields of a non-default OpenshiftEC2NodeClass resource. The default OpenshiftEC2NodeClass is immutable and cannot be modified.
Updating the spec.version field initiates a rolling upgrade of all node pools that reference this OpenshiftEC2NodeClass. For more information about pinned and unpinned upgrade behavior, see the upgrade options in Additional resources.
Prerequisites
-
A non-default
OpenshiftEC2NodeClassresource exists. - You have cluster administrator access.
Procedure
View the current configuration of the
OpenshiftEC2NodeClassresource:$ oc get openshiftec2nodeclass/<nodeclass_name> -o yamlEdit the resource:
$ oc edit openshiftec2nodeclass/<nodeclass_name>Make the necessary changes to the spec fields. For a complete list of configurable fields, see "OpenshiftEC2NodeClass configuration fields".
- Save and close the editor to apply the changes.
Verification
Verify that the resource is ready after the update:
$ oc get openshiftec2nodeclass/<nodeclass_name> -o json | jq '.status.conditions[] | select(.type=="Ready")'Confirm that the
statusvalue isTrue.If you updated
spec.version, verify that the node pool nodes are rolling:$ oc get nodes
5.4.6. Delete a non-default OpenshiftEC2NodeClass Copy linkLink copied to clipboard!
Delete a non-default OpenshiftEC2NodeClass resource when it is no longer needed. Before deleting, you must remove or reassign all node pools that reference it.
You cannot delete the default OpenshiftEC2NodeClass. Only non-default resources can be deleted.
Deleting an OpenshiftEC2NodeClass while node pools still reference it prevents those node pools from provisioning new nodes.
Prerequisites
- You have cluster administrator access.
Procedure
Identify all node pools and the
OpenshiftEC2NodeClasseach one references:$ oc get nodepool -o json | jq -r '.items[] | "\(.metadata.name) -> \(.spec.template.spec.nodeClassRef.name)"'For each node pool identified in the previous step, either delete the node pool or update it to reference a different
OpenshiftEC2NodeClass:To delete a node pool:
$ oc delete nodepool <nodepool_name>To update a node pool to reference a different
OpenshiftEC2NodeClass:$ oc edit nodepool <nodepool_name>Change the
spec.template.spec.nodeClassRef.namefield to the name of a differentOpenshiftEC2NodeClass.
Delete the
OpenshiftEC2NodeClassresource:$ oc delete openshiftec2nodeclass <nodeclass_name>
Verification
Verify that the resource was deleted:
$ oc get openshiftec2nodeclassConfirm that the deleted resource is no longer listed.
Verify that no node pools reference the deleted resource:
$ oc get nodepool -o json | jq -r '.items[] | select(.spec.template.spec.nodeClassRef.name=="<nodeclass_name>") | .metadata.name'This command should return no output.
5.5. Encrypt root volumes with a customer-managed key Copy linkLink copied to clipboard!
You can use a customer-managed key (CMK) to encrypt root volumes on worker nodes provisioned by Red Hat build of Karpenter.
By default, root volumes use the default AWS KMS key for EBS encryption. To use a different symmetric KMS key, configure the KMS key policy and create an OpenshiftEC2NodeClass with it.
5.5.1. KMS key use policy for the Red Hat build of Karpenter Copy linkLink copied to clipboard!
The following key use policy must be attached to your customer-managed key (CMK) to allow the Red Hat build of Karpenter to use it for root volume encryption. This policy grants the Red Hat build of Karpenter IAM role the permissions to create and manage encrypted EBS volumes.
Required KMS key use policy
{
"Sid": "Allow use of the key for Karpenter",
"Effect": "Allow",
"Principal": {
"AWS": "<autonode_iam_role_arn>"
},
"Action": [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey",
"kms:CreateGrant",
"kms:ListGrants",
"kms:RevokeGrant"
],
"Resource": "*",
"Condition": {
"Bool": {
"kms:GrantIsForAWSResource": "true"
}
}
}
where:
<autonode_iam_role_arn>-
The ARN of the Red Hat build of Karpenter IAM role. You can obtain this value by running
rosa describe cluster -c $CLUSTER_NAME -o json | jq -r '.aws.sts.auto_mode.role_arn'.
5.5.2. Configure a customer-managed key for root volume encryption Copy linkLink copied to clipboard!
The root volume attached to the worker nodes managed by the Red Hat build of Karpenter is automatically encrypted using your default KMS key for EBS encryption. Alternatively, you can specify a different symmetric encryption KMS key for the specific volume creation operation.
You cannot modify the blockDeviceMappings field on an existing OpenshiftEC2NodeClass. You must create a new OpenshiftEC2NodeClass resource with the required KMS key configuration.
Prerequisites
- The Red Hat build of Karpenter is enabled on the cluster.
- You have a symmetric encryption AWS KMS key (customer-managed key).
- The KMS key use policy grants the required permissions to the Red Hat build of Karpenter IAM role.
Procedure
Obtain the ARN of the KMS key you want to use. If you want to use the cluster’s default KMS key, run the following command:
$ rosa describe cluster -c $CLUSTER_NAME -o json | jq -r '.aws.kms_key_arn'Create an
OpenshiftEC2NodeClassmanifest with the customer-managed key:$ cat > openshiftec2nodeclass-cmk.yaml <<'EOF' apiVersion: karpenter.hypershift.openshift.io/v1 kind: OpenshiftEC2NodeClass metadata: name: cmk-nodeclass spec: blockDeviceMappings: - deviceName: /dev/xvda ebs: encrypted: Encrypted volumeSizeGiB: <root_volume_size> kmsKeyID: <kms_key_arn> EOFwhere:
blockDeviceMappings.ebs.encrypted-
Must be set to
Encryptedto enable encryption. blockDeviceMappings.ebs.volumeSizeGiB- The size of the root volume in GiB.
blockDeviceMappings.ebs.kmsKeyID- The ARN of the symmetric encryption KMS key to use for root volume encryption.
Apply the manifest:
$ oc apply -f openshiftec2nodeclass-cmk.yaml
Verification
Verify that the
OpenshiftEC2NodeClassresource is ready:$ oc get openshiftec2nodeclass cmk-nodeclassExample output
NAME READY AGE cmk-nodeclass True 5s