13.5. 配置 PTP 设备
PTP Operator 将 NodePtpDevice.ptp.openshift.io 自定义资源定义(CRD)添加到 OpenShift Container Platform。
安装后,PTP Operator 会在每个节点中搜索具有 PTP 功能的网络设备。它为提供兼容 PTP 的网络设备的每个节点创建并更新 NodePtpDevice 自定义资源(CR)对象。
13.5.1. 在集群中发现具有 PTP 功能网络设备
要返回集群中具有 PTP 功能网络设备的完整列表,请运行以下命令:
$ oc get NodePtpDevice -n openshift-ptp -o yaml
输出示例
apiVersion: v1 items: - apiVersion: ptp.openshift.io/v1 kind: NodePtpDevice metadata: creationTimestamp: "2022-01-27T15:16:28Z" generation: 1 name: dev-worker-0 1 namespace: openshift-ptp resourceVersion: "6538103" uid: d42fc9ad-bcbf-4590-b6d8-b676c642781a spec: {} status: devices: 2 - name: eno1 - name: eno2 - name: eno3 - name: eno4 - name: enp5s0f0 - name: enp5s0f1 ...
13.5.2. 将 linuxptp 服务配置为常规时钟
您可以通过创建 PtpConfig 自定义资源(CR)对象将 linuxptp 服务(ptp4l、phc2sys)配置为常规时钟。
使用 PtpConfig CR 示例,将 linuxptp 服务配置为特定硬件和环境的普通时钟。这个示例 CR 没有配置 PTP 快速事件。要配置 PTP 快速事件,请为 ptp4lOpts、ptp4lConf 和 ptpClockThreshold 设置适当的值。只有在启用事件时才需要 ptpClockThreshold。如需更多信息,请参阅"配置 PTP 快速事件通知发布程序"。
先决条件
-
安装 OpenShift CLI(
oc)。 -
以具有
cluster-admin特权的用户身份登录。 - 安装 PTP Operator。
流程
创建以下
PtpConfigCR,然后在ordinary-clock-ptp-config.yaml文件中保存 YAML。推荐的 PTP 普通时钟配置
apiVersion: ptp.openshift.io/v1 kind: PtpConfig metadata: name: ordinary-clock-ptp-config namespace: openshift-ptp spec: profile: - name: ordinary-clock interface: "<interface_name>" phc2sysOpts: "-a -r -n 24" ptp4lOpts: "-2 -s" ptpSchedulingPolicy: SCHED_FIFO ptpSchedulingPriority: 10 ptp4lConf: | [global] # # Default Data Set # twoStepFlag 1 slaveOnly 1 priority1 128 priority2 128 domainNumber 24 clockClass 255 clockAccuracy 0xFE offsetScaledLogVariance 0xFFFF free_running 0 freq_est_interval 1 dscp_event 0 dscp_general 0 dataset_comparison G.8275.x G.8275.defaultDS.localPriority 128 # # Port Data Set # logAnnounceInterval -3 logSyncInterval -4 logMinDelayReqInterval -4 logMinPdelayReqInterval -4 announceReceiptTimeout 3 syncReceiptTimeout 0 delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 20000000 masterOnly 0 G.8275.portDS.localPriority 128 # # Run time options # assume_two_step 0 logging_level 6 path_trace_enabled 0 follow_up_info 0 hybrid_e2e 0 inhibit_multicast_service 0 net_sync_monitor 0 tc_spanning_tree 0 tx_timestamp_timeout 50 unicast_listen 0 unicast_master_table 0 unicast_req_duration 3600 use_syslog 1 verbose 0 summary_interval 0 kernel_leap 1 check_fup_sync 0 # # Servo Options # pi_proportional_const 0.0 pi_integral_const 0.0 pi_proportional_scale 0.0 pi_proportional_exponent -0.3 pi_proportional_norm_max 0.7 pi_integral_scale 0.0 pi_integral_exponent 0.4 pi_integral_norm_max 0.3 step_threshold 2.0 first_step_threshold 0.00002 max_frequency 900000000 clock_servo pi sanity_freq_limit 200000000 ntpshm_segment 0 # # Transport options # transportSpecific 0x0 ptp_dst_mac 01:1B:19:00:00:00 p2p_dst_mac 01:80:C2:00:00:0E udp_ttl 1 udp6_scope 0x0E uds_address /var/run/ptp4l # # Default interface options # clock_type OC network_transport L2 delay_mechanism E2E time_stamping hardware tsproc_mode filter delay_filter moving_median delay_filter_length 10 egressLatency 0 ingressLatency 0 boundary_clock_jbod 0 # # Clock description # productDescription ;; revisionData ;; manufacturerIdentity 00:00:00 userDescription ; timeSource 0xA0 recommend: - profile: ordinary-clock priority: 4 match: - nodeLabel: "node-role.kubernetes.io/worker" nodeName: "<node_name>"表 13.1. PTP 普通时钟 CR 配置选项
自定义资源字段 描述 namePtpConfigCR 的名称。配置集指定包括一个或多个
profile的数组。每个配置集的名称都需要是唯一的。interface指定
ptp4l服务要使用的网络接口,如ens787f1。ptp4lOpts为
ptp4l服务指定系统配置选项,例如-2来选择 IEEE 802.3 网络传输。该选项不应包含网络接口名称-i <interface>和服务配置文件-f /etc/ptp4l.conf,因为网络接口名称和服务配置文件会被自动附加。附加--summary_interval -4来对此接口使用 PTP 快速事件。phc2sysOpts为
phc2sys服务指定系统配置选项。如果此字段为空,PTP Operator 不会启动phc2sys服务。对于 Intel Columbiaville 800 Series NIC,将phc2sysOpts选项设置为-a -r -m -n 24 -N 8 -R 16.-m将消息输出到stdout。linuxptp-daemonDaemonSet解析日志并生成 Prometheus 指标。ptp4lConf指定一个字符串,其中包含要替换默认的
/etc/ptp4l.conf文件的配置。要使用默认配置,请将字段留空。tx_timestamp_timeout对于 Intel Columbiaville 800 系列 NIC,将
tx_timestamp_timeout设置为50。boundary_clock_jbod对于 Intel Columbiaville 800 系列 NIC,将
boundary_clock_jbod设置为0。ptpSchedulingPolicyptp4l和phc2sys进程的调度策略。默认值为SCHED_OTHER。在支持 FIFO 调度的系统上使用SCHED_FIFO。ptpSchedulingPriority当
ptpSchedulingPolicy设置为SCHED_FIFO时,用于为ptp4l和phc2sys进程设置 FIFO 优先级的整数值(1 到 65)。当ptpSchedulingPolicy设置为SCHED_OTHER时,不使用ptpSchedulingPriority字段。ptpClockThreshold可选的。如果没有
ptpClockThreshold,用于ptpClockThreshold字段的默认值。ptpClockThreshold配置在触发 PTP 时间前,PTP master 时钟已断开连接的时长。holdOverTimeout是在 PTP master clock 断开连接时,PTP 时钟事件状态更改为FREERUN前的时间值(以秒为单位)。maxOffsetThreshold和minOffsetThreshold设置以纳秒为单位,它们与CLOCK_REALTIME(phc2sys) 或 master 偏移 (ptp4l) 的值进行比较。当ptp4l或phc2sys偏移值超出这个范围时,PTP 时钟状态被设置为FREERUN。当偏移值在这个范围内时,PTP 时钟状态被设置为LOCKED。建议指定包括一个或多个
recommend对象的数组,该数组定义了如何将配置集应用到节点的规则。.recommend.profile指定在
profile部分定义的.recommend.profile对象名称。.recommend.priority对于普通时钟,将
.recommend.priority设置为0。.recommend.match使用
nodeLabel或nodeName指定.recommend.match规则。.recommend.match.nodeLabel通过
oc get nodes --show-labels命令,使用来自节点对象的node.Labels的key更新nodeLabel。例如:node-role.kubernetes.io/worker。.recommend.match.nodeLabel通过
oc get nodes命令,使用来自节点对象的node.Name值更新nodeName。例如:compute-0.example.com.运行以下命令来创建
PtpConfigCR:$ oc create -f ordinary-clock-ptp-config.yaml
验证
检查
PtpConfig配置集是否已应用到节点。运行以下命令,获取
openshift-ptp命名空间中的 pod 列表:$ oc get pods -n openshift-ptp -o wide
输出示例
NAME READY STATUS RESTARTS AGE IP NODE linuxptp-daemon-4xkbb 1/1 Running 0 43m 10.1.196.24 compute-0.example.com linuxptp-daemon-tdspf 1/1 Running 0 43m 10.1.196.25 compute-1.example.com ptp-operator-657bbb64c8-2f8sj 1/1 Running 0 43m 10.129.0.61 control-plane-1.example.com
检查配置集是否正确。检查与
PtpConfig配置集中指定的节点对应的linuxptp守护进程的日志。运行以下命令:$ oc logs linuxptp-daemon-4xkbb -n openshift-ptp -c linuxptp-daemon-container
输出示例
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 I1115 09:41:17.117616 4143292 daemon.go:102] Interface: ens787f1 I1115 09:41:17.117620 4143292 daemon.go:102] Ptp4lOpts: -2 -s I1115 09:41:17.117623 4143292 daemon.go:102] Phc2sysOpts: -a -r -n 24 I1115 09:41:17.117626 4143292 daemon.go:116] ------------------------------------
其他资源
- 如需有关 PTP 硬件上的 FIFO 优先级调度的更多信息,请参阅为 PTP 硬件配置 FIFO 优先级调度。
- 有关配置 PTP 快速事件的更多信息,请参阅配置 PTP 快速事件通知发布程序。
13.5.3. 将 linuxptp 服务配置为边界时钟
您可以通过创建 PtpConfig 自定义资源(CR)对象将 linuxptp 服务(ptp4l、phc2sys)配置为边界时钟。
使用 PtpConfig CR 示例,将 linuxptp 服务配置为特定硬件和环境的边界时钟。这个示例 CR 没有配置 PTP 快速事件。要配置 PTP 快速事件,请为 ptp4lOpts、ptp4lConf 和 ptpClockThreshold 设置适当的值。ptpClockThreshold 仅在启用事件时使用。如需更多信息,请参阅"配置 PTP 快速事件通知发布程序"。
先决条件
-
安装 OpenShift CLI(
oc)。 -
以具有
cluster-admin特权的用户身份登录。 - 安装 PTP Operator。
流程
创建以下
PtpConfigCR,然后在boundaries-clock-ptp-config.yaml文件中保存 YAML。推荐的 PTP 边界时钟配置
--- apiVersion: ptp.openshift.io/v1 kind: PtpConfig metadata: name: boundary-clock-ptp-config namespace: openshift-ptp spec: profile: - name: boundary-clock phc2sysOpts: "-a -r -n 24" ptp4lOpts: "-2" ptpSchedulingPolicy: SCHED_FIFO ptpSchedulingPriority: 10 ptp4lConf: | [<interface_1>] masterOnly 0 [<interface_2>] masterOnly 1 [<interface_3>] masterOnly 1 [<interface_4>] masterOnly 1 [global] # # Default Data Set # twoStepFlag 1 slaveOnly 0 priority1 128 priority2 128 domainNumber 24 clockClass 248 clockAccuracy 0xFE offsetScaledLogVariance 0xFFFF free_running 0 freq_est_interval 1 dscp_event 0 dscp_general 0 dataset_comparison G.8275.x G.8275.defaultDS.localPriority 128 # # Port Data Set # logAnnounceInterval -3 logSyncInterval -4 logMinDelayReqInterval -4 logMinPdelayReqInterval -4 announceReceiptTimeout 3 syncReceiptTimeout 0 delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 20000000 masterOnly 0 G.8275.portDS.localPriority 128 # # Run time options # assume_two_step 0 logging_level 6 path_trace_enabled 0 follow_up_info 0 hybrid_e2e 0 inhibit_multicast_service 0 net_sync_monitor 0 tc_spanning_tree 0 tx_timestamp_timeout 50 unicast_listen 0 unicast_master_table 0 unicast_req_duration 3600 use_syslog 1 verbose 0 summary_interval 0 kernel_leap 1 check_fup_sync 0 # # Servo Options # pi_proportional_const 0.0 pi_integral_const 0.0 pi_proportional_scale 0.0 pi_proportional_exponent -0.3 pi_proportional_norm_max 0.7 pi_integral_scale 0.0 pi_integral_exponent 0.4 pi_integral_norm_max 0.3 step_threshold 2.0 first_step_threshold 0.00002 max_frequency 900000000 clock_servo pi sanity_freq_limit 200000000 ntpshm_segment 0 # # Transport options # transportSpecific 0x0 ptp_dst_mac 01:1B:19:00:00:00 p2p_dst_mac 01:80:C2:00:00:0E udp_ttl 1 udp6_scope 0x0E uds_address /var/run/ptp4l # # Default interface options # clock_type BC network_transport L2 delay_mechanism E2E time_stamping hardware tsproc_mode filter delay_filter moving_median delay_filter_length 10 egressLatency 0 ingressLatency 0 boundary_clock_jbod 0 # # Clock description # productDescription ;; revisionData ;; manufacturerIdentity 00:00:00 userDescription ; timeSource 0xA0 recommend: - profile: boundary-clock priority: 4 match: - nodeLabel: node-role.kubernetes.io/master nodeName: <nodename>表 13.2. PTP 边界时钟 CR 配置选项
自定义资源字段 描述 namePtpConfigCR 的名称。配置集指定包括一个或多个
profile的数组。name指定唯一标识配置集对象的配置集对象的名称。
ptp4lOpts为
ptp4l服务指定系统配置选项。该选项不应包含网络接口名称-i <interface>和服务配置文件-f /etc/ptp4l.conf,因为网络接口名称和服务配置文件会被自动附加。ptp4lConf指定启动
ptp4l作为边界时钟所需的配置。例如,ens1f0同步来自 Pumaster 时钟,ens1f3同步连接的设备。<interface_1>接收同步时钟的接口。
<interface_2>发送同步时钟的接口。
tx_timestamp_timeout对于 Intel Columbiaville 800 系列 NIC,将
tx_timestamp_timeout设置为50。boundary_clock_jbod对于 Intel Columbiaville 800 系列 NIC,请确保
boundary_clock_jbod设置为0。对于 Intel Fortville X710 系列 NIC,请确保boundary_clock_jbod设置为1。phc2sysOpts为
phc2sys服务指定系统配置选项。如果此字段为空,PTP Operator 不会启动phc2sys服务。ptpSchedulingPolicyptp4l 和 phc2sys 进程的调度策略。默认值为
SCHED_OTHER。在支持 FIFO 调度的系统上使用SCHED_FIFO。ptpSchedulingPriority当
ptpSchedulingPolicy设置为SCHED_FIFO时,用于为ptp4l和phc2sys进程设置 FIFO 优先级的整数值(1 到 65)。当ptpSchedulingPolicy设置为SCHED_OTHER时,不使用ptpSchedulingPriority字段。ptpClockThreshold可选的。如果没有
ptpClockThreshold,用于ptpClockThreshold字段的默认值。ptpClockThreshold配置在触发 PTP 时间前,PTP master 时钟已断开连接的时长。holdOverTimeout是在 PTP master clock 断开连接时,PTP 时钟事件状态更改为FREERUN前的时间值(以秒为单位)。maxOffsetThreshold和minOffsetThreshold设置以纳秒为单位,它们与CLOCK_REALTIME(phc2sys) 或 master 偏移 (ptp4l) 的值进行比较。当ptp4l或phc2sys偏移值超出这个范围时,PTP 时钟状态被设置为FREERUN。当偏移值在这个范围内时,PTP 时钟状态被设置为LOCKED。建议指定包括一个或多个
recommend对象的数组,该数组定义了如何将配置集应用到节点的规则。.recommend.profile指定在
profile部分定义的.recommend.profile对象名称。.recommend.priority使用
0到99之间的一个整数值指定priority。大数值的优先级较低,因此优先级99低于优先级10。如果节点可以根据match字段中定义的规则与多个配置集匹配,则优先级较高的配置集会应用到该节点。.recommend.match使用
nodeLabel或nodeName指定.recommend.match规则。.recommend.match.nodeLabel通过
oc get nodes --show-labels命令,使用来自节点对象的node.Labels的key更新nodeLabel。例如:node-role.kubernetes.io/worker。.recommend.match.nodeLabel通过
oc get nodes命令,使用来自节点对象的node.Name值更新nodeName。例如:compute-0.example.com.运行以下命令来创建 CR:
$ oc create -f boundary-clock-ptp-config.yaml
验证
检查
PtpConfig配置集是否已应用到节点。运行以下命令,获取
openshift-ptp命名空间中的 pod 列表:$ oc get pods -n openshift-ptp -o wide
输出示例
NAME READY STATUS RESTARTS AGE IP NODE linuxptp-daemon-4xkbb 1/1 Running 0 43m 10.1.196.24 compute-0.example.com linuxptp-daemon-tdspf 1/1 Running 0 43m 10.1.196.25 compute-1.example.com ptp-operator-657bbb64c8-2f8sj 1/1 Running 0 43m 10.129.0.61 control-plane-1.example.com
检查配置集是否正确。检查与
PtpConfig配置集中指定的节点对应的linuxptp守护进程的日志。运行以下命令:$ oc logs linuxptp-daemon-4xkbb -n openshift-ptp -c linuxptp-daemon-container
输出示例
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 I1115 09:41:17.117616 4143292 daemon.go:102] Interface: I1115 09:41:17.117620 4143292 daemon.go:102] Ptp4lOpts: -2 I1115 09:41:17.117623 4143292 daemon.go:102] Phc2sysOpts: -a -r -n 24 I1115 09:41:17.117626 4143292 daemon.go:116] ------------------------------------
其他资源
- 如需有关 PTP 硬件上的 FIFO 优先级调度的更多信息,请参阅为 PTP 硬件配置 FIFO 优先级调度。
- 有关配置 PTP 快速事件的更多信息,请参阅配置 PTP 快速事件通知发布程序。
13.5.4. Intel Columbiaville E800 series NIC 作为 PTP 常规时钟参考
下表描述了您必须对引用 PTP 配置进行的更改,以便使用 Intel Columbiaville E800 系列 NIC 作为普通时钟。在应用到集群的 PtpConfig 自定义资源(CR)中进行更改。
表 13.3. Intel Columbiaville NIC 的推荐 PTP 设置
| PTP 配置 | 推荐的设置 |
|---|---|
|
|
|
|
|
|
|
|
|
对于 phc2sysOpts,-m 会将信息输出到 stdout。linuxptp-daemon DaemonSet 解析日志并生成 Prometheus 指标。
其他资源
-
有关将
linuxptp服务配置为具有 PTP 快速事件的普通时钟的完整示例 CR,请参阅将 linuxptp 服务配置为普通时钟。
13.5.5. 为 PTP 硬件配置 FIFO 优先级调度
在需要低延迟性能的电信或其他部署配置中,PTP 守护进程线程在受限制的 CPU 占用空间以及剩余的基础架构组件一起运行。默认情况下,PTP 线程使用 SCHED_OTHER 策略运行。在高负载下,这些线程可能没有获得无错操作所需的调度延迟。
要缓解潜在的调度延迟错误,您可以将 PTP Operator linuxptp 服务配置为允许线程使用 SCHED_FIFO 策略运行。如果为 PtpConfig CR 设置了 SCHED_FIFO,则 ptp4l 和 phc2sys 将在 chrt 的父容器中运行,且由 PtpConfig CR 的 ptpSchedulingPriority 字段设置。
设置 ptpSchedulingPolicy 是可选的,只有在遇到延迟错误时才需要。
流程
编辑
PtpConfigCR 配置集:$ oc edit PtpConfig -n openshift-ptp
更改
ptpSchedulingPolicy和ptpSchedulingPriority字段:apiVersion: ptp.openshift.io/v1 kind: PtpConfig metadata: name: <ptp_config_name> namespace: openshift-ptp ... spec: profile: - name: "profile1" ... ptpSchedulingPolicy: SCHED_FIFO 1 ptpSchedulingPriority: 10 2-
保存并退出,以将更改应用到
PtpConfigCR。
验证
获取
linuxptp-daemonpod 的名称以及应用PtpConfigCR 的对应节点:$ oc get pods -n openshift-ptp -o wide
输出示例
NAME READY STATUS RESTARTS AGE IP NODE linuxptp-daemon-gmv2n 3/3 Running 0 1d17h 10.1.196.24 compute-0.example.com linuxptp-daemon-lgm55 3/3 Running 0 1d17h 10.1.196.25 compute-1.example.com ptp-operator-3r4dcvf7f4-zndk7 1/1 Running 0 1d7h 10.129.0.61 control-plane-1.example.com
检查
ptp4l进程是否使用更新的chrtFIFO 运行:$ oc -n openshift-ptp logs linuxptp-daemon-lgm55 -c linuxptp-daemon-container|grep chrt
输出示例
I1216 19:24:57.091872 1600715 daemon.go:285] /bin/chrt -f 65 /usr/sbin/ptp4l -f /var/run/ptp4l.0.config -2 --summary_interval -4 -m