// Module included in the following assemblies:
//
// * hosted_control_planes/hcp-updating.adoc

:_mod-docs-content-type: PROCEDURE
[id="hcp-update-ocp-hc_{context}"]
= Updating a control plane in a hosted cluster

[role="_abstract"]
In {hcp}, you can upgrade your version of {product-title} by updating the hosted cluster.

The `.spec.release` in the `HostedCluster` custom resource (CR) shows the version of the control plane. The `HostedCluster` updates the `.spec.release` field to the `HostedControlPlane.spec.release` and runs the appropriate Control Plane Operator version.

The `HostedControlPlane` resource orchestrates the rollout of the new version of the control plane components along with the {product-title} component in the data plane through the new version of the Cluster Version Operator (CVO). The `HostedControlPlane` includes the following artifacts:

* CVO
* Cluster Network Operator (CNO)
* Cluster Ingress Operator
* Manifests for the Kube API server, scheduler, and manager
* Machine approver
* Autoscaler
* Infrastructure resources to enable ingress for control plane endpoints such as the Kube API server, ignition, and konnectivity

You can set the `.spec.release` field in the `HostedCluster` CR to update the control plane by using the information from the `status.version.availableUpdates` and `status.version.conditionalUpdates` fields.

.Procedure

. Add the `hypershift.openshift.io/force-upgrade-to=<openshift_release_image>` annotation to the hosted cluster by entering the following command:
+
[source,terminal]
----
$ oc annotate hostedcluster \
  -n <hosted_cluster_namespace> <hosted_cluster_name> \
  "hypershift.openshift.io/force-upgrade-to=<openshift_release_image>" \
  --overwrite
----
+
* Replace `<hosted_cluster_name>` with your hosted cluster name and `<hosted_cluster_namespace>` with your hosted cluster namespace.
* The `<openshift_release_image>` variable specifies the new {product-title} release image that you want to upgrade to, for example, `quay.io/openshift-release-dev/ocp-release:<4.y.z>-x86_64`. Replace `<4.y.z>` with the supported {product-title} version.

. Change the `spec.release.image` value in the hosted cluster by entering the following command:
+
[source,terminal]
----
$ oc patch hostedcluster <hosted_cluster_name> -n <hosted_cluster_namespace> \
  --type=merge \
  -p '{"spec":{"release":{"image":"<openshift_release_image>"}}}'
----

.Verification

* To verify that the new version was rolled out, check the `.status.conditions` and `.status.version` values in the hosted cluster by running the following command:
+
[source,terminal]
----
$ oc get -n <hosted_cluster_namespace> hostedcluster <hosted_cluster_name> \
  -o yaml
----
+
.Example output
[source,terminal]
----
status:
 conditions:
 - lastTransitionTime: "2024-05-20T15:01:01Z"
        message: Payload loaded version="4.20.0" image="quay.io/openshift-release-dev/ocp-release:4.20.0-x86_64"
        status: "True"
        type: ClusterVersionReleaseAccepted
#...
version:
      availableUpdates: null
      desired:
      image: quay.io/openshift-release-dev/ocp-release:4.20.0-x86_64
      version: 4.20.0
----
