// Module included in the following assemblies:
// hosted_control_planes/hcp-manage/hcp-manage-aws.adoc

:_mod-docs-content-type: PROCEDURE
[id="hcp-np-capacity-blocks_{context}"]
= Configuring node pool capacity blocks on {aws-short}

[role="_abstract"]
After you create a hosted cluster, you can configure node pool capacity blocks for graphics processing unit (GPU) reservations on {aws-first}.

.Procedure

. Create GPU reservations on {aws-short} by running a command similar to the following example:
+
[IMPORTANT]
====
The zone of the GPU reservation must match your hosted cluster zone.
====
+
[source,terminal]
----
$ aws ec2 describe-capacity-block-offerings \
      --instance-type "p4d.24xlarge"\
      --instance-count  "1" \
      --start-date-range "$(date -u +"2025-07-21T10:14:39Z")"  \
      --end-date-range "$(date -u -d "2 day" +"2025-07-22T10:16:36Z")" \
      --capacity-duration-hours 24 \
      --output json
----
+
* `--instance-type` defines the type of your {aws-short} instance.
* `--instance-count` defines your instance purchase quantity. Valid values are integers ranging from `1` to `64`.
* `--start-date-range` defines the start date range.
* `--end-date-range` defines the end date range.
* `--capacity-duration-hours` defines the duration of capacity blocks in hours.

. Purchase the minimum fee capacity block by running the following command:
+
[source,terminal]
----
$ aws ec2 purchase-capacity-block \
      --capacity-block-offering-id "${MIN_FEE_ID}" \
      --instance-platform "Linux/UNIX"\
      --tag-specifications 'ResourceType=capacity-reservation,Tags=[{Key=usage-cluster-type,Value=hypershift-hosted}]' \
      --output json   > "${CR_OUTPUT_FILE}"
----
+
* `--capacity-block-offering-id` defines the ID of the capacity block offering.
* `--instance-platform` defines the platform of your instance.
* `--tag-specifications` defines the tag for your instance.

. Create an environment variable to set the capacity reservation ID by running the following command:
+
[source,terminal]
----
$ CB_RESERVATION_ID=$(jq -r '.CapacityReservation.CapacityReservationId' "${CR_OUTPUT_FILE}")
----
+
Wait for a couple of minutes for the GPU reservation to become available.

. Add a node pool to use the GPU reservation by running the following command:
+
[source,terminal]
----
$ hcp create nodepool aws \
  --cluster-name <hosted_cluster_name> \
  --name <node_pool_name> \
  --node-count <node_pool_count> \
  --instance-type <instance_type> \
  --arch <arch_type> \
  --release-image <release_image> \
  --render > /tmp/np.yaml
----
+
* `--cluster-name` specifies the name of your hosted cluster.
* `--name` specifies the name of your node pool.
* `--node-count` defines the node pool count, for example, `1`.
* `--instance-type` defines the instance type, for example, `p4d.24xlarge`.
* `--arch` defines an architecture type, for example, `amd64`.
* `--release-image` specifies the release image you want to use.

. Add the `capacityReservation` setting in your `NodePool` resource by using the following example configuration:
+
[source,yaml]
----
# ...
spec:
  arch: amd64
  clusterName: cb-np-hcp
  management:
    autoRepair: false
    upgradeType: Replace
  platform:
    aws:
      instanceProfile: cb-np-hcp-dqppw-worker
      instanceType: p4d.24xlarge
      rootVolume:
        size: 120
        type: gp3
      subnet:
        id: subnet-00000
      placement:
        capacityReservation:
          id: ${CB_RESERVATION_ID}
          marketType: CapacityBlocks
    type: AWS
# ...
----

. Apply the node pool configuration by running the following command:
+
[source,terminal]
----
$ oc apply -f /tmp/np.yaml
----

.Verification

. Verify that your new node pool is created successfully by running the following command:
+
[source,terminal]
----
$ oc get np -n clusters
----
+
.Example output
[source,terminal]
----
NAMESPACE   NAME    CLUSTER     DESIRED NODES   CURRENT  NODES   AUTOSCALING     AUTOREPAIR   VERSION                               UPDATINGVERSION   UPDATINGCONFIG   MESSAGE
clusters    cb-np   cb-np-hcp   1               1                False           False        4.22.0-0.nightly-2025-06-05-224220    False             False
----

. Verify that your new compute nodes are created in the hosted cluster by running the following command:
+
[source,terminal]
----
$ oc get nodes
----
+
.Example output
[source, terminal]
----
NAME                           STATUS   ROLES    AGE    VERSION
ip-10-0-132-74.ec2.internal    Ready    worker   17m    v1.35.4
ip-10-0-134-183.ec2.internal   Ready    worker   4h5m   v1.35.4
----
