Chapter 5. Managing compute nodes using Red Hat build of Karpenter


5.1. About Red Hat build of Karpenter

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

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

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.

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 jq CLI tool.
  • You have installed the oc CLI tool.
  • You have the required AWS Identity and Access Management (IAM) permissions to create policies and roles.
Note

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.

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')
    Important

    Ensure 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

Create the IAM policy and role that the Red Hat build of Karpenter requires to provision Amazon Elastic Compute Cloud (Amazon EC2) instances.

Procedure

  1. 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"
                    }
                }
            }
        ]
    }
    EOF
  2. Create 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=true
  3. Attach 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}

Enable the Red Hat build of Karpenter on your cluster by using ROSA command-line interface (CLI) (rosa) after it finishes installing.

Procedure

  1. Wait for the cluster to become ready:

    $ rosa describe cluster -c $CLUSTER_ID | grep -i State

    Example output

    State:                      ready

  2. Ensure 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)
  3. Enable the Red Hat build of Karpenter:

    $ rosa edit cluster -c $CLUSTER_ID \
      --autonode=enabled \
      --autonode-iam-role-arn=$ROLE_ARN
  4. If you do not already have cluster admin access, create a cluster admin user:

    $ rosa create admin -c $CLUSTER_ID
  5. Log in to the cluster using the credentials from the previous command:

    $ oc login <api_url> --username cluster-admin --password <password>
  6. Verify that the Red Hat build of Karpenter custom resource definitions (CRDs) are present:

    $ oc get ec2nodeclass
    Note

    The node pool manifest uses the EC2NodeClass resource.

    Example output

    NAME      READY   AGE
    default   True    5m

    $ oc get openshiftec2nodeclass
    Note

    The OpenshiftEC2NodeClass resource is Red Hat’s wrapper to communicate with the EC2NodeClass resource.

    Example output

    NAME      READY
    default   True

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.

    Note

    Run rosa describe cluster -c $CLUSTER_NAME | grep "OIDC Endpoint URL" to see this URL. Do not include the https:// prefix from the OIDC Endpoint URL. For example, use example-oidc-endpoint.cloudfront.net/abcd1234examplehash5678 instead of https://example-oidc-endpoint.cloudfront.net/abcd1234examplehash5678.

  • You have the proper credentials to access the AWS console.

Procedure

  1. Export your AWS ID:

    $ export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
  2. Log in to the AWS console.
  3. In the AWS console, navigate to IAM > Roles.
  4. On your Red Hat build of Karpenter Amazon Resource Name (ARN), update the trust policy to include the following policy specifications:

    Note

    To 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.
  5. In OpenShift Cluster Manager, select your cluster from the cluster list.
  6. On the cluster details screen, select the Edit button next to the status for the Red Hat build of Karpenter.
  7. On the Edit Autonode settings dialog box, toggle Enable Autonode.
  8. Add your Red Hat build of Karpenter IAM role ARN to the field in this dialog box.
  9. Select Save to save your configurations and close the Edit Autonode settings box.

Verification

  1. Log in to the cluster:

    $ oc login <api_url> --username cluster-admin --password <password>
  2. Verify that the Red Hat build of Karpenter custom resource definitions (CRDs) are present:

    $ oc get ec2nodeclass

    Example output

    NAME      READY   AGE
    default   True    5m

    $ oc get openshiftec2nodeclass

    Example output

    NAME      READY
    default   True

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

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 EC2 instances. The selected EC2 instance must meet the minimum resource requirements of 4 vCPUs or more. To enforce this validation on your cluster, include the karpenter.k8s.aws/instance-cpu key in your spec.template.spec.requirements block.
  • Reserved Kubernetes labels: In the NodePool configurations 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.replicas field or StaticCapacity is 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.

    Warning

    By 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-type requirement to on-demand in your NodePool configuration.

5.3.2. Create a node pool

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 OpenshiftEC2NodeClass is in a Ready state.
  • You have installed the oc CLI and are logged in to the cluster.

Procedure

  1. 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
    EOF

    where:

    nodeClassRef.kind
    Required field that must use the EC2NodeClass type.
    spec.labels

    Optional field that you can use to place pods by using labels.

    Note

    For a list of all requirements available under spec.requirements, see the Additional resources.

  2. Apply the node pool:

    $ oc apply -f nodepool.yaml
  3. Verify the node pool is ready:

    $ oc get nodepool

    Example output

    NAME         NODECLASS   NODES   READY   AGE
    default-np   default     0       True    3s

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 OpenshiftEC2NodeClass resource exists and is in a Ready state.

Procedure

  1. 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>
    
    EOF

    where:

    nodeClassRef.name
    The name of the non-default OpenshiftEC2NodeClass resource. This value must match the metadata.name of an existing OpenshiftEC2NodeClass.
  2. Apply the node pool:

    $ oc apply -f nodepool.yaml

Verification

  • Verify that the node pool references the non-default OpenshiftEC2NodeClass:

    $ oc get nodepool

    Example output

    NAME        NODECLASS          NODES   READY   AGE
    custom-np   custom-nodeclass   0       True    3s

5.4. Manage OpenshiftEC2NodeClass resources

Create, update, and delete non-default OpenshiftEC2NodeClass resources to customize how the Red Hat build of Karpenter provisions worker nodes.

The OpenshiftEC2NodeClass resource has immutability and lifecycle rules that you must follow when managing node classes.

  • Resource immutability: The default OpenshiftEC2NodeClass resource is immutable. Use this resource only for referencing purposes inside the NodePool resources that you create.
  • Default node classes: A default OpenshiftEC2NodeClass is created automatically when you enable the Red Hat build of Karpenter in the cluster. All NodePool resources that reference the default OpenshiftEC2NodeClass upgrade automatically when the hosted control plane upgrades.
  • Control plane version pinning: All NodePool resources that do not specify a spec.version field upgrade automatically alongside the hosted control plane. If you prefer to prevent automated upgrades for specific node pools, you must pin the version of the OpenshiftEC2NodeClass resource by using the spec.version field.
  • 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 NodePool custom resources and the applications running on them before cleaning up any custom OpenshiftEC2NodeClass that the NodePool resources reference.

5.4.2. Storage and networking constraints

The following storage and networking constraints apply to OpenshiftEC2NodeClass resources.

  • Root volume constraints: Within the OpenshiftEC2NodeClass specification, the minimum allowed root volume size is 100 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 associatePublicIPAddress field to true on any OpenshiftEC2NodeClass that you create.

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.

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 OpenshiftEC2NodeClass resource. The name default is reserved for the system-managed immutable resource. Non-default resources must use a different name.
spec.version

Pins 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.

Important

The two minor version skew for OpenshiftEC2NodeClass resources 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 optional to allow IMDSv1 access without HTTP tokens. Set to required to enforce IMDSv2 with HTTP tokens. The default value is required.
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

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.

Note

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 OpenshiftEC2NodeClass is in a Ready state.
  • You have cluster administrator access.
  • You have installed the oc CLI and are logged in to the cluster.

Procedure

  1. Create an OpenshiftEC2NodeClass manifest:

    $ cat > openshiftec2nodeclass.yaml <<'EOF'
    apiVersion: karpenter.hypershift.openshift.io/v1
    kind: OpenshiftEC2NodeClass
    metadata:
      name: custom-nodeclass
    spec:
      tags:
        team: "engineering"
    EOF

    For a complete list of configurable fields, see "OpenshiftEC2NodeClass configuration fields".

  2. Apply the manifest:

    $ oc apply -f openshiftec2nodeclass.yaml

Verification

  1. Verify that the OpenshiftEC2NodeClass resource was created:

    $ oc get openshiftec2nodeclass

    Example output

    NAME               READY   AGE
    default            True    1h
    custom-nodeclass   True    5s

  2. Verify the resource is ready by checking its status conditions:

    $ oc get openshiftec2nodeclass/custom-nodeclass -o json | jq '.status.conditions'

    If the Ready condition is False, see the troubleshooting guidance in Additional resources.

5.4.5. Update a non-default OpenshiftEC2NodeClass

You can update the fields of a non-default OpenshiftEC2NodeClass resource. The default OpenshiftEC2NodeClass is immutable and cannot be modified.

Important

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 OpenshiftEC2NodeClass resource exists.
  • You have cluster administrator access.

Procedure

  1. View the current configuration of the OpenshiftEC2NodeClass resource:

    $ oc get openshiftec2nodeclass/<nodeclass_name> -o yaml
  2. Edit 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".

  3. Save and close the editor to apply the changes.

Verification

  1. 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 status value is True.

  2. If you updated spec.version, verify that the node pool nodes are rolling:

    $ oc get nodes

5.4.6. Delete a non-default OpenshiftEC2NodeClass

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.

Important

You cannot delete the default OpenshiftEC2NodeClass. Only non-default resources can be deleted.

Warning

Deleting an OpenshiftEC2NodeClass while node pools still reference it prevents those node pools from provisioning new nodes.

Prerequisites

  • You have cluster administrator access.

Procedure

  1. Identify all node pools and the OpenshiftEC2NodeClass each one references:

    $ oc get nodepool -o json | jq -r '.items[] | "\(.metadata.name) -> \(.spec.template.spec.nodeClassRef.name)"'
  2. 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.name field to the name of a different OpenshiftEC2NodeClass.

  3. Delete the OpenshiftEC2NodeClass resource:

    $ oc delete openshiftec2nodeclass <nodeclass_name>

Verification

  1. Verify that the resource was deleted:

    $ oc get openshiftec2nodeclass

    Confirm that the deleted resource is no longer listed.

  2. 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.

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.

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'.

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.

Important

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

  1. 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'
  2. Create an OpenshiftEC2NodeClass manifest 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>
    EOF

    where:

    blockDeviceMappings.ebs.encrypted
    Must be set to Encrypted to 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.
  3. Apply the manifest:

    $ oc apply -f openshiftec2nodeclass-cmk.yaml

Verification

  • Verify that the OpenshiftEC2NodeClass resource is ready:

    $ oc get openshiftec2nodeclass cmk-nodeclass

    Example output

    NAME             READY   AGE
    cmk-nodeclass    True    5s

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top