// Module included in the following assemblies:
//
// * scalability_and_performance/ztp_far_edge/ztp-talm-updating-managed-policies.adoc

:_mod-docs-content-type: PROCEDURE
[id="talo-platform-update-{policy-gen-cr}_{context}"]
= Performing a platform update with {policy-gen-cr} CRs

[role="_abstract"]
You can perform a platform update with the {cgu-operator}.

.Prerequisites

* Install the {cgu-operator-first}.
* Update {ztp-first} to the latest version.
* Provision one or more managed clusters with {ztp}.
* Mirror the required image repository.
* Log in as a user with `cluster-admin` privileges.
* Create {rh-rhacm} policies in the hub cluster.

.Procedure

. Create a `{policy-gen-cr}` CR for the platform update:

.. Save the following `{policy-gen-cr}` CR in the `du-upgrade.yaml` file:
+
--
The following example shows the `{policy-gen-cr}` CR for platform update:

ifeval::["{policy-gen-cr}" == "PolicyGenTemplate"]
include::snippets/pgt-cnf-topology-aware-lifecycle-manager-platform-update.adoc[]
endif::[]
ifeval::["{policy-gen-cr}" == "PolicyGenerator"]
include::snippets/pg-cnf-topology-aware-lifecycle-manager-platform-update.adoc[]
endif::[]

The `{policy-gen-cr}` CR generates two policies:

* The `du-upgrade-platform-upgrade-prep` policy does the preparation work for the platform update. It creates the `ConfigMap` CR for the required release image signature, creates the image content source of the mirrored release image repository, and updates the cluster version with the required update channel and the update graph reachable by the managed cluster in the disconnected environment.

* The `du-upgrade-platform-upgrade` policy is used to perform platform upgrade.
--

.. Add the `du-upgrade.yaml` file contents to the `kustomization.yaml` file located in the {ztp} Git repository for the `{policy-gen-cr}` CRs and push the changes to the Git repository.
+
ArgoCD pulls the changes from the Git repository and generates the policies on the hub cluster.

.. Check the created policies by running the following command:
+
[source,terminal]
----
$ oc get policies -A | grep platform-upgrade
----

. Create the `ClusterGroupUpdate` CR for the platform update with the `spec.enable` field set to `false`.

.. Save the content of the platform update `ClusterGroupUpdate` CR with the `du-upgrade-platform-upgrade-prep` and the `du-upgrade-platform-upgrade` policies and the target clusters to the `cgu-platform-upgrade.yml` file, as shown in the following example:
+
[source,yaml]
----
apiVersion: ran.openshift.io/v1alpha1
kind: ClusterGroupUpgrade
metadata:
  name: cgu-platform-upgrade
  namespace: default
spec:
  managedPolicies:
  - du-upgrade-platform-upgrade-prep
  - du-upgrade-platform-upgrade
  preCaching: false
  clusters:
  - spoke1
  remediationStrategy:
    maxConcurrency: 1
  enable: false
----

.. Apply the `ClusterGroupUpdate` CR to the hub cluster by running the following command:
+
[source,terminal]
----
$ oc apply -f cgu-platform-upgrade.yml
----

. Optional: Precache the images for the platform update.
.. Enable precaching in the `ClusterGroupUpdate` CR by running the following command:
+
[source,terminal]
----
$ oc --namespace=default patch clustergroupupgrade.ran.openshift.io/cgu-platform-upgrade \
--patch '{"spec":{"preCaching": true}}' --type=merge
----

.. Monitor the update process and wait for the pre-caching to complete. Check the status of pre-caching by running the following command on the hub cluster:
+
[source,terminal]
----
$ oc get cgu cgu-platform-upgrade -o jsonpath='{.status.precaching.status}'
----

. Start the platform update:
.. Enable the `cgu-platform-upgrade` policy and disable pre-caching by running the following command:
+
[source,terminal]
----
$ oc --namespace=default patch clustergroupupgrade.ran.openshift.io/cgu-platform-upgrade \
--patch '{"spec":{"enable":true, "preCaching": false}}' --type=merge
----

.. Monitor the process. Upon completion, ensure that the policy is compliant by running the following command:
+
[source,terminal]
----
$ oc get policies --all-namespaces
----
