Configuring PTP hardware
OKD includes the capability to use Precision Time Protocol (PTP)hardware on your nodes. You can configure linuxptp services on nodes in your cluster that have PTP-capable hardware.
The PTP Operator works with PTP-capable devices on clusters provisioned only on bare metal infrastructure. |
You can use the OKD console to install PTP by deploying the PTP Operator. The PTP Operator creates and manages the linuxptp services. The Operator provides the following features:
Discovery of the PTP-capable devices in a cluster.
Management of the configuration of linuxptp services.
The PTP Operator adds the custom resource definition (CRD) to OKD. The PTP Operator will search your cluster for PTP capable network devices on each node. The Operator creates and updates a NodePtpDevice
custom resource (CR) object for each node that provides a compatible PTP device.
One CR is created for each node, and shares the same name as the node. The .status.devices
list provides information about the PTP devices on a node.
The following is an example of a NodePtpDevice
CR created by the PTP Operator:
As a cluster administrator, you can install the PTP Operator using the OKD CLI or the web console.
As a cluster administrator, you can install the Operator 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.
To create a namespace for the PTP Operator, enter the following command:
$ cat << EOF| oc create -f -
apiVersion: v1
kind: Namespace
metadata:
name: openshift-ptp
annotations:
workload.openshift.io/allowed: management
labels:
name: openshift-ptp
openshift.io/cluster-monitoring: "true"
EOF
To create an Operator group for the Operator, enter the following command:
$ cat << EOF| oc create -f -
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: ptp-operators
namespace: openshift-ptp
spec:
targetNamespaces:
- openshift-ptp
EOF
To verify that the Operator is installed, enter the following command:
$ oc get csv -n openshift-ptp \
Example output
Web console: Installing the PTP Operator
As a cluster administrator, you can install the Operator using the web console.
You have to create the namespace and operator group as mentioned in the previous section. |
Procedure
Install the PTP Operator using the OKD web console:
In the OKD web console, click Operators → OperatorHub.
Choose PTP Operator from the list of available Operators, and then click Install.
On the Install Operator page, under A specific namespace on the cluster select openshift-ptp. Then, click Install.
Optional: Verify that the PTP Operator installed successfully:
Ensure that PTP Operator is listed in the openshift-ptp project with a Status of InstallSucceeded.
If the operator does not appear as installed, to troubleshoot further:
Go to the Operators → Installed Operators page and inspect the Operator Subscriptions and Install Plans tabs for any failure or errors under Status.
Go to the Workloads → Pods page and check the logs for pods in the
openshift-ptp
project.
The PTP Operator adds the PtpConfig.ptp.openshift.io
custom resource definition (CRD) to OKD. You can configure the Linuxptp services (ptp4l, phc2sys) by creating a PtpConfig
custom resource (CR) object.
Prerequisites
Install the OpenShift CLI (
oc
).Log in as a user with
cluster-admin
privileges.You must have installed the PTP Operator.
Procedure
Create the following
PtpConfig
CR, and then save the YAML in the<name>-ptp-config.yaml
file. Replace<name>
with the name for this configuration.apiVersion: ptp.openshift.io/v1
kind: PtpConfig
metadata:
name: <name> (1)
spec:
profile: (3)
- name: "profile1" (4)
interface: "ens787f1" (5)
ptp4lOpts: "-s -2" (6)
phc2sysOpts: "-a -r" (7)
recommend: (8)
- profile: "profile1" (9)
priority: 10 (10)
match: (11)
- nodeLabel: "node-role.kubernetes.io/worker" (12)
nodeName: "dev-worker-0" (13)
1 Specify a name for the PtpConfig
CR.2 Specify the namespace where the PTP Operator is installed. 3 Specify an array of one or more profile
objects.4 Specify the name of a profile object which is used to uniquely identify a profile object. 5 Specify the network interface name to use by the ptp4l
service, for exampleens787f1
.6 Specify system config options for the ptp4l
service, for example-s -2
. This should not include the interface name-i <interface>
and service config file-f /etc/ptp4l.conf
because these will be automatically appended.7 Specify system config options for the phc2sys
service, for example-a -r
.8 Specify an array of one or more recommend
objects which define rules on how theprofile
should be applied to nodes.9 Specify the profile
object name defined in theprofile
section.10 Specify the priority
with an integer value between0
and99
. A larger number gets lower priority, so a priority of99
is lower than a priority of . If a node can be matched with multiple profiles according to rules defined in thematch
field, the profile with the higher priority will be applied to that node.11 Specify match
rules withnodeLabel
ornodeName
.12 Specify nodeLabel
with thekey
ofnode.Labels
from the node object.13 Specify nodeName
withnode.Name
from the node object.Create the CR by running the following command:
$ oc create -f <filename> (1)
Optional: Check that the
PtpConfig
profile is applied to nodes that match withnodeLabel
ornodeName
.Example output
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
linuxptp-daemon-4xkbb 1/1 Running 0 43m 192.168.111.15 dev-worker-0 <none> <none>
linuxptp-daemon-tdspf 1/1 Running 0 43m 192.168.111.11 dev-master-0 <none> <none>
ptp-operator-657bbb64c8-2f8sj 1/1 Running 0 43m 10.128.0.116 dev-master-0 <none> <none>
$ oc logs linuxptp-daemon-4xkbb -n openshift-ptp
I1115 09:41:17.117596 4143292 daemon.go:107] in applyNodePTPProfile
I1115 09:41:17.117604 4143292 daemon.go:109] updating NodePTPProfile to:
I1115 09:41:17.117607 4143292 daemon.go:110] ------------------------------------
I1115 09:41:17.117612 4143292 daemon.go:102] Profile Name: profile1 (1)
I1115 09:41:17.117616 4143292 daemon.go:102] Interface: ens787f1 (2)
I1115 09:41:17.117620 4143292 daemon.go:102] Ptp4lOpts: -s -2 (3)
I1115 09:41:17.117623 4143292 daemon.go:102] Phc2sysOpts: -a -r (4)
I1115 09:41:17.117626 4143292 daemon.go:116] ------------------------------------
I1115 09:41:18.117934 4143292 daemon.go:186] Starting phc2sys...
I1115 09:41:18.117985 4143292 daemon.go:187] phc2sys cmd: &{Path:/usr/sbin/phc2sys Args:[/usr/sbin/phc2sys -a -r] Env:[] Dir: Stdin:<nil> Stdout:<nil> Stderr:<nil> ExtraFiles:[] SysProcAttr:<nil> Process:<nil> ProcessState:<nil> ctx:<nil> lookPathErr:<nil> finished:false childFiles:[] closeAfterStart:[] closeAfterWait:[] goroutine:[] errch:<nil> waitDone:<nil>}
I1115 09:41:19.118175 4143292 daemon.go:186] Starting ptp4l...
I1115 09:41:19.118209 4143292 daemon.go:187] ptp4l cmd: &{Path:/usr/sbin/ptp4l Args:[/usr/sbin/ptp4l -m -f /etc/ptp4l.conf -i ens787f1 -s -2] Env:[] Dir: Stdin:<nil> Stdout:<nil> Stderr:<nil> ExtraFiles:[] SysProcAttr:<nil> Process:<nil> ProcessState:<nil> ctx:<nil> lookPathErr:<nil> finished:false childFiles:[] closeAfterStart:[] closeAfterWait:[] goroutine:[] errch:<nil> waitDone:<nil>}
ptp4l[102189.864]: selected /dev/ptp5 as PTP clock
ptp4l[102189.886]: port 0: INITIALIZING to LISTENING on INIT_COMPLETE
1 Profile Name
is the name that is applied to nodedev-worker-0
.2 Interface
is the PTP device specified in theprofile1
interface field. Theptp4l
service runs on this interface.3 Ptp4lOpts
are the ptp4l sysconfig options specified inprofile1
Ptp4lOpts field.4 Phc2sysOpts
are the phc2sys sysconfig options specified in Phc2sysOpts field.