// Module included in the following assemblies:
//
// * networking/ptp/configuring-ptp.adoc

:_mod-docs-content-type: PROCEDURE
[id="install-ptp-operator-cli_{context}"]
= Installing the PTP Operator using the CLI

[role="_abstract"]
As a cluster administrator, you can install the Operator by using the CLI.

.Prerequisites

* A cluster installed on bare-metal hardware with nodes that have hardware that supports PTP.
* Install the OpenShift CLI (`oc`).
* Log in as a user with `cluster-admin` privileges.

.Procedure

. Create a namespace for the PTP Operator.

.. Save the following YAML in the `ptp-namespace.yaml` file:
+
[source,yaml]
----
apiVersion: v1
kind: Namespace
metadata:
  name: openshift-ptp
  annotations:
    workload.openshift.io/allowed: management
  labels:
    name: openshift-ptp
    openshift.io/cluster-monitoring: "true"
----

.. Create the `Namespace` CR:
+
[source,terminal]
----
$ oc create -f ptp-namespace.yaml
----

. Create an Operator group for the PTP Operator.

.. Save the following YAML in the `ptp-operatorgroup.yaml` file:
+
[source,yaml]
----
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
  name: ptp-operators
  namespace: openshift-ptp
spec:
  targetNamespaces:
  - openshift-ptp
----

.. Create the `OperatorGroup` CR:
+
[source,terminal]
----
$ oc create -f ptp-operatorgroup.yaml
----

. Subscribe to the PTP Operator.

.. Save the following YAML in the `ptp-sub.yaml` file:
+
[source,yaml]
----
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: ptp-operator-subscription
  namespace: openshift-ptp
spec:
  channel: "stable"
  name: ptp-operator
  source: redhat-operators
  sourceNamespace: openshift-marketplace
----

.. Create the `Subscription` CR:
+
[source,terminal]
----
$ oc create -f ptp-sub.yaml
----

. To verify that the Operator is installed, enter the following command:
+
[source,terminal]
----
$ oc get csv -n openshift-ptp -o custom-columns=Name:.metadata.name,Phase:.status.phase
----
+
.Example output
[source,terminal,subs="attributes+"]
----
Name                         Phase
{product-version}.0-202301261535          Succeeded
----
